public final class Configuration extends Object
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();
}
}
}
Modifier and Type | Method | Description |
---|---|---|
static Configuration |
create |
Reads a configuration from a character stream. |
static Configuration |
create |
Reads a configuration from a file. |
static Configuration |
getConfiguration |
Returns a predefined configuration. |
static List |
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 |
getSettings() |
Returns the settings that specifies how a recording is configured. |
public Map<String,String> getSettings()
Modifying the returned Map
object doesn't change the configuration.
null
public String getName()
"default" or "profile")
.null
if it doesn't existpublic String getLabel()
"Continuous" or "Profiling"
}.null
if it doesn't existpublic String getDescription()
"Low
overhead configuration safe for continuous use in production
environments"
)null
if it doesn't existpublic String getProvider()
"OpenJDK"
).null
if it doesn't existpublic String getContents()
null
if it doesn't existpublic static Configuration create(Path path) throws IOException, ParseException
path
- the file that contains the configuration, not null
Configuration
, not null
ParseException
- if the file can't be parsedIOException
- if the file can't be readSecurityException
- if a security manager exists and its checkRead
method denies read access to the file.public static Configuration create(Reader reader) throws IOException, ParseException
reader
- a Reader
that provides the configuration contents, not null
null
IOException
- if an I/O error occurs while trying to read contents from the Reader
ParseException
- if the file can't be parsedpublic static Configuration getConfiguration(String name) throws IOException, ParseException
See getConfigurations()
for available configuration names.
name
- the name of the configuration (for example, "default"
or "profile"
)null
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 parsedpublic static List<Configuration> getConfigurations()
null
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jfr/jdk/jfr/Configuration.html