Class Configuration
java.lang.Object
jdk.jfr.Configuration
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 TypeMethodDescriptionstatic ConfigurationReads a configuration from a character stream.static ConfigurationReads a configuration from a file.static ConfigurationgetConfiguration(String name) Returns a predefined configuration.static List<Configuration> Returns an immutable list of predefined configurations for this Java Virtual Machine (JVM).Returns a textual representation of the configuration (for example, the contents of a JFC file).Returns a short sentence that describes the configuration (for example"Low overhead configuration safe for continuous use in production environments")getLabel()Returns a human-readable name (for example,"Continuous" or "Profiling"}.getName()Returns an identifying name (for example,"default" or "profile").Returns who created the configuration (for example"OpenJDK").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, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Method Details
-
getSettings
-
getName
Returns an identifying name (for example,"default" or "profile").- Returns:
- the name, or
nullif it doesn't exist
-
getLabel
Returns a human-readable name (for example,"Continuous" or "Profiling"}.- Returns:
- the label, or
nullif 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")- Returns:
- the description, or
nullif it doesn't exist
-
getProvider
Returns who created the configuration (for example"OpenJDK").- Returns:
- the provider, or
nullif it doesn't exist
-
getContents
Returns a textual representation of the configuration (for example, the contents of a JFC file).- Returns:
- contents, or
nullif it doesn't exist - See Also:
-
create
Reads a configuration from a file.- Parameters:
path- the file that contains the configuration, notnull- Returns:
- the read
Configuration, notnull - Throws:
ParseException- if the file can't be parsedIOException- if the file can't be read- See Also:
-
create
Reads a configuration from a character stream.- Parameters:
reader- aReaderthat provides the configuration contents, notnull- Returns:
- a configuration, not
null - Throws:
IOException- if an I/O error occurs while trying to read contents from theReaderParseException- if the file can't be parsed
-
getConfiguration
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 fileParseException- if the configuration file can't be parsed
-
getConfigurations
Returns an immutable list of predefined configurations for this Java Virtual Machine (JVM).- Returns:
- the list of predefined configurations, not
null
-