# Class Configuration

java.lang.Object
jdk.jfr.Configuration

public final class Configuration extends Object
A collection of settings and metadata describing the configuration.

The following example shows how the `Configuration` class can be used to list available configurations and how to pass a configuration object to a `Recording`.

    public static void main(String... args) throws Exception {
        if (args.length == 0) {
            System.out.println("Configurations:");
            for (Configuration c : Configuration.getConfigurations()) {
                System.out.println("Name: " + c.getName());
                System.out.println("Label: " + c.getLabel());
                System.out.println("Description: " + c.getDescription());
                System.out.println("Provider: " + c.getProvider());
                System.out.println();
            }
        } else {
            String name = args[0];
            Configuration c = Configuration.getConfiguration(name);
            try (Recording r = new Recording(c)) {
                System.out.println("Starting recording with settings:");
                for (Map.Entry<String, String> setting : c.getSettings().entrySet()) {
                    System.out.println(setting.getKey() + " = " + setting.getValue());
                }
                r.start();
            }
        }
    }

Since:
  9

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Configuration`
  `create(Reader reader)`
  Reads a configuration from a character stream.
  `static Configuration`
  `create(Path path)`
  Reads a configuration from a file.
  `static Configuration`
  `getConfiguration(String name)`
  Returns a predefined configuration.
  `static List<Configuration>`
  `getConfigurations()`
  Returns an immutable list of predefined configurations for this Java Virtual Machine (JVM).
  `String`
  `getContents()`
  Returns a textual representation of the configuration (for example, the contents of a JFC file).
  `String`
  `getDescription()`
  Returns a short sentence that describes the configuration (for example `"Low overhead configuration safe for continuous use in production environments"`)
  `String`
  `getLabel()`
  Returns a human-readable name (for example, `"Continuous" or "Profiling"`}.
  `String`
  `getName()`
  Returns an identifying name (for example, `"default" or "profile")`.
  `String`
  `getProvider()`
  Returns who created the configuration (for example `"OpenJDK"`).
  `Map<String,String>`
  `getSettings()`
  Returns the settings that specify how a recording is configured.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Method Details

  - ### getSettings

    public Map<String,String> getSettings()
    Returns the settings that specify how a recording is configured.

    Modifying the returned `Map` object doesn't change the configuration.

    Returns:
      settings, not `null`

  - ### getName

    public String getName()
    Returns an identifying name (for example, `"default" or "profile")`.
    Returns:
      the name, or `null` if it doesn't exist

  - ### getLabel

    public String getLabel()
    Returns a human-readable name (for example, `"Continuous" or "Profiling"`}.
    Returns:
      the label, or `null` if it doesn't exist

  - ### getDescription

    public String getDescription()
    Returns a short sentence that describes the configuration (for example `"Low overhead configuration safe for continuous use in production environments"`)
    Returns:
      the description, or `null` if it doesn't exist

  - ### getProvider

    public String getProvider()
    Returns who created the configuration (for example `"OpenJDK"`).
    Returns:
      the provider, or `null` if it doesn't exist

  - ### getContents

    public String getContents()
    Returns a textual representation of the configuration (for example, the contents of a JFC file).
    Returns:
      contents, or `null` if it doesn't exist
    See Also:
      - `getContents()`

  - ### create

    public static Configuration create(Path path) throws IOException, ParseException
    Reads a configuration from a file.
    Parameters:
      `path` - the file that contains the configuration, not `null`
    Returns:
      the read `Configuration`, not `null`
    Throws:
      `ParseException` - if the file can't be parsed
      `IOException` - if the file can't be read
    See Also:
      - `File.getPath()`

  - ### create

    public static Configuration create(Reader reader) throws IOException, ParseException
    Reads a configuration from a character stream.
    Parameters:
      `reader` - a `Reader` that provides the configuration contents, not `null`
    Returns:
      a configuration, not `null`
    Throws:
      `IOException` - if an I/O error occurs while trying to read contents from the `Reader`
      `ParseException` - if the file can't be parsed

  - ### getConfiguration

    public static Configuration getConfiguration(String name) throws IOException, ParseException
    Returns a predefined configuration.

    See `getConfigurations()` for available configuration names.

    Parameters:
      `name` - the name of the configuration (for example, `"default"` or `"profile"`)
    Returns:
      a configuration, not `null`
    Throws:
      `IOException` - if a configuration with the given name does not exist, or if an I/O error occurs while reading the configuration file
      `ParseException` - if the configuration file can't be parsed

  - ### getConfigurations

    public static List<Configuration> getConfigurations()
    Returns an immutable list of predefined configurations for this Java Virtual Machine (JVM).
    Returns:
      the list of predefined configurations, not `null`