Top Description Fields Constructors Methods
jdk.jfr

public final Class Configuration

extends Object
Class Inheritance
Imports
java.io.IOException, .Reader, java.nio.file.Files, .Path, java.text.ParseException, java.util.LinkedHashMap, .List, .Map, .Objects, jdk.jfr.internal.JVMSupport, jdk.jfr.internal.jfc.JFC

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(); } } }
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

Field Summary

Modifier and TypeField and Description
private final String
private final String
private final String
private final String
private final String
private final Map<String, String>

Constructor Summary

AccessConstructor and Description
pack-priv
Configuration(String name, String label, String description, String provider, Map<String, String> settings, String contents)

Method Summary

Modifier and TypeMethod and Description
public static Configuration

Returns:

the read Configuration, not null
create
(Path
the file that contains the configuration, not null
path
)

Reads a configuration from a file.

public static Configuration

Returns:

a configuration, not null
create
(Reader
a Reader that provides the configuration contents, not null
reader
)

Reads a configuration from a character stream.

public static Configuration

Returns:

a configuration, not null
getConfiguration
(String
the name of the configuration (for example, "default" or "profile")
name
)

Returns a predefined configuration.

public static List<Configuration>

Returns:

the list of predefined configurations, not null
getConfigurations
()

Returns an immutable list of predefined configurations for this Java Virtual Machine (JVM).

public String

Returns:

contents, or null if it doesn't exist
getContents
()

Returns a textual representation of the configuration (for example, the contents of a JFC file).

public String

Returns:

the description, or null if it doesn't exist
getDescription
()

Returns a short sentence that describes the configuration (for example "Low overhead configuration safe for continuous use in production environments")

public String

Returns:

the label, or null if it doesn't exist
getLabel
()

Returns a human-readable name (for example, "Continuous" or "Profiling"}.

public String

Returns:

the name, or null if it doesn't exist
getName
()

Returns an identifying name (for example, "default" or "profile").

public String

Returns:

the provider, or null if it doesn't exist
getProvider
()

Returns who created the configuration (for example "OpenJDK").

public Map<String, String>

Returns:

settings, not null
getSettings
()

Returns the settings that specifies how a recording is configured.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentsback to summary
private final String contents
descriptionback to summary
private final String description
labelback to summary
private final String label
nameback to summary
private final String name
providerback to summary
private final String provider
settingsback to summary
private final Map<String, String> settings

Constructor Detail

Configurationback to summary
pack-priv Configuration(String name, String label, String description, String provider, Map<String, String> settings, String contents)

Method Detail

createback to summary
public static Configuration create(Path path) throws IOException, ParseException

Reads a configuration from a file.

Parameters
path:Path

the file that contains the configuration, not null

Returns:Configuration

the read Configuration, not null

Exceptions
IOException:
if the file can't be read
ParseException:
if the file can't be parsed
SecurityException:
if a security manager exists and its checkRead method denies read access to the file.
See Also
java.io.File#getPath(), java.lang.SecurityManager#checkRead(java.lang.String)
createback to summary
public static Configuration create(Reader reader) throws IOException, ParseException

Reads a configuration from a character stream.

Parameters
reader:Reader

a Reader that provides the configuration contents, not null

Returns:Configuration

a configuration, not null

Exceptions
IOException:
if an I/O error occurs while trying to read contents from the Reader
ParseException:
if the file can't be parsed
getConfigurationback to summary
public static Configuration getConfiguration(String name) throws IOException, ParseException

Returns a predefined configuration.

See Configuration#getConfigurations() for available configuration names.

Parameters
name:String

the name of the configuration (for example, "default" or "profile")

Returns:Configuration

a configuration, not null

Exceptions
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
getConfigurationsback to summary
public static List<Configuration> getConfigurations()

Returns an immutable list of predefined configurations for this Java Virtual Machine (JVM).

Returns:List<Configuration>

the list of predefined configurations, not null

getContentsback to summary
public String getContents()

Returns a textual representation of the configuration (for example, the contents of a JFC file).

Returns:String

contents, or null if it doesn't exist

See Also
Configuration#getContents()
getDescriptionback to summary
public String getDescription()

Returns a short sentence that describes the configuration (for example "Low overhead configuration safe for continuous use in production environments")

Returns:String

the description, or null if it doesn't exist

getLabelback to summary
public String getLabel()

Returns a human-readable name (for example, "Continuous" or "Profiling"}.

Returns:String

the label, or null if it doesn't exist

getNameback to summary
public String getName()

Returns an identifying name (for example, "default" or "profile").

Returns:String

the name, or null if it doesn't exist

getProviderback to summary
public String getProvider()

Returns who created the configuration (for example "OpenJDK").

Returns:String

the provider, or null if it doesn't exist

getSettingsback to summary
public Map<String, String> getSettings()

Returns the settings that specifies how a recording is configured.

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

Returns:Map<String, String>

settings, not null