diff --git a/pom.xml b/pom.xml
index 12e3ee20..fcd2d0b5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,6 +44,15 @@
+
+
+ jmc-libs
+ Adoptium JDK Mission Control Core Libraries
+ https://adoptium.jfrog.io/artifactory/jmc-libs
+ default
+
+
+
github
@@ -63,7 +72,7 @@
11${java.version}${java.version}
- 8.2.0
+ 9.0.03.1.73.13.0
@@ -96,27 +105,37 @@
org.openjdk.jmccommon
- ${jmc.version}
+ ${org.openjdk.jmc.version}org.openjdk.jmcflightrecorder
- ${jmc.version}
+ ${org.openjdk.jmc.version}
+
+
+ org.openjdk.jmc
+ flightrecorder.configuration
+ ${org.openjdk.jmc.version}org.openjdk.jmcflightrecorder.rules
- ${jmc.version}
+ ${org.openjdk.jmc.version}org.openjdk.jmcflightrecorder.rules.jdk
- ${jmc.version}
+ ${org.openjdk.jmc.version}org.openjdk.jmcjdp
- ${jmc.version}
+ ${org.openjdk.jmc.version}
+
+
+ org.openjdk.jmc
+ rjmx.common
+ ${org.openjdk.jmc.version}org.apache.commons
diff --git a/scripts/jmc-diff.sh b/scripts/jmc-diff.sh
deleted file mode 100755
index 28cda5bc..00000000
--- a/scripts/jmc-diff.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/bash
-
-#
-# Copyright The Cryostat Authors
-#
-# The Universal Permissive License (UPL), Version 1.0
-#
-# Subject to the condition set forth below, permission is hereby granted to any
-# person obtaining a copy of this software, associated documentation and/or data
-# (collectively the "Software"), free of charge and under any and all copyright
-# rights in the Software, and any and all patent rights owned or freely
-# licensable by each licensor hereunder covering either (i) the unmodified
-# Software as contributed to or provided by such licensor, or (ii) the Larger
-# Works (as defined below), to deal in both
-#
-# (a) the Software, and
-# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
-# one is included with the Software (each a "Larger Work" to which the Software
-# is contributed by such licensors),
-#
-# without restriction, including without limitation the rights to copy, create
-# derivative works of, display, perform, and distribute the Software and make,
-# use, sell, offer for sale, import, export, have made, and have sold the
-# Software and the Larger Work(s), and to sublicense the foregoing rights on
-# either these or other terms.
-#
-# This license is subject to the following condition:
-# The above copyright notice and either this complete permission notice or at
-# a minimum a reference to the UPL must be included in all copies or
-# substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-# This script compares the differences between a JMC 7 source and the
-# embedded JMC source files within this repo
-if [ $# -ne 1 ]; then
- echo "usage: $0 /path/to/jmc7" >&2
- exit 1
-fi
-
-JMC_DIR=$1
-ROOT_DIR="$(readlink -f "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/..")"
-SUMMARIZE_MISSING="${SUMMARIZE_MISSING:-false}"
-MISSING_FILES=""
-
-diffBundle () {
- local bundle_name="$1"
- local src_dir="$2"
- local exclude_dir="$3"
-
- pushd "${JMC_DIR}/application/${bundle_name}" >/dev/null
- if [ -n "$exclude_dir" ]; then
- local srcFiles=$(find "${src_dir}" -type f -not -path "${exclude_dir}/*")
- else
- local srcFiles=$(find "${src_dir}" -type f)
- fi
-
- local diff_flags="-u"
- if [ "${SUMMARIZE_MISSING}" != true ]; then
- diff_flags="${diff_flags} -N"
- fi
-
- for i in ${srcFiles}; do
- if [ "${SUMMARIZE_MISSING}" = true -a ! -f "${ROOT_DIR}/$i" ]; then
- MISSING_FILES="${MISSING_FILES}\n$i"
- else
- diff ${diff_flags} --label="a/$i" --label="b/$i" "${JMC_DIR}/application/${bundle_name}/$i" "${ROOT_DIR}/$i"
- fi
- done
- popd >/dev/null
-}
-
-diffBundle "org.openjdk.jmc.flightrecorder.configuration" "src/main/java/org/openjdk/jmc/flightrecorder/configuration/"
-diffBundle "org.openjdk.jmc.flightrecorder.controlpanel.ui" "src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui" "src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration"
-diffBundle "org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration" "src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration"
-diffBundle "org.openjdk.jmc.rjmx" "src/main/java/org/openjdk/jmc/rjmx" "src/main/java/org/openjdk/jmc/rjmx/services/jfr"
-diffBundle "org.openjdk.jmc.rjmx.services.jfr" "src/main/java/org/openjdk/jmc/rjmx/services/jfr"
-diffBundle "org.openjdk.jmc.jdp" "src/main/java/org/openjdk/jmc/jdp"
-diffBundle "org.openjdk.jmc.ui.common" "src/main/java/org/openjdk/jmc/ui/common"
-
-if [ "${SUMMARIZE_MISSING}" = true ]; then
- echo -e "\nRemoved files:${MISSING_FILES}"
-fi
diff --git a/scripts/jmc-embed.sh b/scripts/jmc-embed.sh
deleted file mode 100755
index 87edc456..00000000
--- a/scripts/jmc-embed.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/bash
-
-#
-# Copyright The Cryostat Authors
-#
-# The Universal Permissive License (UPL), Version 1.0
-#
-# Subject to the condition set forth below, permission is hereby granted to any
-# person obtaining a copy of this software, associated documentation and/or data
-# (collectively the "Software"), free of charge and under any and all copyright
-# rights in the Software, and any and all patent rights owned or freely
-# licensable by each licensor hereunder covering either (i) the unmodified
-# Software as contributed to or provided by such licensor, or (ii) the Larger
-# Works (as defined below), to deal in both
-#
-# (a) the Software, and
-# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
-# one is included with the Software (each a "Larger Work" to which the Software
-# is contributed by such licensors),
-#
-# without restriction, including without limitation the rights to copy, create
-# derivative works of, display, perform, and distribute the Software and make,
-# use, sell, offer for sale, import, export, have made, and have sold the
-# Software and the Larger Work(s), and to sublicense the foregoing rights on
-# either these or other terms.
-#
-# This license is subject to the following condition:
-# The above copyright notice and either this complete permission notice or at
-# a minimum a reference to the UPL must be included in all copies or
-# substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-# This script copies JMC 7 classes used by Cryostat Core into
-# the src/main/java directory
-if [ $# -ne 1 ]; then
- echo "usage: $0 /path/to/jmc7" >&2
- exit 1
-fi
-
-JMC_DIR=$1
-ROOT_DIR="$(readlink -f "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/..")"
-
-copyBundle () {
- local bundle_name="$1"
- cp -rv "${JMC_DIR}/application/${bundle_name}/src/main/java/org" "${ROOT_DIR}/src/main/java/"
-}
-
-copyResource() {
- local bundle_name="$1"
- local resource_path="$2"
-
- mkdir -p "$(dirname "${ROOT_DIR}/src/main/resources/${resource_path}")"
- cp -rv "${JMC_DIR}/application/${bundle_name}/src/main/resources/${resource_path}" "${ROOT_DIR}/src/main/resources/${resource_path}"
-}
-# src/main/resources/org/openjdk/jmc/rjmx/subscription/internal/mrimetadata.xml
-copyBundle "org.openjdk.jmc.flightrecorder.configuration"
-copyBundle "org.openjdk.jmc.flightrecorder.controlpanel.ui"
-copyBundle "org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration"
-copyBundle "org.openjdk.jmc.rjmx"
-copyBundle "org.openjdk.jmc.rjmx.services.jfr"
-copyBundle "org.openjdk.jmc.jdp"
-copyBundle "org.openjdk.jmc.ui.common"
-
-copyResource "org.openjdk.jmc.flightrecorder.configuration" "org/openjdk/jmc/flightrecorder/configuration/events/jfc_v1.xsd"
-copyResource "org.openjdk.jmc.flightrecorder.configuration" "org/openjdk/jmc/flightrecorder/configuration/events/jfc_v2.xsd"
-copyResource "org.openjdk.jmc.rjmx" "org/openjdk/jmc/rjmx/subscription/internal/mrimetadata.xml"
diff --git a/src/main/java/io/cryostat/core/EventOptionsBuilder.java b/src/main/java/io/cryostat/core/EventOptionsBuilder.java
index 7318c788..40bec48b 100644
--- a/src/main/java/io/cryostat/core/EventOptionsBuilder.java
+++ b/src/main/java/io/cryostat/core/EventOptionsBuilder.java
@@ -27,9 +27,9 @@
import org.openjdk.jmc.common.unit.QuantityConversionException;
import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeID;
-import org.openjdk.jmc.rjmx.ServiceNotAvailableException;
-import org.openjdk.jmc.rjmx.services.jfr.IEventTypeInfo;
-import org.openjdk.jmc.rjmx.services.jfr.internal.FlightRecorderServiceV2;
+import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeInfo;
+import org.openjdk.jmc.rjmx.common.ServiceNotAvailableException;
+import org.openjdk.jmc.rjmx.common.services.jfr.internal.FlightRecorderServiceV2;
import io.cryostat.core.net.JFRConnection;
@@ -96,7 +96,7 @@ public static class EventOptionException extends Exception {
public static class Factory {
public EventOptionsBuilder create(JFRConnection connection)
throws IOException, ServiceNotAvailableException,
- org.openjdk.jmc.rjmx.services.jfr.FlightRecorderException {
+ org.openjdk.jmc.flightrecorder.configuration.FlightRecorderException {
if (!FlightRecorderServiceV2.isAvailable(connection.getHandle())) {
throw new UnsupportedOperationException("Only FlightRecorder V2 is supported");
}
diff --git a/src/main/java/io/cryostat/core/EventOptionsCustomizer.java b/src/main/java/io/cryostat/core/EventOptionsCustomizer.java
index 64021f96..b12f03b8 100644
--- a/src/main/java/io/cryostat/core/EventOptionsCustomizer.java
+++ b/src/main/java/io/cryostat/core/EventOptionsCustomizer.java
@@ -25,7 +25,7 @@
import org.openjdk.jmc.common.unit.QuantityConversionException;
import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeID;
-import org.openjdk.jmc.rjmx.services.jfr.IEventTypeInfo;
+import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeInfo;
import io.cryostat.core.net.JFRConnection;
diff --git a/src/main/java/io/cryostat/core/agent/AgentJMXHelper.java b/src/main/java/io/cryostat/core/agent/AgentJMXHelper.java
index 6515485a..d9f91bc7 100644
--- a/src/main/java/io/cryostat/core/agent/AgentJMXHelper.java
+++ b/src/main/java/io/cryostat/core/agent/AgentJMXHelper.java
@@ -26,7 +26,7 @@
import javax.management.ObjectName;
import javax.management.ReflectionException;
-import org.openjdk.jmc.rjmx.IConnectionHandle;
+import org.openjdk.jmc.rjmx.common.IConnectionHandle;
public class AgentJMXHelper {
diff --git a/src/main/java/io/cryostat/core/jmc/CopyRecordingDescriptor.java b/src/main/java/io/cryostat/core/jmc/CopyRecordingDescriptor.java
index 77c19cda..3191da98 100644
--- a/src/main/java/io/cryostat/core/jmc/CopyRecordingDescriptor.java
+++ b/src/main/java/io/cryostat/core/jmc/CopyRecordingDescriptor.java
@@ -20,7 +20,7 @@
import javax.management.ObjectName;
import org.openjdk.jmc.common.unit.IQuantity;
-import org.openjdk.jmc.rjmx.services.jfr.IRecordingDescriptor;
+import org.openjdk.jmc.flightrecorder.configuration.IRecordingDescriptor;
public class CopyRecordingDescriptor implements IRecordingDescriptor {
private final IRecordingDescriptor original;
diff --git a/src/main/java/io/cryostat/core/jmc/SecurityManager.java b/src/main/java/io/cryostat/core/jmc/SecurityManager.java
index ad15bd76..64b2a2d6 100644
--- a/src/main/java/io/cryostat/core/jmc/SecurityManager.java
+++ b/src/main/java/io/cryostat/core/jmc/SecurityManager.java
@@ -18,10 +18,10 @@
import java.util.Collections;
import java.util.Set;
-import org.openjdk.jmc.ui.common.security.ActionNotGrantedException;
-import org.openjdk.jmc.ui.common.security.FailedToSaveException;
-import org.openjdk.jmc.ui.common.security.ISecurityManager;
-import org.openjdk.jmc.ui.common.security.SecurityException;
+import org.openjdk.jmc.common.security.ActionNotGrantedException;
+import org.openjdk.jmc.common.security.FailedToSaveException;
+import org.openjdk.jmc.common.security.ISecurityManager;
+import org.openjdk.jmc.common.security.SecurityException;
import io.cryostat.core.jmc.internal.Store;
diff --git a/src/main/java/io/cryostat/core/net/CryostatFlightRecorderService.java b/src/main/java/io/cryostat/core/net/CryostatFlightRecorderService.java
index 06cb85a6..25ef2327 100644
--- a/src/main/java/io/cryostat/core/net/CryostatFlightRecorderService.java
+++ b/src/main/java/io/cryostat/core/net/CryostatFlightRecorderService.java
@@ -20,14 +20,14 @@
import org.openjdk.jmc.common.unit.IConstrainedMap;
import org.openjdk.jmc.common.unit.QuantityConversionException;
+import org.openjdk.jmc.flightrecorder.configuration.FlightRecorderException;
+import org.openjdk.jmc.flightrecorder.configuration.IFlightRecorderService;
+import org.openjdk.jmc.flightrecorder.configuration.IRecordingDescriptor;
+import org.openjdk.jmc.flightrecorder.configuration.events.EventConfiguration;
import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
-import org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration.model.xml.XMLModel;
-import org.openjdk.jmc.flightrecorder.controlpanel.ui.model.EventConfiguration;
-import org.openjdk.jmc.rjmx.ConnectionException;
-import org.openjdk.jmc.rjmx.ServiceNotAvailableException;
-import org.openjdk.jmc.rjmx.services.jfr.FlightRecorderException;
-import org.openjdk.jmc.rjmx.services.jfr.IFlightRecorderService;
-import org.openjdk.jmc.rjmx.services.jfr.IRecordingDescriptor;
+import org.openjdk.jmc.flightrecorder.configuration.model.xml.XMLModel;
+import org.openjdk.jmc.rjmx.common.ConnectionException;
+import org.openjdk.jmc.rjmx.common.ServiceNotAvailableException;
import io.cryostat.core.EventOptionsBuilder.EventOptionException;
import io.cryostat.core.EventOptionsBuilder.EventTypeException;
diff --git a/src/main/java/io/cryostat/core/net/JFRConnection.java b/src/main/java/io/cryostat/core/net/JFRConnection.java
index 6b729c2c..9d7b321f 100644
--- a/src/main/java/io/cryostat/core/net/JFRConnection.java
+++ b/src/main/java/io/cryostat/core/net/JFRConnection.java
@@ -22,9 +22,9 @@
import javax.management.ReflectionException;
import javax.management.remote.JMXServiceURL;
-import org.openjdk.jmc.rjmx.ConnectionException;
-import org.openjdk.jmc.rjmx.IConnectionHandle;
-import org.openjdk.jmc.rjmx.ServiceNotAvailableException;
+import org.openjdk.jmc.rjmx.common.ConnectionException;
+import org.openjdk.jmc.rjmx.common.IConnectionHandle;
+import org.openjdk.jmc.rjmx.common.ServiceNotAvailableException;
import io.cryostat.core.JvmIdentifier;
import io.cryostat.core.sys.Clock;
diff --git a/src/main/java/io/cryostat/core/net/JFRConnectionToolkit.java b/src/main/java/io/cryostat/core/net/JFRConnectionToolkit.java
index bf7a2c64..6ce69372 100644
--- a/src/main/java/io/cryostat/core/net/JFRConnectionToolkit.java
+++ b/src/main/java/io/cryostat/core/net/JFRConnectionToolkit.java
@@ -26,9 +26,9 @@
import javax.management.MBeanServerConnection;
import javax.management.remote.JMXServiceURL;
-import org.openjdk.jmc.rjmx.ConnectionDescriptorBuilder;
-import org.openjdk.jmc.rjmx.ConnectionException;
-import org.openjdk.jmc.rjmx.ConnectionToolkit;
+import org.openjdk.jmc.rjmx.common.ConnectionDescriptorBuilder;
+import org.openjdk.jmc.rjmx.common.ConnectionException;
+import org.openjdk.jmc.rjmx.common.ConnectionToolkit;
import io.cryostat.core.sys.Environment;
import io.cryostat.core.sys.FileSystem;
diff --git a/src/main/java/io/cryostat/core/net/JFRJMXConnection.java b/src/main/java/io/cryostat/core/net/JFRJMXConnection.java
index 3283e7ab..ca2d4e8b 100644
--- a/src/main/java/io/cryostat/core/net/JFRJMXConnection.java
+++ b/src/main/java/io/cryostat/core/net/JFRJMXConnection.java
@@ -37,19 +37,24 @@
import javax.management.openmbean.TabularData;
import javax.management.remote.JMXServiceURL;
-import org.openjdk.jmc.rjmx.ConnectionException;
-import org.openjdk.jmc.rjmx.ConnectionToolkit;
-import org.openjdk.jmc.rjmx.IConnectionDescriptor;
-import org.openjdk.jmc.rjmx.IConnectionHandle;
-import org.openjdk.jmc.rjmx.IConnectionListener;
-import org.openjdk.jmc.rjmx.ServiceNotAvailableException;
-import org.openjdk.jmc.rjmx.internal.DefaultConnectionHandle;
-import org.openjdk.jmc.rjmx.internal.RJMXConnection;
-import org.openjdk.jmc.rjmx.internal.ServerDescriptor;
-import org.openjdk.jmc.rjmx.services.jfr.internal.FlightRecorderServiceFactory;
-import org.openjdk.jmc.rjmx.services.jfr.internal.FlightRecorderServiceV2;
-import org.openjdk.jmc.rjmx.subscription.MRI;
-import org.openjdk.jmc.rjmx.subscription.MRI.Type;
+import org.openjdk.jmc.rjmx.common.ConnectionException;
+import org.openjdk.jmc.rjmx.common.ConnectionToolkit;
+import org.openjdk.jmc.rjmx.common.IConnectionDescriptor;
+import org.openjdk.jmc.rjmx.common.IConnectionHandle;
+import org.openjdk.jmc.rjmx.common.IConnectionListener;
+import org.openjdk.jmc.rjmx.common.ServiceNotAvailableException;
+import org.openjdk.jmc.rjmx.common.internal.DefaultConnectionHandle;
+import org.openjdk.jmc.rjmx.common.internal.RJMXConnection;
+import org.openjdk.jmc.rjmx.common.internal.ServerDescriptor;
+import org.openjdk.jmc.rjmx.common.services.internal.AttributeStorageServiceFactory;
+import org.openjdk.jmc.rjmx.common.services.internal.CommercialFeaturesServiceFactory;
+import org.openjdk.jmc.rjmx.common.services.internal.DiagnosticCommandServiceFactory;
+import org.openjdk.jmc.rjmx.common.services.internal.ServiceEntry;
+import org.openjdk.jmc.rjmx.common.services.internal.SubscriptionServiceFactory;
+import org.openjdk.jmc.rjmx.common.services.jfr.internal.FlightRecorderServiceFactory;
+import org.openjdk.jmc.rjmx.common.services.jfr.internal.FlightRecorderServiceV2;
+import org.openjdk.jmc.rjmx.common.subscription.MRI;
+import org.openjdk.jmc.rjmx.common.subscription.MRI.Type;
import io.cryostat.core.JvmIdentifier;
import io.cryostat.core.sys.Clock;
@@ -68,6 +73,7 @@ public class JFRJMXConnection implements JFRConnection {
protected final Environment env;
protected final FlightRecorderServiceFactory serviceFactory;
protected final List closeListeners;
+ protected final List> serviceEntries;
protected RJMXConnection rjmxConnection;
protected IConnectionHandle handle;
protected IConnectionDescriptor connectionDescriptor;
@@ -84,6 +90,33 @@ public class JFRJMXConnection implements JFRConnection {
this.connectionDescriptor = cd;
this.closeListeners = new ArrayList<>(listeners);
this.serviceFactory = new FlightRecorderServiceFactory();
+ this.serviceEntries = new ArrayList<>();
+ initializeServiceEntries();
+ }
+
+ private void initializeServiceEntries() {
+ serviceEntries.add(
+ new ServiceEntry<>(
+ new AttributeStorageServiceFactory(),
+ "Attribute Storage",
+ "Service for storing attribute values"));
+ serviceEntries.add(
+ new ServiceEntry<>(
+ new CommercialFeaturesServiceFactory(),
+ "Commercial Features",
+ "Service for checking and enabling the state of the commercial features"
+ + " in hotspot."));
+ serviceEntries.add(
+ new ServiceEntry<>(
+ new DiagnosticCommandServiceFactory(),
+ "Diagnostic Commands",
+ "Diagnostic Commands"));
+ serviceEntries.add(
+ new ServiceEntry<>(
+ new SubscriptionServiceFactory(),
+ "Subscription Engine",
+ "Service for controlling the client side attribute subscription"
+ + " engine"));
}
JFRJMXConnection(ClientWriter cw, FileSystem fs, Environment env, IConnectionDescriptor cd) {
@@ -307,7 +340,8 @@ public void onConnectionChange(
}
})
.collect(Collectors.toList())
- .toArray(new IConnectionListener[0]));
+ .toArray(new IConnectionListener[0]),
+ serviceEntries);
}
public synchronized void disconnect() {
diff --git a/src/main/java/io/cryostat/core/net/JmxFlightRecorderService.java b/src/main/java/io/cryostat/core/net/JmxFlightRecorderService.java
index 15c08dfe..c4237200 100644
--- a/src/main/java/io/cryostat/core/net/JmxFlightRecorderService.java
+++ b/src/main/java/io/cryostat/core/net/JmxFlightRecorderService.java
@@ -27,15 +27,15 @@
import org.openjdk.jmc.common.unit.IOptionDescriptor;
import org.openjdk.jmc.common.unit.IQuantity;
import org.openjdk.jmc.common.unit.QuantityConversionException;
+import org.openjdk.jmc.flightrecorder.configuration.FlightRecorderException;
+import org.openjdk.jmc.flightrecorder.configuration.IFlightRecorderService;
+import org.openjdk.jmc.flightrecorder.configuration.IRecordingDescriptor;
import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeID;
-import org.openjdk.jmc.rjmx.ConnectionException;
-import org.openjdk.jmc.rjmx.ServiceNotAvailableException;
-import org.openjdk.jmc.rjmx.services.jfr.FlightRecorderException;
-import org.openjdk.jmc.rjmx.services.jfr.IEventTypeInfo;
-import org.openjdk.jmc.rjmx.services.jfr.IFlightRecorderService;
-import org.openjdk.jmc.rjmx.services.jfr.IRecordingDescriptor;
-import org.openjdk.jmc.rjmx.services.jfr.internal.FlightRecorderServiceFactory;
+import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeInfo;
+import org.openjdk.jmc.rjmx.common.ConnectionException;
+import org.openjdk.jmc.rjmx.common.ServiceNotAvailableException;
+import org.openjdk.jmc.rjmx.common.services.jfr.internal.FlightRecorderServiceFactory;
import io.cryostat.core.EventOptionsBuilder;
import io.cryostat.core.EventOptionsBuilder.EventOptionException;
diff --git a/src/main/java/io/cryostat/core/serialization/SerializableEventTypeInfo.java b/src/main/java/io/cryostat/core/serialization/SerializableEventTypeInfo.java
index 514bd279..71fd0b9f 100644
--- a/src/main/java/io/cryostat/core/serialization/SerializableEventTypeInfo.java
+++ b/src/main/java/io/cryostat/core/serialization/SerializableEventTypeInfo.java
@@ -20,7 +20,7 @@
import java.util.Map;
import org.openjdk.jmc.common.unit.IOptionDescriptor;
-import org.openjdk.jmc.rjmx.services.jfr.IEventTypeInfo;
+import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeInfo;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
diff --git a/src/main/java/io/cryostat/core/serialization/SerializableRecordingDescriptor.java b/src/main/java/io/cryostat/core/serialization/SerializableRecordingDescriptor.java
index fa50930d..b7126556 100644
--- a/src/main/java/io/cryostat/core/serialization/SerializableRecordingDescriptor.java
+++ b/src/main/java/io/cryostat/core/serialization/SerializableRecordingDescriptor.java
@@ -22,8 +22,8 @@
import org.openjdk.jmc.common.unit.IQuantity;
import org.openjdk.jmc.common.unit.QuantityConversionException;
import org.openjdk.jmc.common.unit.UnitLookup;
-import org.openjdk.jmc.rjmx.services.jfr.IRecordingDescriptor;
-import org.openjdk.jmc.rjmx.services.jfr.IRecordingDescriptor.RecordingState;
+import org.openjdk.jmc.flightrecorder.configuration.IRecordingDescriptor;
+import org.openjdk.jmc.flightrecorder.configuration.IRecordingDescriptor.RecordingState;
import jdk.jfr.Recording;
import org.apache.commons.lang3.builder.EqualsBuilder;
diff --git a/src/main/java/io/cryostat/core/templates/AbstractTemplateService.java b/src/main/java/io/cryostat/core/templates/AbstractTemplateService.java
index 8fe5d0db..30deb5b9 100644
--- a/src/main/java/io/cryostat/core/templates/AbstractTemplateService.java
+++ b/src/main/java/io/cryostat/core/templates/AbstractTemplateService.java
@@ -19,8 +19,8 @@
import java.util.Objects;
import java.util.stream.Collectors;
-import org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration.model.xml.XMLModel;
-import org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration.model.xml.XMLTagInstance;
+import org.openjdk.jmc.flightrecorder.configuration.model.xml.XMLModel;
+import org.openjdk.jmc.flightrecorder.configuration.model.xml.XMLTagInstance;
import io.cryostat.core.FlightRecorderException;
diff --git a/src/main/java/io/cryostat/core/templates/RemoteTemplateService.java b/src/main/java/io/cryostat/core/templates/RemoteTemplateService.java
index e7271fb6..30371cd7 100644
--- a/src/main/java/io/cryostat/core/templates/RemoteTemplateService.java
+++ b/src/main/java/io/cryostat/core/templates/RemoteTemplateService.java
@@ -23,11 +23,11 @@
import java.util.stream.Collectors;
import org.openjdk.jmc.common.unit.IConstrainedMap;
+import org.openjdk.jmc.flightrecorder.configuration.IFlightRecorderService;
+import org.openjdk.jmc.flightrecorder.configuration.events.EventConfiguration;
import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
-import org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration.model.xml.XMLModel;
-import org.openjdk.jmc.flightrecorder.controlpanel.ui.model.EventConfiguration;
-import org.openjdk.jmc.rjmx.ServiceNotAvailableException;
-import org.openjdk.jmc.rjmx.services.jfr.IFlightRecorderService;
+import org.openjdk.jmc.flightrecorder.configuration.model.xml.XMLModel;
+import org.openjdk.jmc.rjmx.common.ServiceNotAvailableException;
import io.cryostat.core.FlightRecorderException;
import io.cryostat.core.net.JFRConnection;
@@ -84,7 +84,7 @@ public Optional getXml(String templateName, TemplateType type)
return configuration.attr("label").equals(templateName);
})
.findFirst();
- } catch (org.openjdk.jmc.rjmx.services.jfr.FlightRecorderException
+ } catch (org.openjdk.jmc.flightrecorder.configuration.FlightRecorderException
| IOException
| ServiceNotAvailableException e) {
throw new FlightRecorderException("Could not get XML", e);
@@ -137,7 +137,7 @@ protected List getTemplateModels() throws FlightRecorderException {
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
- } catch (org.openjdk.jmc.rjmx.services.jfr.FlightRecorderException
+ } catch (org.openjdk.jmc.flightrecorder.configuration.FlightRecorderException
| IOException
| ServiceNotAvailableException e) {
throw new FlightRecorderException("Could not get template models", e);
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/ConfigurationToolkit.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/ConfigurationToolkit.java
deleted file mode 100644
index 965b2175..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/ConfigurationToolkit.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.openjdk.jmc.common.unit.IConstrainedMap;
-import org.openjdk.jmc.common.unit.IDescribedMap;
-import org.openjdk.jmc.common.unit.IMutableConstrainedMap;
-import org.openjdk.jmc.common.unit.QuantityConversionException;
-import org.openjdk.jmc.common.version.JavaVersion;
-import org.openjdk.jmc.common.version.JavaVersionSupport;
-import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
-import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeID;
-import org.openjdk.jmc.flightrecorder.configuration.events.SchemaVersion;
-import org.openjdk.jmc.flightrecorder.configuration.internal.EventTypeIDV1;
-import org.openjdk.jmc.flightrecorder.configuration.internal.EventTypeIDV2;
-import org.openjdk.jmc.flightrecorder.configuration.internal.KnownEventOptions;
-import org.openjdk.jmc.flightrecorder.configuration.internal.KnownRecordingOptions;
-
-/**
- * Provisional entry point to obtain Flight Recorder meta data.
- */
-public class ConfigurationToolkit {
- private final static Logger LOGGER = Logger.getLogger("org.openjdk.jmc.flightrecorder.configuration"); //$NON-NLS-1$
-
- public static Logger getLogger() {
- return LOGGER;
- }
-
- public static IDescribedMap getRecordingOptions(JavaVersion version) {
- if (version.isGreaterOrEqualThan(JavaVersionSupport.JDK_9)) {
- return KnownRecordingOptions.OPTION_DEFAULTS_V2;
- } else if (version.isGreaterOrEqualThan(JavaVersionSupport.JDK_7_U_4)) {
- return KnownRecordingOptions.OPTION_DEFAULTS_V1;
- }
- return null;
- }
-
- public static IDescribedMap getRecordingOptions(SchemaVersion version) {
- switch (version) {
- case V1:
- return KnownRecordingOptions.OPTION_DEFAULTS_V1;
- case V2:
- return KnownRecordingOptions.OPTION_DEFAULTS_V2;
- default:
- }
- return null;
- }
-
- public static IDescribedMap getEventOptions(SchemaVersion version) {
- switch (version) {
- case V1:
- return KnownEventOptions.OPTION_DEFAULTS_V1;
- case V2:
- return KnownEventOptions.OPTION_DEFAULTS_V2;
- default:
- }
- return null;
- }
-
- public static IEventTypeID createEventTypeID(String producerURI, String eventPath) {
- return new EventTypeIDV1(producerURI, eventPath);
- }
-
- public static IEventTypeID createEventTypeID(String eventName) {
- return new EventTypeIDV2(eventName);
- }
-
- public static IConstrainedMap extractDelta(IConstrainedMap options, IConstrainedMap baseline) {
- IMutableConstrainedMap deltas = options.emptyWithSameConstraints();
- for (K key : options.keySet()) {
- Object value = options.get(key);
- if ((value != null) && !value.equals(baseline.get(key))) {
- try {
- deltas.put(key, value);
- } catch (QuantityConversionException e) {
- // Shouldn't really happen.
- LOGGER.log(Level.FINE, "Couldn't convert when extracting delta.", e); //$NON-NLS-1$
- }
- }
- }
- return deltas;
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/IRecorderConfigurationService.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/IRecorderConfigurationService.java
deleted file mode 100644
index c84f296a..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/IRecorderConfigurationService.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration;
-
-import org.openjdk.jmc.common.unit.IDescribedMap;
-import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
-
-public interface IRecorderConfigurationService {
- /**
- * The version of JDK Flight Recorder this service instance represents. The format is entirely
- * internal and may change at any time.
- */
- String getVersion();
-
- /**
- * Returns the default recording options, with descriptions. These should not change over time,
- * for a particular service instance.
- *
- * @return an immutable {@link IDescribedMap} with descriptions of options and their default
- * values.
- */
- IDescribedMap getDefaultRecordingOptions();
-
- /**
- * Returns the default event options, with descriptions.
- *
- * @return an immutable {@link IDescribedMap} with descriptions of options and their default
- * values.
- */
- IDescribedMap getDefaultEventOptions();
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/OptionInfo.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/OptionInfo.java
deleted file mode 100644
index 768f24e3..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/OptionInfo.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration;
-
-import org.openjdk.jmc.common.unit.IConstraint;
-import org.openjdk.jmc.common.unit.IOptionDescriptor;
-
-public class OptionInfo implements IOptionDescriptor {
- public static final IOptionDescriptor> DISALLOWED_OPTION = new OptionInfo<>(null,
- "Disallowed option", null, null);
-
- private final String label;
- private final String description;
- private final T defaultValue;
- private final IConstraint constraint;
-
- public OptionInfo(String label, String description, IConstraint constraint, T defaultValue) {
- this.label = label;
- this.description = description;
- this.constraint = constraint;
- this.defaultValue = defaultValue;
- }
-
- @Override
- public String getName() {
- return label;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- @Override
- public T getDefault() {
- return defaultValue;
- }
-
- @Override
- public IConstraint getConstraint() {
- return constraint;
- }
-
- @Override
- @SuppressWarnings("nls")
- public String toString() {
- return "OptionInfo [label=" + label + ", default=" + defaultValue + ", constraint=" + constraint + ']';
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/EventOptionID.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/EventOptionID.java
deleted file mode 100644
index 71256e77..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/EventOptionID.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.events;
-
-/**
- * Identifier class needed since, for JFR 1.0, you cannot from a single option or event URI identify
- * where the descriptive event path begins.
- */
-public final class EventOptionID {
- private final IEventTypeID eventTypeID;
- private final String optionKey;
-
- public EventOptionID(IEventTypeID eventTypeID, String optionKey) {
- this.eventTypeID = eventTypeID;
- this.optionKey = optionKey;
- }
-
- public IEventTypeID getEventTypeID() {
- return eventTypeID;
- }
-
- public String getOptionKey() {
- return optionKey;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof EventOptionID) {
- EventOptionID otherID = (EventOptionID) other;
- return eventTypeID.equals(otherID.eventTypeID) && optionKey.equals(otherID.optionKey);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return eventTypeID.hashCode() ^ optionKey.hashCode();
- }
-
- @Override
- public String toString() {
- return eventTypeID.getFullKey(optionKey);
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/IEventConfiguration.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/IEventConfiguration.java
deleted file mode 100644
index 61fb0c65..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/IEventConfiguration.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.events;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.openjdk.jmc.common.unit.IConstrainedMap;
-import org.openjdk.jmc.common.unit.IMutableConstrainedMap;
-import org.openjdk.jmc.flightrecorder.configuration.spi.IConfigurationStorageDelegate;
-
-/**
- * Interface for JDK Flight Recorder configurations. Note that this interface is (and should
- * remain) agnostic as to how the configuration is represented.
- */
-public interface IEventConfiguration {
- String JFC_FILE_EXTENSION = ".jfc"; //$NON-NLS-1$
-
- /**
- * @return the name of this configuration, as shown when selecting among configuration
- * templates.
- */
- String getName();
-
- /**
- * Set the name of this configuration, as shown when selecting among configuration templates.
- *
- * @param name
- */
- void setName(String name);
-
- /**
- * @return the description of this configuration, as shown when selecting among configuration
- * templates.
- */
- String getDescription();
-
- /**
- * Set the description of this configuration, as shown when selecting among configuration
- * templates.
- *
- * @param description
- */
- void setDescription(String description);
-
- /**
- * @return a description of where this configuration is stored, or null if this is unimportant
- * to the user.
- */
- String getLocationInfo();
-
- /**
- * Whether this particular configuration offers some kind of simplified, higher level control
- * over what to include in the recording, compared to setting individual low level options.
- *
- * @return true iff the configuration has some kind of simplified control mechanism.
- */
- boolean hasControlElements();
-
- /**
- * Remove all kinds of simplified, higher level controls over what to include in the recording,
- * compared to setting individual low level options. This is typically called when the
- * configuration is about to be modified by the user at the low level, and higher level controls
- * could interfere with that.
- *
- * @return true iff the configuration had some kind of simplified control mechanism.
- */
- boolean removeControlElements();
-
- /**
- * If this configuration can likely be deleted permanently, that is, beyond the life cycle of
- * this instance and any repositories containing it. Note that returning true here does not
- * guarantee that a {@link #delete()} will succeed, only that it can be attempted.
- *
- * @return
- */
- boolean isDeletable();
-
- /**
- * Attempt to delete this configuration permanently, that is, beyond the life cycle of this
- * instance and any repositories containing it.
- *
- * @return true iff this configuration was deleted permanently.
- */
- boolean delete();
-
- /**
- * If this configuration can likely be saved permanently, that is, beyond the life cycle of this
- * instance and any repositories containing it. This method can be used to enable or disable
- * save options. Note that returning true here does not guarantee that a {@link #save()} will
- * succeed, only that it can be attempted.
- *
- * @return
- */
- boolean isSaveable();
-
- /**
- * Save this configuration permanently, that is, beyond the life cycle of this instance and any
- * repositories containing it.
- *
- * @return true iff this configuration was saved permanently.
- */
- boolean save();
-
- /**
- * If this configuration can be cloned, and it makes sense to do it.
- *
- * @return
- */
- boolean isCloneable();
-
- /**
- * Warning, this creates a clone with the same underlying storage. This might not be what you
- * want.
- *
- * @return a clone using the same storage as this configuration
- * @see #createCloneWithStorage(IConfigurationStorageDelegate)
- */
- IEventConfiguration createClone();
-
- /**
- * Create a clone using the specified underlying storage.
- *
- * @param storageDelegate
- * @return a clone using {@code storageDelegate} as underlying storage.
- */
- IEventConfiguration createCloneWithStorage(IConfigurationStorageDelegate storageDelegate);
-
- /**
- * Create a working copy of this configuration, with no backing storage. The returned
- * configuration will return this configuration from its {@link #getOriginal()} method.
- *
- * @return a new {@link IEventConfiguration}
- */
- IEventConfiguration createWorkingCopy();
-
- /**
- * If this is a working copy configuration, return the original configuration, otherwise return
- * null.
- *
- * @return a {@link IEventConfiguration} or null
- */
- IEventConfiguration getOriginal();
-
- /**
- * Check if the settings held by this configuration is the same as those held by {@code other}.
- * The textual representation doesn't matter, nor does control elements.
- *
- * @param other
- * @return true if the settings are the same, false otherwise
- */
- boolean equalSettings(IEventConfiguration other);
-
- IConstrainedMap getEventOptions(IMutableConstrainedMap options);
-
- /**
- * Get the persistable string for the option specified by {@code optionID}. If the option is
- * unset, {@code null} will be returned.
- *
- * @param optionID
- */
- String getPersistableString(EventOptionID optionID);
-
- /**
- * Set the option specified by {@code optionID} to the given persisted value.
- *
- * @param optionID
- * @param persisted
- */
- void putPersistedString(EventOptionID optionID, String persisted);
-
- /**
- * If this configuration can be exported, and it makes sense to do it.
- *
- * @return
- */
- boolean isExportable();
-
- /**
- * Export this configuration to the given file.
- *
- * @param file
- * the destination file.
- * @throws IOException
- * if there were trouble writing to {@code file}.
- */
- void exportToFile(File file) throws IOException;
-
- /**
- * The schema version for this configuration
- *
- * @return schema version
- */
- SchemaVersion getVersion();
-
- /**
- * Gets the location of the underlying storage delegate, see
- * {@link IConfigurationStorageDelegate#getLocationPath()}.
- *
- * @return a string that represents the file system location of this template, or null.
- */
- String getLocationPath();
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/IEventTypeID.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/IEventTypeID.java
deleted file mode 100644
index 2b9b76d7..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/IEventTypeID.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.events;
-
-/**
- * Abstraction of a persistable identifier for an event type in JFR.
- */
-public interface IEventTypeID {
-
- /**
- * The identifying key of the producer of this event type. This is only relevant for some JFR
- * versions. For all other versions, this is {@code null}. The format of the key is JFR version
- * specific.
- *
- * @return a producer key or {@code null}
- */
- String getProducerKey();
-
- /**
- * The persistable key identifying this event type, within its {@link #getProducerKey()
- * producer}, if applicable. The format of the key is JFR version specific.
- *
- * @return a event type key, never {@code null}
- */
- String getRelativeKey();
-
- /**
- * A string array representing some sort of categorization to be used only when the
- * corresponding {@link IEventTypeInfo} is unavailable. Note that, unlike in
- * {@link IEventTypeInfo#getHierarchicalCategory()}, the last element in the array represents
- * the event type itself.
- *
- * @return
- */
- String[] getFallbackHierarchy();
-
- /**
- * The persistable key uniquely identifying this event type. The format of the key is JFR
- * version specific.
- *
- * @return a qualified event type key, never {@code null}
- */
- String getFullKey();
-
- /**
- * The persistable key uniquely identifying the event option specified by {@code optionKey} in
- * this event type. The format of the key is JFR version specific.
- *
- * @return a qualified event option key, never {@code null}
- */
- String getFullKey(String optionKey);
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/SchemaVersion.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/SchemaVersion.java
deleted file mode 100644
index 946850f1..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/events/SchemaVersion.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.events;
-
-import java.io.InputStream;
-
-import org.openjdk.jmc.common.version.JavaVersion;
-import org.openjdk.jmc.common.version.JavaVersionSupport;
-
-public enum SchemaVersion {
- V1("1.0", "jfc_v1.xsd", "JDK 7/8"), //$NON-NLS-1$ //$NON-NLS-2$
- V2("2.0", "jfc_v2.xsd", "JDK 9+"); //$NON-NLS-1$ //$NON-NLS-2$
-
- public static SchemaVersion fromBeanVersion(String beanVersion) {
- for (SchemaVersion version : values()) {
- if (version.version.equals(beanVersion)) {
- return version;
- }
- }
- return null;
- }
-
- public static SchemaVersion fromJavaVersion(JavaVersion javaVersion) {
- return javaVersion.isGreaterOrEqualThan(JavaVersionSupport.JDK_9) ? V2
- : javaVersion.isGreaterOrEqualThan(JavaVersionSupport.JDK_7_U_4) ? V1 : null;
- }
-
- private final String version;
- private final String xsdFile;
- private final String description;
-
- private SchemaVersion(String version, String xsdFile, String description) {
- this.version = version;
- this.xsdFile = xsdFile;
- this.description = description;
- }
-
- public String attributeValue() {
- return version;
- }
-
- public InputStream createSchemaStream() {
- return SchemaVersion.class.getResourceAsStream(xsdFile);
- }
-
- @Override
- public String toString() {
- return version + " (" + xsdFile + ')'; //$NON-NLS-1$
- }
-
- public String getDescription() {
- return description;
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/CommonConstraints.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/CommonConstraints.java
deleted file mode 100644
index f056dc0a..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/CommonConstraints.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import static org.openjdk.jmc.common.unit.BinaryPrefix.EXBI;
-import static org.openjdk.jmc.common.unit.DecimalPrefix.MICRO;
-import static org.openjdk.jmc.common.unit.DecimalPrefix.MILLI;
-import static org.openjdk.jmc.common.unit.DecimalPrefix.NANO;
-import static org.openjdk.jmc.common.unit.DecimalPrefix.NONE;
-import static org.openjdk.jmc.common.unit.UnitLookup.BYTE;
-import static org.openjdk.jmc.common.unit.UnitLookup.DAY;
-import static org.openjdk.jmc.common.unit.UnitLookup.EPOCH_MS;
-import static org.openjdk.jmc.common.unit.UnitLookup.EPOCH_NS;
-import static org.openjdk.jmc.common.unit.UnitLookup.HOUR;
-import static org.openjdk.jmc.common.unit.UnitLookup.MEMORY;
-import static org.openjdk.jmc.common.unit.UnitLookup.MINUTE;
-import static org.openjdk.jmc.common.unit.UnitLookup.NANOSECOND;
-import static org.openjdk.jmc.common.unit.UnitLookup.SECOND;
-import static org.openjdk.jmc.common.unit.UnitLookup.TIMESPAN;
-import static org.openjdk.jmc.common.unit.UnitLookup.YEAR;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.logging.Level;
-
-import org.openjdk.jmc.common.unit.ComparableConstraint;
-import org.openjdk.jmc.common.unit.CustomUnitSelector;
-import org.openjdk.jmc.common.unit.DecimalPrefix;
-import org.openjdk.jmc.common.unit.DecimalUnitSelector;
-import org.openjdk.jmc.common.unit.IConstraint;
-import org.openjdk.jmc.common.unit.IFormatter;
-import org.openjdk.jmc.common.unit.IQuantity;
-import org.openjdk.jmc.common.unit.ITypedQuantity;
-import org.openjdk.jmc.common.unit.IUnit;
-import org.openjdk.jmc.common.unit.LinearKindOfQuantity.LinearUnitSelector;
-import org.openjdk.jmc.common.unit.LinearUnit;
-import org.openjdk.jmc.common.unit.QuantityConversionException;
-import org.openjdk.jmc.common.unit.UnitLookup;
-import org.openjdk.jmc.common.unit.WrappingPersister;
-import org.openjdk.jmc.flightrecorder.configuration.ConfigurationToolkit;
-
-/**
- * Constraints common for multiple JFR versions.
- */
-public class CommonConstraints {
- public final static IQuantity EVERY_CHUNK_MAGIC_INSTANCE = NANOSECOND.quantity(0);
- public final static IQuantity BEGIN_CHUNK_MAGIC_INSTANCE = NANOSECOND.quantity(0);
- public final static IQuantity END_CHUNK_MAGIC_INSTANCE = NANOSECOND.quantity(0);
- private final static String EVERY_CHUNK = "everyChunk"; //$NON-NLS-1$
- private final static String BEGIN_CHUNK = "beginChunk"; //$NON-NLS-1$
- private final static String END_CHUNK = "endChunk"; //$NON-NLS-1$
-
- /**
- * Constraint that persists and parses duration values compatible with the non-SI-conforming
- * representation that JFR unfortunately uses. However, the output is always SI-conforming.
- */
- private static class TimePersisterBrokenSI extends WrappingPersister {
- private static final LinearUnitSelector UNIT_SELECTOR;
- private static final IQuantity MIN_REPRESENTABLE = NANOSECOND.quantity(1);
-
- static {
- // Error message claims: '1 min' is not a valid timespan. Shoule be numeric value followed by a unit, i.e. 20 ms. Valid units are ns, us, s, m, h and d.
- DecimalPrefix[] prefixes = {NANO, MICRO, MILLI, NONE};
- LinearUnitSelector systemSelector = new DecimalUnitSelector(TIMESPAN, Arrays.asList(prefixes));
- // Omitting MINUTE since JFR cannot handle SI and we do not want to spread non-SI.
- LinearUnit[] units = {HOUR, DAY};
- // Simplest tick set that will pass the checks in CustomUnitSelector. Not actually used.
- SortedSet> ticks = new TreeSet<>(Collections.singleton(HOUR.quantity(1)));
- UNIT_SELECTOR = new CustomUnitSelector(TIMESPAN, systemSelector, Arrays.asList(units),
- new DecimalUnitSelector(TIMESPAN, DAY), ticks);
- }
-
- public TimePersisterBrokenSI() {
- super(TIMESPAN);
- }
-
- @Override
- @SuppressWarnings("nls")
- public String persistableString(IQuantity value) {
- if (MIN_REPRESENTABLE.compareTo(value) > 0) {
- return "0 ns";
- }
- @SuppressWarnings("unchecked")
- ITypedQuantity typedValue = (ITypedQuantity) value;
- LinearUnit unit = UNIT_SELECTOR.getLargestExactUnit(typedValue);
- if (unit == null) {
- unit = UNIT_SELECTOR.getPreferredUnit(typedValue, 1, 1000000000);
- if (unit == null) {
- unit = NANOSECOND;
- }
- }
- // NOTE: We might theoretically get out of range here, but in practice values are constrained in magnitude when this class is used.
- return super.persistableString(unit.quantity(value.clampedLongValueIn(unit)));
- }
-
- @Override
- @SuppressWarnings("nls")
- public IQuantity parsePersisted(String persistedValue) throws QuantityConversionException {
- if (persistedValue.endsWith("m")) {
- persistedValue += "in";
- // FIXME: Log or warn that non-SI-conforming input was received.
- }
- IQuantity value = super.parsePersisted(persistedValue);
- if ((value.getUnit() == SECOND) && (value.longValue() % 60 == 0)) {
- return MINUTE.quantity(value.clampedLongValueIn(MINUTE));
- }
- return value;
- }
- }
-
- private static final class PeriodPersister extends TimePersisterBrokenSI implements IFormatter {
- @Override
- public boolean validate(IQuantity value) {
- if (value == EVERY_CHUNK_MAGIC_INSTANCE) {
- return true;
- }
- return super.validate(value);
- }
-
- @Override
- public String persistableString(IQuantity value) {
- return (value == EVERY_CHUNK_MAGIC_INSTANCE) ? EVERY_CHUNK : super.persistableString(value);
- }
-
- @Override
- public IQuantity parsePersisted(String persistedValue) throws QuantityConversionException {
- return EVERY_CHUNK.equals(persistedValue) ? EVERY_CHUNK_MAGIC_INSTANCE
- : super.parsePersisted(persistedValue);
- }
-
- @Override
- @SuppressWarnings("nls")
- public String interactiveFormat(IQuantity value) {
- return (value == EVERY_CHUNK_MAGIC_INSTANCE) ? "" : super.interactiveFormat(value);
- }
-
- @Override
- public IQuantity parseInteractive(String interactiveValue) throws QuantityConversionException {
- return (interactiveValue.isEmpty()) ? EVERY_CHUNK_MAGIC_INSTANCE : super.parseInteractive(interactiveValue);
- }
-
- @Override
- public String format(IQuantity value) {
- // FIXME: Migrate localized value from configuration GUI.
- return (value == EVERY_CHUNK_MAGIC_INSTANCE)
- ? "Once every chunk" : super.interactiveFormat(value);
- }
- }
-
- private static final class PeriodPersisterV2 extends TimePersisterBrokenSI implements IFormatter {
-
- @Override
- public boolean validate(IQuantity value) {
- if (value == EVERY_CHUNK_MAGIC_INSTANCE || value == BEGIN_CHUNK_MAGIC_INSTANCE
- || value == END_CHUNK_MAGIC_INSTANCE) {
- return true;
- }
- return super.validate(value);
- }
-
- @Override
- public String persistableString(IQuantity value) {
- if (value == EVERY_CHUNK_MAGIC_INSTANCE) {
- return EVERY_CHUNK;
- } else if (value == BEGIN_CHUNK_MAGIC_INSTANCE) {
- return BEGIN_CHUNK;
- } else if (value == END_CHUNK_MAGIC_INSTANCE) {
- return END_CHUNK;
- }
- return super.persistableString(value);
- }
-
- @Override
- public IQuantity parsePersisted(String persistedValue) throws QuantityConversionException {
- if (EVERY_CHUNK.equals(persistedValue)) {
- return EVERY_CHUNK_MAGIC_INSTANCE;
- } else if (BEGIN_CHUNK.equals(persistedValue)) {
- return BEGIN_CHUNK_MAGIC_INSTANCE;
- } else if (END_CHUNK.equals(persistedValue)) {
- return END_CHUNK_MAGIC_INSTANCE;
- }
- return super.parsePersisted(persistedValue);
- }
-
- @Override
- public String interactiveFormat(IQuantity value) {
- if (value == EVERY_CHUNK_MAGIC_INSTANCE) {
- return ""; //$NON-NLS-1$
- }
- return super.interactiveFormat(value);
- }
-
- @Override
- public IQuantity parseInteractive(String interactiveValue) throws QuantityConversionException {
- if (interactiveValue.isEmpty()) {
- return EVERY_CHUNK_MAGIC_INSTANCE;
- }
- return super.parseInteractive(interactiveValue);
- }
-
- @Override
- public String format(IQuantity value) {
- // FIXME: Migrate localized value from configuration GUI.
- if (value == EVERY_CHUNK_MAGIC_INSTANCE) {
- return "Once every chunk";
- } else if (value == BEGIN_CHUNK_MAGIC_INSTANCE) {
- return "Beginning of every chunk";
- } else if (value == END_CHUNK_MAGIC_INSTANCE) {
- return "End of every chunk";
- }
- return super.interactiveFormat(value);
- }
- }
-
- private static class LongInUnitPersister extends WrappingPersister {
- private final IUnit unit;
-
- public LongInUnitPersister(IUnit unit) {
- super(unit.getContentType());
- this.unit = unit;
- }
-
- @Override
- public String persistableString(IQuantity value) {
- return Long.toString(value.clampedLongValueIn(unit));
- }
-
- @Override
- public IQuantity parsePersisted(String persistedValue) throws QuantityConversionException {
- try {
- return unit.quantity(Long.parseLong(persistedValue));
- } catch (NumberFormatException e) {
- throw QuantityConversionException.unparsable(persistedValue, unit.quantity(1234), this);
- }
- }
- }
-
- public final static IConstraint POSITIVE_TIMESPAN = new ComparableConstraint<>(
- new TimePersisterBrokenSI(), SECOND.quantity(0), EPOCH_NS.quantity(Long.MAX_VALUE));
- public final static IConstraint PERIOD_V1 = new ComparableConstraint<>(new PeriodPersister(),
- NANOSECOND.quantity(1), YEAR.quantity(1));
- public final static IConstraint PERIOD_V2 = new ComparableConstraint<>(new PeriodPersisterV2(),
- NANOSECOND.quantity(1), YEAR.quantity(1));
- public final static IConstraint POSITIVE_MEMORY = new ComparableConstraint<>(
- new LongInUnitPersister(BYTE), BYTE.quantity(0), MEMORY.getUnit(EXBI).quantity(4));
- public final static IConstraint POINT_IN_TIME = new ComparableConstraint<>(
- new LongInUnitPersister(EPOCH_MS), EPOCH_MS.quantity(0), EPOCH_MS.quantity(Long.MAX_VALUE));
-
- private static final Map> JFR1_TYPE_TO_CONSTRAINT;
-
- private static final Map> JFR2_TYPE_TO_CONSTRAINT;
- private static final Map, String> CONSTRAINT_TO_JFR2_TYPE;
-
- static {
- JFR1_TYPE_TO_CONSTRAINT = makeJFRv1ConstraintMap();
- JFR2_TYPE_TO_CONSTRAINT = makeJFRv2ConstraintMap();
-
- Map, String> constraintToContentType = new HashMap<>();
- for (Entry> entry : JFR2_TYPE_TO_CONSTRAINT.entrySet()) {
- constraintToContentType.put(entry.getValue(), entry.getKey());
- }
- // Remove constraint used for fallback when no content type was specified, so that this isn't persisted.
- // This may need to be adjusted so that fallbacks can be distinguished if usage changes.
- constraintToContentType.remove(UnitLookup.PLAIN_TEXT.getPersister());
- CONSTRAINT_TO_JFR2_TYPE = constraintToContentType;
- }
-
- @SuppressWarnings("nls")
- private static Map> makeJFRv1ConstraintMap() {
- Map> jfr1types = new HashMap<>();
- // These are the content types known to have been used in JFC files. More might have worked. Unsure if there's any specification.
- jfr1types.put("timespan", POSITIVE_TIMESPAN);
- jfr1types.put("text", UnitLookup.PLAIN_TEXT.getPersister());
- return jfr1types;
- }
-
- @SuppressWarnings("nls")
- private static Map> makeJFRv2ConstraintMap() {
- Map> jfr2types = new HashMap<>();
- final String jfrPkg = "jdk.jfr.";
- jfr2types.put(jfrPkg + "Percentage", UnitLookup.PERCENTAGE);
- jfr2types.put(jfrPkg + "Timespan", POSITIVE_TIMESPAN);
- jfr2types.put(jfrPkg + "Timestamp", POINT_IN_TIME);
- jfr2types.put(jfrPkg + "Period", PERIOD_V2);
- // Format never seen, not sufficiently specified. (Used to be mixed up with PERIOD.)
-// jfr2types.put(jfrPkg + "Frequency", null);
- jfr2types.put(jfrPkg + "Flag", UnitLookup.FLAG.getPersister());
- jfr2types.put(jfrPkg + "MemoryAddress", UnitLookup.ADDRESS);
- jfr2types.put(jfrPkg + "DataAmount", POSITIVE_MEMORY);
- return jfr2types;
- }
-
- public static IConstraint> forContentTypeV1(String typeName) {
- IConstraint> constraint = JFR1_TYPE_TO_CONSTRAINT.get(typeName);
- return (constraint != null) ? constraint : UnitLookup.PLAIN_TEXT.getPersister();
- }
-
- public static String toMatchingContentTypeV2(IConstraint> constraint) {
- return CONSTRAINT_TO_JFR2_TYPE.get(constraint);
- }
-
- public static IConstraint> forContentTypeV2(String typeName, String defaultPersistedString) {
- IConstraint> constraint = JFR2_TYPE_TO_CONSTRAINT.get(typeName);
- if (constraint != null) {
- try {
- constraint.parsePersisted(defaultPersistedString);
- return constraint;
- } catch (QuantityConversionException e) {
- ConfigurationToolkit.getLogger().log(Level.WARNING, e.getMessage(), e);
- // Fall through to PLAIN_TEXT
- }
- } else if ("true".equals(defaultPersistedString) || "false".equals(defaultPersistedString)) { //$NON-NLS-1$ //$NON-NLS-2$
- // Patch for Thread (at least)
- return UnitLookup.FLAG.getPersister();
- } else {
- // FIXME: Only log newly encountered (determined by inserting into other set, preferably).
- ConfigurationToolkit.getLogger().log(Level.WARNING, "Couldn't find constraint for " + typeName); //$NON-NLS-1$
- }
- return UnitLookup.PLAIN_TEXT.getPersister();
- }
-
- public static IConstraint> forContentTypeV2(String typeName) {
- IConstraint> constraint = JFR2_TYPE_TO_CONSTRAINT.get(typeName);
- return (constraint != null) ? constraint : UnitLookup.PLAIN_TEXT.getPersister();
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/DefaultValueMap.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/DefaultValueMap.java
deleted file mode 100644
index 194876ae..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/DefaultValueMap.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.openjdk.jmc.common.unit.IConstraint;
-import org.openjdk.jmc.common.unit.IDescribedMap;
-import org.openjdk.jmc.common.unit.IMutableConstrainedMap;
-import org.openjdk.jmc.common.unit.IOptionDescriptor;
-import org.openjdk.jmc.common.unit.QuantityConversionException;
-
-/**
- * Describable map with defaults values for all known keys, and acceptable optional keys, if any.
- *
- * @param
- */
-public class DefaultValueMap implements IDescribedMap {
- // NOTE: This should not be modifiable.
- private final Map> knownOptions;
- // NOTE: This should ideally be a (JDK 8) Function. May be null.
- private final IMapper> fallbacks;
-
- private static final Logger LOGGER = Logger.getLogger("org.openjdk.jmc.flightrecorder.configuration");
-
- public DefaultValueMap(Map> knownOptions) {
- this(knownOptions, null);
- }
-
- public DefaultValueMap(IMapper> fallbacks) {
- this(Collections.emptyMap(), fallbacks);
- }
-
- public DefaultValueMap(Map> knownOptions,
- IMapper> fallbacks) {
- this.knownOptions = knownOptions;
- this.fallbacks = fallbacks;
- }
-
- @Override
- public IMutableConstrainedMap emptyWithSameConstraints() {
- return new FixedDescriptorMap<>(makeCombinedMapper());
- }
-
- @Override
- public IMutableConstrainedMap mutableCopy() {
- FixedDescriptorMap copy = new FixedDescriptorMap<>(makeCombinedMapper());
- try {
- for (Entry> entry : knownOptions.entrySet()) {
- Object value = entry.getValue().getDefault();
- if (value != null) {
- copy.put(entry.getKey(), value);
- }
- }
- } catch (QuantityConversionException e) {
- throw new RuntimeException("Implementation error", e); //$NON-NLS-1$
- }
- return copy;
- }
-
- protected IMapper> makeCombinedMapper() {
- if (knownOptions.isEmpty()) {
- // FIXME: fallbacks may be null here, but it is unlikely in practice. Should be handled.
- return fallbacks;
- } else if (fallbacks == null) {
- return new IMapper.MapMapper<>(knownOptions);
- } else {
- return new IMapper>() {
- @Override
- public IOptionDescriptor> get(K key) {
- IOptionDescriptor> desc = knownOptions.get(key);
- return (desc != null) ? desc : fallbacks.get(key);
- };
- };
- }
- }
-
- protected IOptionDescriptor> getDescriptor(K key) {
- IOptionDescriptor> desc = knownOptions.get(key);
- return ((desc == null) && (fallbacks != null)) ? fallbacks.get(key) : desc;
- }
-
- @Override
- public IConstraint> getConstraint(K key) {
- IOptionDescriptor> desc = getDescriptor(key);
- return (desc != null) ? desc.getConstraint() : null;
- }
-
- @Override
- public IOptionDescriptor> getDescribable(K key) {
- return getDescriptor(key);
- }
-
- @Override
- public Set keySet() {
- return knownOptions.keySet();
- }
-
- @Override
- public Object get(K key) {
- // NOTE: Only return non-null values for the known keys, for the valueKeySet() contract to hold.
- IOptionDescriptor> desc = knownOptions.get(key);
- return (desc != null) ? desc.getDefault() : null;
- }
-
- @Override
- public String getPersistableString(K key) {
- return getPersistableDefault(getDescriptor(key));
- }
-
- private String getPersistableDefault(IOptionDescriptor desc) {
- if (desc != null) {
- try {
- V value = desc.getDefault();
- return (value == null) ? null : desc.getConstraint().persistableString(value);
- } catch (QuantityConversionException e) {
- LOGGER.log(Level.WARNING, "Problem parsing option default", e); //$NON-NLS-1$
- }
- }
- return null;
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/EventOptionDescriptorMapper.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/EventOptionDescriptorMapper.java
deleted file mode 100644
index 9b8a4257..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/EventOptionDescriptorMapper.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import java.util.Map;
-
-import org.openjdk.jmc.common.unit.IOptionDescriptor;
-import org.openjdk.jmc.flightrecorder.configuration.OptionInfo;
-import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
-import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeID;
-
-/**
- * Mapping function to return an {@link IOptionDescriptor} for all {@link EventOptionID option IDs}
- * formed by a specific class of {@link IEventTypeID event type ID} and a well-known option key.
- */
-public class EventOptionDescriptorMapper implements IMapper> {
- private final Class extends IEventTypeID> typeClass;
- private final Map> map;
- private final boolean allowOther;
-
- public EventOptionDescriptorMapper(Class extends IEventTypeID> typeClass, Map> map,
- boolean allowOther) {
- this.map = map;
- this.typeClass = typeClass;
- this.allowOther = allowOther;
- }
-
- @Override
- public IOptionDescriptor> get(EventOptionID key) {
- if (typeClass.isInstance(key.getEventTypeID())) {
- IOptionDescriptor> desc = map.get(key.getOptionKey());
- return (allowOther || (desc != null)) ? desc : OptionInfo.DISALLOWED_OPTION;
- }
- return OptionInfo.DISALLOWED_OPTION;
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/EventTypeIDV1.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/EventTypeIDV1.java
deleted file mode 100644
index 033c7177..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/EventTypeIDV1.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeID;
-import org.openjdk.jmc.flightrecorder.internal.EventAppearance;
-
-/**
- * Identifier class needed since currently you cannot from a single event URI identify where the
- * descriptive event path begins.
- */
-public final class EventTypeIDV1 implements IEventTypeID {
-
- // FIXME: When usage has settled, revise stored state and convenience methods.
- private final String producerURI;
- private final String eventURI;
- private final String eventPath;
- private String[] cachedFallbackHierarchy;
-
- /**
- * By (accidental?) convention, {@code producerURI} should end in a slash. {@code eventPath}
- * should not begin, nor end, in a slash.
- *
- * @param producerURI
- * @param eventPath
- */
- public EventTypeIDV1(String producerURI, String eventPath) {
- this(producerURI + eventPath, producerURI.length());
- }
-
- public EventTypeIDV1(String eventURI, int producerEndPos) {
- // This ensures that the various strings are consistent (and reuses the same char[], which may be non-optimal).
- this.eventURI = eventURI;
- eventPath = eventURI.substring(producerEndPos);
- producerURI = eventURI.substring(0, producerEndPos);
- }
-
- /**
- * May be null.
- *
- * @return
- */
- @Override
- public String getProducerKey() {
- return producerURI;
- }
-
- @Override
- public String getRelativeKey() {
- return eventPath;
- }
-
- @Override
- public String[] getFallbackHierarchy() {
- if (cachedFallbackHierarchy == null) {
- cachedFallbackHierarchy = EventAppearance.getHumanSegmentArray(eventPath);
- }
- return cachedFallbackHierarchy;
- }
-
- @Override
- public String getFullKey() {
- return eventURI;
- }
-
- @Override
- public String getFullKey(String optionKey) {
- // FIXME: Use slash instead?
- return eventURI + ':' + optionKey;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof EventTypeIDV1) {
- EventTypeIDV1 otherID = (EventTypeIDV1) other;
- return eventURI.equals(otherID.eventURI) && eventPath.equals(otherID.eventPath);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return eventURI.hashCode();
- }
-
- @Override
- public String toString() {
- return eventURI;
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/EventTypeIDV2.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/EventTypeIDV2.java
deleted file mode 100644
index 89a9f86c..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/EventTypeIDV2.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import java.util.regex.Pattern;
-
-import org.openjdk.jmc.flightrecorder.configuration.events.IEventTypeID;
-
-/**
- * Event type identifier class for JFR 2.0 intended to simplify co-existence with JFR 1.0.
- */
-public final class EventTypeIDV2 implements IEventTypeID {
- private static final Pattern PACKAGE_SPLIT_REGEX = Pattern.compile("\\."); //$NON-NLS-1$
-
- private final String eventName;
-
- public EventTypeIDV2(String eventName) {
- this.eventName = eventName;
- }
-
- @Override
- public String getProducerKey() {
- return null;
- }
-
- @Override
- public String getRelativeKey() {
- return eventName;
- }
-
- @Override
- public String[] getFallbackHierarchy() {
- return PACKAGE_SPLIT_REGEX.split(eventName);
- }
-
- @Override
- public String getFullKey() {
- return eventName;
- }
-
- @Override
- public String getFullKey(String optionKey) {
- return eventName + '#' + optionKey;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof EventTypeIDV2) {
- EventTypeIDV2 otherID = (EventTypeIDV2) other;
- return eventName.equals(otherID.eventName);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return eventName.hashCode();
- }
-
- @Override
- public String toString() {
- return eventName;
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/FixedDescriptorMap.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/FixedDescriptorMap.java
deleted file mode 100644
index d8574315..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/FixedDescriptorMap.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.openjdk.jmc.common.unit.IConstraint;
-import org.openjdk.jmc.common.unit.IDescribedMap;
-import org.openjdk.jmc.common.unit.IMutableConstrainedMap;
-import org.openjdk.jmc.common.unit.IOptionDescriptor;
-import org.openjdk.jmc.common.unit.MutableConstrainedMap;
-import org.openjdk.jmc.common.unit.UnitLookup;
-
-/**
- * General mutable {@link IOptionDescriptor} based {@link IDescribedMap} with possibility to add
- * constraints.
- *
- * @param
- */
-// FIXME: Rename to something more accurate.
-public class FixedDescriptorMap extends MutableConstrainedMap implements IDescribedMap {
- private final IMapper> mapper;
- protected final Map> constraints;
-
- public FixedDescriptorMap(IMapper> mapper) {
- this(mapper, new HashMap());
- }
-
- protected FixedDescriptorMap(IMapper> mapper, HashMap values) {
- this(mapper, values, new HashMap>());
- }
-
- protected FixedDescriptorMap(IMapper> mapper, HashMap values,
- HashMap> constraints) {
- super(values);
- this.mapper = mapper;
- this.constraints = constraints;
- }
-
- @Override
- public IMutableConstrainedMap emptyWithSameConstraints() {
- return new FixedDescriptorMap<>(mapper, new HashMap(), new HashMap<>(constraints));
- }
-
- @Override
- public IMutableConstrainedMap mutableCopy() {
- return new FixedDescriptorMap<>(mapper, new HashMap<>(values), new HashMap<>(constraints));
- }
-
- @Override
- public IConstraint> getConstraint(K key) {
- IOptionDescriptor> desc = mapper.get(key);
- return (desc != null) ? desc.getConstraint() : constraints.get(key);
- }
-
- @Override
- protected IConstraint> getSuggestedConstraint(K key) {
- IOptionDescriptor> desc = mapper.get(key);
- return (desc != null) ? null : UnitLookup.PLAIN_TEXT.getPersister();
- }
-
- @Override
- public IOptionDescriptor> getDescribable(K key) {
- return mapper.get(key);
- }
-
- @Override
- protected void addConstraint(K key, IConstraint> constraint) {
- IOptionDescriptor> desc = mapper.get(key);
- if (desc != null) {
- throw new IllegalArgumentException("Key '" + key + "' is expressly prohibited in this map."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- constraints.put(key, constraint);
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/IMapper.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/IMapper.java
deleted file mode 100644
index 9b71cf81..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/IMapper.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import java.util.Map;
-
-/**
- * Simple mapping function, to be replaced with java.util.function.Function in JDK 8.
- *
- * @param
- * key
- * @param
- * value
- */
-public interface IMapper {
- public static class MapMapper implements IMapper {
- private final Map map;
-
- public MapMapper(Map map) {
- this.map = map;
- }
-
- @Override
- public V get(K key) {
- return map.get(key);
- }
- }
-
- V get(K key);
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/KeyTranslatingMap.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/KeyTranslatingMap.java
deleted file mode 100644
index d5f562f7..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/KeyTranslatingMap.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.openjdk.jmc.common.IDescribable;
-import org.openjdk.jmc.common.unit.IConstrainedMap;
-import org.openjdk.jmc.common.unit.IConstraint;
-import org.openjdk.jmc.common.unit.IDescribedMap;
-import org.openjdk.jmc.common.unit.IMutableConstrainedMap;
-import org.openjdk.jmc.common.unit.QuantityConversionException;
-
-/**
- * Abstract base class for {@link IConstrainedMap constrained map} wrappers that can re-map a fixed
- * number of keys into other keys before delegating to the underlying map. All other keys are passed
- * through.
- *
- * @param
- * @param
- */
-public abstract class KeyTranslatingMap> implements IConstrainedMap {
- protected final M delegate;
- private final Map translations;
-
- public KeyTranslatingMap(M delegate, Map translations) {
- this.delegate = delegate;
- this.translations = translations;
- }
-
- protected final K translate(K key) {
- K translation = translations.get(key);
- return (translation != null) ? translation : key;
- }
-
- @Override
- public Set keySet() {
- return delegate.keySet();
- }
-
- @Override
- public Object get(K key) {
- return delegate.get(translate(key));
- }
-
- @Override
- public IConstraint> getConstraint(K key) {
- return delegate.getConstraint(translate(key));
- }
-
- @Override
- public String getPersistableString(K key) {
- return delegate.getPersistableString(translate(key));
- }
-
- @Override
- public IMutableConstrainedMap emptyWithSameConstraints() {
- return new Mutable<>(delegate.emptyWithSameConstraints(), translations);
- }
-
- @Override
- public IMutableConstrainedMap mutableCopy() {
- return new Mutable<>(delegate.mutableCopy(), translations);
- }
-
- public static class Constrained extends KeyTranslatingMap> {
- public Constrained(IConstrainedMap delegate, Map translations) {
- super(delegate, translations);
- }
- }
-
- public static class Described extends KeyTranslatingMap> implements IDescribedMap {
- public Described(IDescribedMap delegate, Map translations) {
- super(delegate, translations);
- }
-
- @Override
- public IDescribable getDescribable(K key) {
- return delegate.getDescribable(translate(key));
- }
- }
-
- public static class Mutable extends KeyTranslatingMap>
- implements IMutableConstrainedMap {
- public Mutable(IMutableConstrainedMap delegate, Map translations) {
- super(delegate, translations);
- }
-
- @Override
- public void put(K key, Object value) throws QuantityConversionException {
- delegate.put(translate(key), value);
- }
-
- @Override
- public void putPersistedString(K key, String persisted) throws QuantityConversionException {
- delegate.putPersistedString(translate(key), persisted);
- }
-
- @Override
- public void put(K key, IConstraint constraint, T value) throws QuantityConversionException {
- delegate.put(translate(key), value);
- }
-
- @Override
- public void putPersistedString(K key, IConstraint constraint, String persisted)
- throws QuantityConversionException {
- delegate.putPersistedString(translate(key), constraint, persisted);
- }
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/KnownEventOptions.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/KnownEventOptions.java
deleted file mode 100644
index c27bc787..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/KnownEventOptions.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import static org.openjdk.jmc.common.unit.UnitLookup.NANOSECOND;
-import static org.openjdk.jmc.flightrecorder.configuration.internal.CommonConstraints.PERIOD_V1;
-import static org.openjdk.jmc.flightrecorder.configuration.internal.CommonConstraints.PERIOD_V2;
-import static org.openjdk.jmc.flightrecorder.configuration.internal.CommonConstraints.POSITIVE_TIMESPAN;
-
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.openjdk.jmc.common.unit.IConstraint;
-import org.openjdk.jmc.common.unit.IDescribedMap;
-import org.openjdk.jmc.common.unit.IOptionDescriptor;
-import org.openjdk.jmc.common.unit.UnitLookup;
-import org.openjdk.jmc.flightrecorder.configuration.OptionInfo;
-import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
-
-public class KnownEventOptions {
- public final static String KEY_THRESHOLD = "threshold"; //$NON-NLS-1$
- public final static String KEY_STACKTRACE = "stackTrace"; //$NON-NLS-1$
- public final static String KEY_PERIOD = "period"; //$NON-NLS-1$
- public final static String KEY_ENABLED = "enabled"; //$NON-NLS-1$
-
- private static final String ENABLED_LABEL = "Enabled";
- private static final String ENABLED_DESC = "Whether or not events of this type will be included.";
- private static final String PERIOD_LABEL = "Period";
- private static final String PERIOD_DESC = "The request period.";
- private static final String STACKTRACE_LABEL = "Stack Trace";
- private static final String STACKTRACE_DESC = "Whether or not to include stack traces in the events.";
- private static final String THRESHOLD_LABEL = "Threshold";
- private static final String THRESHOLD_DESC = "Only include events with at least this duration.";
-
- public final static Map> EVENT_OPTIONS_BY_KEY_V1;
- public final static Map> EVENT_OPTIONS_BY_KEY_V2;
-
- public final static IDescribedMap OPTION_DEFAULTS_V1;
- public final static IDescribedMap OPTION_DEFAULTS_V2;
-
- static {
- Map> eventOptionsV1 = new LinkedHashMap<>();
- // Options identical between JFR V1 and V2
- eventOptionsV1.put(KEY_THRESHOLD, option(KEY_THRESHOLD, POSITIVE_TIMESPAN, NANOSECOND.quantity(20), THRESHOLD_LABEL, THRESHOLD_DESC));
- eventOptionsV1.put(KEY_STACKTRACE, option(KEY_STACKTRACE, UnitLookup.FLAG.getPersister(), Boolean.TRUE, STACKTRACE_LABEL, STACKTRACE_DESC));
- eventOptionsV1.put(KEY_ENABLED, option(KEY_ENABLED, UnitLookup.FLAG.getPersister(), Boolean.TRUE, ENABLED_LABEL, ENABLED_DESC));
-
- // Initialize V2 options from V1 options so far
- Map> eventOptionsV2 = new LinkedHashMap<>(eventOptionsV1);
-
- // Option differing between JFR V1 and V2
- eventOptionsV1.put(KEY_PERIOD, option(KEY_PERIOD, PERIOD_V1, UnitLookup.MILLISECOND.quantity(20), PERIOD_LABEL, PERIOD_DESC));
- eventOptionsV2.put(KEY_PERIOD, option(KEY_PERIOD, PERIOD_V2, UnitLookup.MILLISECOND.quantity(20), PERIOD_LABEL, PERIOD_DESC));
-
- EVENT_OPTIONS_BY_KEY_V1 = Collections.unmodifiableMap(eventOptionsV1);
- EVENT_OPTIONS_BY_KEY_V2 = Collections.unmodifiableMap(eventOptionsV2);
-
- OPTION_DEFAULTS_V1 = new DefaultValueMap<>(
- new EventOptionDescriptorMapper(EventTypeIDV1.class, eventOptionsV1, false));
- OPTION_DEFAULTS_V2 = new DefaultValueMap<>(
- new EventOptionDescriptorMapper(EventTypeIDV2.class, eventOptionsV2, true));
- }
-
- private static OptionInfo option(String optionName, IConstraint constraint, T defaultValue,
- String label, String desc) {
- return new OptionInfo<>(label, desc, constraint, defaultValue);
- }
-
- private KnownEventOptions() {
- throw new AssertionError("Not to be instantiated!"); //$NON-NLS-1$
- }
-
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/KnownRecordingOptions.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/KnownRecordingOptions.java
deleted file mode 100644
index 8ad57387..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/KnownRecordingOptions.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import static org.openjdk.jmc.common.unit.UnitLookup.BYTE;
-import static org.openjdk.jmc.common.unit.UnitLookup.FLAG;
-import static org.openjdk.jmc.common.unit.UnitLookup.PLAIN_TEXT;
-import static org.openjdk.jmc.common.unit.UnitLookup.SECOND;
-import static org.openjdk.jmc.flightrecorder.configuration.internal.CommonConstraints.POINT_IN_TIME;
-import static org.openjdk.jmc.flightrecorder.configuration.internal.CommonConstraints.POSITIVE_MEMORY;
-import static org.openjdk.jmc.flightrecorder.configuration.internal.CommonConstraints.POSITIVE_TIMESPAN;
-import static org.openjdk.jmc.flightrecorder.configuration.recording.RecordingOptionsBuilder.KEY_DESTINATION_COMPRESSED;
-import static org.openjdk.jmc.flightrecorder.configuration.recording.RecordingOptionsBuilder.KEY_DESTINATION_FILE;
-import static org.openjdk.jmc.flightrecorder.configuration.recording.RecordingOptionsBuilder.KEY_DUMP_ON_EXIT;
-import static org.openjdk.jmc.flightrecorder.configuration.recording.RecordingOptionsBuilder.KEY_DURATION;
-import static org.openjdk.jmc.flightrecorder.configuration.recording.RecordingOptionsBuilder.KEY_MAX_AGE;
-import static org.openjdk.jmc.flightrecorder.configuration.recording.RecordingOptionsBuilder.KEY_MAX_SIZE;
-import static org.openjdk.jmc.flightrecorder.configuration.recording.RecordingOptionsBuilder.KEY_NAME;
-import static org.openjdk.jmc.flightrecorder.configuration.recording.RecordingOptionsBuilder.KEY_START_TIME;
-import static org.openjdk.jmc.flightrecorder.configuration.recording.RecordingOptionsBuilder.KEY_TO_DISK;
-
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.openjdk.jmc.common.unit.IConstraint;
-import org.openjdk.jmc.common.unit.IDescribedMap;
-import org.openjdk.jmc.common.unit.IOptionDescriptor;
-import org.openjdk.jmc.common.unit.UnitLookup;
-import org.openjdk.jmc.flightrecorder.configuration.OptionInfo;
-
-public class KnownRecordingOptions {
- public final static Map> DESCRIPTORS_BY_KEY_V1;
- public final static Map> DESCRIPTORS_BY_KEY_V2;
-
- public final static IDescribedMap OPTION_DEFAULTS_V1;
- public final static IDescribedMap OPTION_DEFAULTS_V2;
-
- private final static String KEY_TO_DISK_V2 = "disk"; //$NON-NLS-1$
-
- private static final String RECORDING_NAME_LABEL = "Name";
- private static final String RECORDING_NAME_DESC = "Recording name";
- private static final String TO_DISK_LABEL = "To disk";
- private static final String TO_DISK_DESC = "Record to disk";
- private static final String DURATION_LABEL = "Duration";
- private static final String DURATION_DESC = "Duration of recording";
- private static final String MAXIMUM_SIZE_LABEL = "Max Size";
- private static final String MAXIMUM_SIZE_DESC = "Maximum size of recording";
- private static final String MAXIMUM_AGE_LABEL = "Max Age";
- private static final String MAXIMUM_AGE_DESC = "Maximum age of the events in the recording";
- // Options unique to JFR V1
- private static final String DESTINATION_FILE_LABEL = "File Name";
- private static final String DESTINATION_FILE_DESC = "Target file for resulting recording";
- private static final String START_TIME_LABEL = "Start Time";
- private static final String START_TIME_DESC = "Start time of recording";
- private static final String DESTINATION_COMPRESSED_LABEL = "File Compression";
- private static final String DESTINATION_COMPRESSED_DESC = "Should destination file be compressed";
- // Option unique to JFR V2
- private static final String DUMP_ON_EXIT_LABEL = "Dump on Exit";
- private static final String DUMP_ON_EXIT_DESC = "Dump recording data to disk on JVM exit";
-
-
- static {
- Map> recOptionsV1 = new LinkedHashMap<>();
- // Options common to JFR V1 and V2
- recOptionsV1.put(KEY_NAME, option("RECORDING_NAME", PLAIN_TEXT.getPersister(), //$NON-NLS-1$
- "Recording", RECORDING_NAME_LABEL, RECORDING_NAME_DESC));
- recOptionsV1.put(KEY_DURATION, option("DURATION", POSITIVE_TIMESPAN, SECOND.quantity(30), DURATION_LABEL, DURATION_DESC)); //$NON-NLS-1$
- recOptionsV1.put(KEY_MAX_SIZE, option("MAXIMUM_SIZE", POSITIVE_MEMORY, BYTE.quantity(0), MAXIMUM_SIZE_LABEL, MAXIMUM_SIZE_DESC)); //$NON-NLS-1$
- recOptionsV1.put(KEY_MAX_AGE, option("MAXIMUM_AGE", POSITIVE_TIMESPAN, SECOND.quantity(0), MAXIMUM_AGE_LABEL, MAXIMUM_AGE_DESC)); //$NON-NLS-1$
-
- // Initialize V2 options from V1 options so far
- Map> recOptionsV2 = new LinkedHashMap<>(recOptionsV1);
-
- // Options unique to JFR V1
- recOptionsV1.put(KEY_DESTINATION_FILE,
- option("DESTINATION_FILE", UnitLookup.PLAIN_TEXT.getPersister(), "recording.jfr", DESTINATION_FILE_LABEL, DESTINATION_FILE_DESC)); //$NON-NLS-1$ //$NON-NLS-2$
- recOptionsV1.put(KEY_START_TIME, option("START_TIME", POINT_IN_TIME, null, START_TIME_LABEL, START_TIME_DESC)); //$NON-NLS-1$
- recOptionsV1.put(KEY_DESTINATION_COMPRESSED,
- option("DESTINATION_COMPRESSED", FLAG.getPersister(), Boolean.FALSE, DESTINATION_COMPRESSED_LABEL, DESTINATION_COMPRESSED_DESC)); //$NON-NLS-1$
- // Option renamed from JFR V1 to V2
- OptionInfo diskOption = option("TO_DISK", FLAG.getPersister(), Boolean.FALSE, TO_DISK_LABEL, TO_DISK_DESC); //$NON-NLS-1$
- recOptionsV1.put(KEY_TO_DISK, diskOption);
- recOptionsV2.put(KEY_TO_DISK_V2, diskOption);
-
- // Option unique to JFR V2
- recOptionsV2.put(KEY_DUMP_ON_EXIT, option("DUMP_ON_EXIT", FLAG.getPersister(), Boolean.FALSE, DUMP_ON_EXIT_LABEL, DUMP_ON_EXIT_DESC)); //$NON-NLS-1$
-
- DESCRIPTORS_BY_KEY_V1 = Collections.unmodifiableMap(recOptionsV1);
- DESCRIPTORS_BY_KEY_V2 = Collections.unmodifiableMap(recOptionsV2);
-
- OPTION_DEFAULTS_V1 = new DefaultValueMap<>(recOptionsV1);
- OPTION_DEFAULTS_V2 = new KeyTranslatingMap.Described<>(new DefaultValueMap<>(recOptionsV2),
- Collections.singletonMap(KEY_TO_DISK, KEY_TO_DISK_V2));
- }
-
- private static OptionInfo option(String optionName, IConstraint constraint, T defaultValue,
- String label, String desc) {
- return new OptionInfo<>(label, desc, constraint, defaultValue);
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/ValidationException.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/ValidationException.java
deleted file mode 100644
index a9d68bfd..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/ValidationException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-public class ValidationException extends IllegalArgumentException {
-
- private static final long serialVersionUID = 1L;
- private final String localizedMessage;
-
- public ValidationException(String message, String localizedMessage) {
- super(message);
- this.localizedMessage = localizedMessage;
- }
-
- @Override
- public String getLocalizedMessage() {
- return localizedMessage;
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/ValidationToolkit.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/ValidationToolkit.java
deleted file mode 100644
index c7230f19..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/internal/ValidationToolkit.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.internal;
-
-import org.openjdk.jmc.common.unit.IConstrainedMap;
-import org.openjdk.jmc.common.unit.IConstraint;
-import org.openjdk.jmc.common.unit.QuantityConversionException;
-
-/**
- * Helpers for validating entire settings maps.
- */
-public final class ValidationToolkit {
-
- /**
- * Will validate the entire map and collect all validation problems in a big validation
- * exception. If there are no errors, no exception will be thrown
- *
- * @param options
- * @throws ValidationException
- */
- public static void validate(IConstrainedMap options) throws ValidationException {
- StringBuilder messageBuilder = new StringBuilder();
- StringBuilder localizedMessageBuilder = new StringBuilder();
- boolean caught = false;
- try {
- for (K key : options.keySet()) {
- Object value = options.get(key);
- if (value != null) {
- validate(options.getConstraint(key), value);
- }
- }
- } catch (QuantityConversionException e) {
- caught = true;
- messageBuilder.append(e.getMessage());
- messageBuilder.append(System.getProperty("line.separator")); //$NON-NLS-1$
- localizedMessageBuilder.append(e.getLocalizedMessage());
- localizedMessageBuilder.append(System.getProperty("line.separator")); //$NON-NLS-1$
- } catch (IllegalArgumentException e) {
- caught = true;
- messageBuilder.append(e.getMessage());
- messageBuilder.append(System.getProperty("line.separator")); //$NON-NLS-1$
- localizedMessageBuilder.append(e.getLocalizedMessage());
- localizedMessageBuilder.append(System.getProperty("line.separator")); //$NON-NLS-1$
- }
- if (caught) {
- throw new ValidationException(messageBuilder.toString(), localizedMessageBuilder.toString());
- }
- }
-
- @SuppressWarnings("unchecked")
- private static void validate(IConstraint constraint, Object value) throws QuantityConversionException {
- constraint.validate((T) value);
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/recording/RecordingOptionsBuilder.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/recording/RecordingOptionsBuilder.java
deleted file mode 100644
index 26ee6bf3..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/recording/RecordingOptionsBuilder.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.recording;
-
-import java.util.Date;
-import java.util.Properties;
-
-import org.openjdk.jmc.common.unit.IConstrainedMap;
-import org.openjdk.jmc.common.unit.IMutableConstrainedMap;
-import org.openjdk.jmc.common.unit.IQuantity;
-import org.openjdk.jmc.common.unit.QuantityConversionException;
-import org.openjdk.jmc.common.unit.UnitLookup;
-import org.openjdk.jmc.flightrecorder.configuration.IRecorderConfigurationService;
-import org.openjdk.jmc.flightrecorder.configuration.internal.ValidationToolkit;
-
-/**
- * Builder to help build recording options. These are typically the options relevant to the
- * recording other than the event type options, such as the duration or when to start the recording.
- */
-public class RecordingOptionsBuilder {
- public final static String KEY_NAME = "name"; //$NON-NLS-1$
- /** The requested duration of a recording */
- public final static String KEY_DURATION = "duration"; //$NON-NLS-1$
- public final static String KEY_DESTINATION_FILE = "destinationFile"; //$NON-NLS-1$
- public final static String KEY_DESTINATION_COMPRESSED = "destinationCompressed"; //$NON-NLS-1$
- public final static String KEY_START_TIME = "startTime"; //$NON-NLS-1$
- public final static String KEY_MAX_SIZE = "maxSize"; //$NON-NLS-1$
- public final static String KEY_MAX_AGE = "maxAge"; //$NON-NLS-1$
- public final static String KEY_TO_DISK = "toDisk"; //$NON-NLS-1$
- public final static String KEY_DUMP_ON_EXIT = "dumpOnExit"; //$NON-NLS-1$
- private final static String DEFAULT_NAME = "Unnamed Recording"; //$NON-NLS-1$
- private final IMutableConstrainedMap map;
-
- public RecordingOptionsBuilder(IRecorderConfigurationService service) throws QuantityConversionException {
- this(service.getDefaultRecordingOptions().emptyWithSameConstraints());
- }
-
- public RecordingOptionsBuilder(IMutableConstrainedMap map) throws QuantityConversionException {
- this.map = map;
- name(DEFAULT_NAME);
- }
-
- public RecordingOptionsBuilder duration(long duration) throws QuantityConversionException {
- return duration(UnitLookup.MILLISECOND.quantity(duration));
- }
-
- public RecordingOptionsBuilder duration(IQuantity duration) throws QuantityConversionException {
- map.put(KEY_DURATION, duration);
- return this;
- }
-
- public RecordingOptionsBuilder destinationFile(String fileName) throws QuantityConversionException {
- map.put(KEY_DESTINATION_FILE, fileName);
- return this;
- }
-
- public RecordingOptionsBuilder destinationCompressed(boolean compress) throws QuantityConversionException {
- map.put(KEY_DESTINATION_COMPRESSED, Boolean.valueOf(compress));
- return this;
- }
-
- public RecordingOptionsBuilder startTime(Date startTime) throws QuantityConversionException {
- return startTime(UnitLookup.fromDate(startTime));
- }
-
- public RecordingOptionsBuilder startTime(IQuantity startTime) throws QuantityConversionException {
- map.put(KEY_START_TIME, startTime);
- return this;
- }
-
- public RecordingOptionsBuilder maxSize(long maxSize) throws QuantityConversionException {
- return maxSize(UnitLookup.BYTE.quantity(maxSize));
- }
-
- public RecordingOptionsBuilder maxSize(IQuantity maxSize) throws QuantityConversionException {
- map.put(KEY_MAX_SIZE, maxSize);
- return this;
- }
-
- public RecordingOptionsBuilder maxAge(long maxAge) throws QuantityConversionException {
- return maxAge(UnitLookup.SECOND.quantity(maxAge));
- }
-
- public RecordingOptionsBuilder maxAge(IQuantity maxAge) throws QuantityConversionException {
- map.put(KEY_MAX_AGE, maxAge);
- return this;
- }
-
- public RecordingOptionsBuilder name(String name) throws QuantityConversionException {
- map.put(KEY_NAME, name);
- return this;
- }
-
- public RecordingOptionsBuilder toDisk(boolean toDisk) throws QuantityConversionException {
- map.put(KEY_TO_DISK, Boolean.valueOf(toDisk));
- return this;
- }
-
- /**
- * Will initialize the builder from a properties collection. Typing of individual content will
- * be attempted.
- */
- public RecordingOptionsBuilder fromProperties(Properties props) throws QuantityConversionException {
- for (Object element : props.keySet()) {
- String key = (String) element;
- addByKey(key, props.getProperty(key));
- }
- return this;
- }
-
- public RecordingOptionsBuilder addByKey(String key, String property) throws QuantityConversionException {
- map.putPersistedString(key, property);
- return this;
- }
-
- public IConstrainedMap build() throws QuantityConversionException {
- ValidationToolkit.validate(map);
- return map;
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/spi/IConfigurationStorageDelegate.java b/src/main/java/org/openjdk/jmc/flightrecorder/configuration/spi/IConfigurationStorageDelegate.java
deleted file mode 100644
index b9eb2670..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/configuration/spi/IConfigurationStorageDelegate.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.configuration.spi;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Storage delegate for storing text based configuration files. It can be thought of as a fancy URL
- * wrapper.
- */
-public interface IConfigurationStorageDelegate {
- /**
- * The only currently supported character encoding.
- */
- final static String CHARSET_UTF8 = "UTF-8"; //$NON-NLS-1$
-
- /**
- * @return an input stream or null if the underlying storage does not yet have any contents.
- */
- InputStream getContents();
-
- /**
- * If the underlying storage can be saved to. This method can be used to enable or disable save
- * options. Also optionally to avoid having to generate the content for {@link #save(String)},
- * when it won't be used.
- *
- * @return
- */
- boolean isSaveable();
-
- /**
- * Save the given content string to the underlying storage, replacing previous content. The
- * character encoding is currently forced to be {@value #CHARSET_UTF8}, as specified by
- * {@link #CHARSET_UTF8}, which is important for XML stating the encoding.
- *
- * NOTE: Passing the contents as a String are fine for small files that are seldom written to.
- * Should this method be used more often or with larger files, a callback with methods for
- * writing to a output stream and for providing an input stream (for IResource destinations)
- * could be passed instead.
- *
- * @param fileContent
- * @return true iff the save operation succeded.
- * @throws IOException
- * if some problem occurred while writing to the underlying storage. The contents
- * might have been partially written.
- */
- boolean save(String fileContent) throws IOException;
-
- /**
- * If the underlying storage can likely be deleted permanently. Note that returning true here
- * does not guarantee that a {@link #delete()} will succeed, only that it can be attempted.
- *
- * @return
- */
- boolean isDeletable();
-
- /**
- * Attempt to delete the underlying storage. If successful, the storage delegate should no
- * longer be used, which might be enforced in the future.
- *
- * @return true iff the underlying storage was deleted.
- */
- boolean delete();
-
- /**
- * Get additional information on the underlying storage, if available.
- *
- * @return a descriptive string which the name of the template can be augmented with, or null.
- */
- String getLocationInfo();
-
- /**
- * Get information on the file system location for the underlying storage, if available.
- *
- * @return a string that represents the file system location of this template, or null.
- */
- String getLocationPath();
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/ControlPanel.java b/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/ControlPanel.java
deleted file mode 100644
index 46b43767..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/ControlPanel.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.controlpanel.ui;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public class ControlPanel {
-
- public static ControlPanel getDefault() {
- return new ControlPanel();
- }
-
- public Logger getLogger() {
- Logger logger = Logger.getGlobal();
- logger.setLevel(Level.ALL);
- return logger;
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration/model/xml/IXMLValidator.java b/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration/model/xml/IXMLValidator.java
deleted file mode 100644
index 91b70467..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration/model/xml/IXMLValidator.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration.model.xml;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Stateless validator of {@link XMLModel}s. Preliminary interface until generic XML validation has
- * been separated from schema specifics. Currently also provides the starting point for the XML
- * grammar.
- */
-interface IXMLValidator {
- /**
- * Validate all aspects of the given model.
- *
- * @param model
- * @return
- */
- List validate(XMLModel model);
-
- /**
- * The expected root element type for models this validator validates.
- *
- * @return an XML element type
- */
- XMLTag getRootElementType();
-
- /**
- * A set of {@link XMLTag}s that should be output on one line to make the XML more readable.
- * (This may seem out of place in the validator. It was put here mostly because it was simplest,
- * but it was also thought that it might be useful when outputting validation problems.)
- *
- * @return
- */
- Set getElementsTooKeepOnOneLine();
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration/model/xml/JFCGrammar.java b/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration/model/xml/JFCGrammar.java
deleted file mode 100644
index bf0b4708..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration/model/xml/JFCGrammar.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration.model.xml;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Describes the XML grammar of a Flight Recorder Configuration. This should match with the XML
- * Schema {@code jfc_.xsd}, to the extent that the grammar can be expressed in both.
- */
-@SuppressWarnings("nls")
-public final class JFCGrammar {
- /**
- * XML elements that should be kept on one line when outputting the {@link XMLModel} as text.
- */
- public static final Set ONE_LINE_ELEMENTS;
-
- public static final String[] DATA_TYPE = {"int", "long", "string", "boolean"};
- public static final String FLAG_CONTENT_TYPE = "flag";
- public static final String TIMESPAN_CONTENT_TYPE = "timespan";
- public static final String[] CONTENT_TYPE = {FLAG_CONTENT_TYPE, TIMESPAN_CONTENT_TYPE};
- public static final String[] OPERATORS = {"equal"};
-
- public static final XMLAttribute ATTRIBUTE_LABEL_MANDATORY = new XMLAttribute("label", true, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_LABEL = new XMLAttribute("label", false, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_DESCRIPTION = new XMLAttribute("description", false, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_NAME = new XMLAttribute("name", true, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_NAME_DEFINITION = new XMLAttribute("name", true, XMLNodeType.DEFINITION);
-
- public static final XMLAttribute ATTRIBUTE_DEFAULT = new XMLAttribute("default", true, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_VALUE = new XMLAttribute("value", false, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_TRUE = new XMLAttribute("true", false, XMLNodeType.TEXT, "true");
- // NOTE: Do not provide a default value for false, since that would prevent multiple conditions for the same variable from working.
- // Compare with the else attribute in Apache Ant's condition task.
- public static final XMLAttribute ATTRIBUTE_FALSE = new XMLAttribute("false", false, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_PATH = new XMLAttribute("path", true, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_VERSION = new XMLAttribute("version", true, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_PROVIDER = new XMLAttribute("provider", false, XMLNodeType.TEXT);
-
- public static final XMLAttribute ATTRIBUTE_NAME_REFERENCE = new XMLAttribute("name", false, XMLNodeType.REFERENCE);
- public static final XMLAttribute ATTRIBUTE_CONTROL_REFERENCE = new XMLAttribute("control", false,
- XMLNodeType.REFERENCE);
- public static final XMLAttribute ATTRIBUTE_OPERATOR = new XMLAttribute("operator", true, XMLNodeType.TEXT,
- OPERATORS);
- public static final XMLAttribute ATTRIBUTE_URI = new XMLAttribute("uri", true, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_CONTENT_TYPE = new XMLAttribute("contentType", false, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_TYPE = new XMLAttribute("type", true, XMLNodeType.TEXT, DATA_TYPE);
- public static final XMLAttribute ATTRIBUTE_MINIMUM = new XMLAttribute("minimum", false, XMLNodeType.TEXT);
- public static final XMLAttribute ATTRIBUTE_MAXIMUM = new XMLAttribute("maximum", false, XMLNodeType.TEXT);
-
- public static final XMLTag ROOT = new XMLTag("root");
- public static final XMLTag TAG_CONFIGURATION_V1 = new XMLTag.Predicated("configuration", ATTRIBUTE_VERSION, "1.0");
- public static final XMLTag TAG_CONFIGURATION_V2 = new XMLTag("configuration");
- public static final XMLTag TAG_PRODUCER = new XMLTag("producer");
- public static final XMLTag TAG_CONTROL = new XMLTag("control");
- public static final XMLTag TAG_SELECTION = new XMLTag("selection");
- public static final XMLTag TAG_OPTION = new XMLTag("option", XMLNodeType.ELEMENT_WITH_CONTENT);
- public static final XMLTag TAG_FLAG = new XMLTag("flag", XMLNodeType.ELEMENT_WITH_CONTENT);
- public static final XMLTag TAG_TEXT = new XMLTag("text", XMLNodeType.ELEMENT_WITH_CONTENT);;
- public static final XMLTag TAG_VARIABLE = new XMLTag("variable", XMLNodeType.ELEMENT_WITH_CONTENT);
- public static final XMLTag TAG_CONDITION = new XMLTag("condition");
- public static final XMLTag TAG_AND = new XMLTag("and", XMLNodeType.ELEMENT_WITH_AT_LEAST_ONE_CHILD);
- public static final XMLTag TAG_OR = new XMLTag("or", XMLNodeType.ELEMENT_WITH_AT_LEAST_ONE_CHILD);
- public static final XMLTag TAG_NOT = new XMLTag("not", XMLNodeType.ELEMENT_WITH_AT_LEAST_ONE_CHILD);
- public static final XMLTag TAG_TEST = new XMLTag("test");
- public static final XMLTag TAG_EVENTTYPE_V1 = new XMLTag("event");
- public static final XMLTag TAG_EVENTTYPE_V2 = new XMLTag("event");
- public static final XMLTag TAG_SETTING = new XMLTag("setting", XMLNodeType.ELEMENT_WITH_CONTENT);
- public static final XMLTag TAG_CATEGORY = new XMLTag("category");
-
- /*
- * Currently used values for the "name" attribute of elements. With the exception of
- * "enabled", these shouldn't really be treated specially anywhere, since more will be added in
- * "JFR 2.0". However, since some currently are special treated, we should at least have
- * constants for them, so their usage can be tracked.
- *
- * FIXME: These should probably not be defined in multiple places.
- *
- * But since they were only defined in the RJMX project, which is utterly wrong (in
- * org.openjdk.jmc.rjmx.services.flr.internal.RecordingSettingsToolkit), they are temporarily
- * defined here.
- */
- public static final String SETTING_ENABLED = "enabled";
- public static final String SETTING_STACKTRACE = "stackTrace";
- public static final String SETTING_THRESHOLD = "threshold";
- public static final String SETTING_PERIOD = "period";
-
- public static final String PERIOD_EVERY_CHUNK = "everyChunk";
-
- static {
- // Wire it up!
- ROOT.add(TAG_CONFIGURATION_V1, TAG_CONFIGURATION_V2);
-
- TAG_CONFIGURATION_V1.add(TAG_PRODUCER, ATTRIBUTE_VERSION, ATTRIBUTE_NAME, ATTRIBUTE_DESCRIPTION,
- ATTRIBUTE_PROVIDER);
-
- TAG_PRODUCER.add(TAG_CONTROL, TAG_SETTING, TAG_EVENTTYPE_V1, ATTRIBUTE_URI, ATTRIBUTE_LABEL,
- ATTRIBUTE_DESCRIPTION);
-
- TAG_EVENTTYPE_V1.add(TAG_SETTING, ATTRIBUTE_PATH, ATTRIBUTE_LABEL, ATTRIBUTE_DESCRIPTION);
-
- TAG_CONFIGURATION_V2.add(TAG_CONTROL, TAG_CATEGORY, TAG_EVENTTYPE_V2, ATTRIBUTE_VERSION,
- ATTRIBUTE_LABEL_MANDATORY, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_PROVIDER);
-
- TAG_CATEGORY.add(ATTRIBUTE_LABEL_MANDATORY, TAG_CATEGORY, TAG_EVENTTYPE_V2);
-
- TAG_EVENTTYPE_V2.add(TAG_SETTING, ATTRIBUTE_NAME, ATTRIBUTE_LABEL, ATTRIBUTE_DESCRIPTION);
-
- TAG_CONTROL.add(TAG_FLAG, TAG_TEXT, TAG_SELECTION, TAG_VARIABLE, TAG_CONDITION);
-
- TAG_SELECTION.add(TAG_OPTION, ATTRIBUTE_NAME_DEFINITION, ATTRIBUTE_DEFAULT, ATTRIBUTE_LABEL_MANDATORY,
- ATTRIBUTE_DESCRIPTION);
-
- TAG_OPTION.add(ATTRIBUTE_LABEL_MANDATORY, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_NAME);
-
- TAG_TEXT.add(ATTRIBUTE_NAME_DEFINITION, ATTRIBUTE_LABEL_MANDATORY, ATTRIBUTE_DESCRIPTION,
- ATTRIBUTE_CONTENT_TYPE, ATTRIBUTE_MINIMUM, ATTRIBUTE_MAXIMUM);
-
- TAG_VARIABLE.add(ATTRIBUTE_NAME_DEFINITION);
-
- TAG_CONDITION.add(TAG_OR, TAG_AND, TAG_NOT, TAG_TEST, ATTRIBUTE_NAME_DEFINITION, ATTRIBUTE_TRUE,
- ATTRIBUTE_FALSE);
-
- TAG_TEST.add(ATTRIBUTE_NAME_REFERENCE, ATTRIBUTE_CONTENT_TYPE, ATTRIBUTE_OPERATOR, ATTRIBUTE_VALUE);
-
- TAG_OR.add(TAG_AND, TAG_NOT, TAG_TEST, TAG_OR);
-
- TAG_NOT.add(TAG_OR, TAG_AND, TAG_TEST, TAG_NOT);
-
- TAG_AND.add(TAG_OR, TAG_NOT, TAG_TEST, TAG_AND);
-
- TAG_FLAG.add(ATTRIBUTE_NAME_DEFINITION, ATTRIBUTE_LABEL_MANDATORY, ATTRIBUTE_DESCRIPTION);
-
- TAG_SETTING.add(ATTRIBUTE_NAME, ATTRIBUTE_CONTROL_REFERENCE, ATTRIBUTE_LABEL, ATTRIBUTE_DESCRIPTION,
- ATTRIBUTE_CONTENT_TYPE);
-
- {
- Set oneLineElements = new HashSet<>();
- oneLineElements.add(TAG_SETTING);
- oneLineElements.add(TAG_OPTION);
- oneLineElements.add(TAG_NOT);
- oneLineElements.add(TAG_AND);
- oneLineElements.add(TAG_OR);
- oneLineElements.add(TAG_TEST);
- ONE_LINE_ELEMENTS = Collections.unmodifiableSet(oneLineElements);
- }
- }
-}
diff --git a/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration/model/xml/JFCXMLValidator.java b/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration/model/xml/JFCXMLValidator.java
deleted file mode 100644
index 988adfbf..00000000
--- a/src/main/java/org/openjdk/jmc/flightrecorder/controlpanel/ui/configuration/model/xml/JFCXMLValidator.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * The contents of this file are subject to the terms of either the Universal Permissive License
- * v 1.0 as shown at http://oss.oracle.com/licenses/upl
- *
- * or the following license:
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted
- * provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
- * and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other materials provided with
- * the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
- * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration.model.xml;
-
-import static org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration.model.xml.JFCGrammar.ATTRIBUTE_LABEL_MANDATORY;
-import static org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration.model.xml.JFCGrammar.ATTRIBUTE_NAME;
-import static org.openjdk.jmc.flightrecorder.controlpanel.ui.configuration.model.xml.JFCGrammar.TAG_CONFIGURATION_V1;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * A stateless validator of {@link XMLModel}s used for Flight Recording Configurations. Should
- * perhaps factor out aspects that can be expressed using {@link JFCGrammar}.
- */
-public final class JFCXMLValidator implements IXMLValidator {
- private static final JFCXMLValidator SHARED = new JFCXMLValidator();
-
- private static final Logger LOGGER = Logger.getLogger("org.openjdk.jmc.ui");
-
- interface IXMLNodeValidator {
- XMLValidationResult validate(Object parentNode, Object node);
- }
-
- private static class DanglingReference implements IXMLNodeValidator {
- private final Set m_variableNames;
- private final URI m_baseURI;
-
- DanglingReference(Set variableNames, URI baseURI) {
- m_variableNames = variableNames;
- m_baseURI = baseURI;
- }
-
- @Override
- public XMLValidationResult validate(Object parentNode, Object node) {
- if (node instanceof XMLAttributeInstance) {
- XMLAttributeInstance i = (XMLAttributeInstance) node;
- if (i.getAttribute().getType() == XMLNodeType.REFERENCE) {
- String variableName = i.getValue();
- if (!variableName.isEmpty()) {
- variableName = m_baseURI.resolve(variableName).toString();
- if (!m_variableNames.contains(variableName)) {
- return new XMLValidationResult(i, "Variable '" + variableName + "' can't be found.", true); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- }
- return XMLValidationResult.OK;
- }
- };
-
- private static class DuplicateDefinition implements IXMLNodeValidator {
- private final Set m_variables = new HashSet<>();
-
- @Override
- public XMLValidationResult validate(Object parentNode, Object node) {
- if (node instanceof XMLAttributeInstance) {
- XMLAttributeInstance i = (XMLAttributeInstance) node;
- if (i.getAttribute().getType() == XMLNodeType.DEFINITION) {
- if (parentNode instanceof XMLTagInstance) {
- // Only conditions are allowed to define duplicates.
- XMLTagInstance parent = (XMLTagInstance) parentNode;
- if (parent.getTag() == JFCGrammar.TAG_CONDITION) {
- return XMLValidationResult.OK;
- }
- }
- String name = i.getValue();
- if (m_variables.contains(name)) {
- return new XMLValidationResult(i, "Variable '" + name + "' is defined more than once.", true); //$NON-NLS-1$ //$NON-NLS-2$
- }
- m_variables.add(i.getValue());
- }
- }
- return XMLValidationResult.OK;
- }
- };
-
- private static class MissingChild implements IXMLNodeValidator {
- @Override
- public XMLValidationResult validate(Object parentNode, Object node) {
- if (node instanceof XMLTagInstance) {
- XMLTagInstance i = (XMLTagInstance) node;
- if (i.getTag().getType() == XMLNodeType.ELEMENT_WITH_AT_LEAST_ONE_CHILD
- && i.getTagsInstances().isEmpty()) {
- return new XMLValidationResult(i, i.getTag().getName() + " must have at least on child element.", //$NON-NLS-1$
- true);
- }
- }
- return XMLValidationResult.OK;
- }
- };
-
- private static class InvalidAttribute implements IXMLNodeValidator {
- @Override
- public XMLValidationResult validate(Object parentNode, Object node) {
- if (node instanceof XMLAttributeInstance) {
- XMLAttributeInstance instance = (XMLAttributeInstance) node;
- XMLAttribute attribute = instance.getAttribute();
- if (attribute.isRequired() && instance.isImplicitDefault()) {
- return new XMLValidationResult(instance,
- "'" + instance.getAttribute().getName() + "' is missing content.", true); //$NON-NLS-1$ //$NON-NLS-2$
- }
- Collection validValues = attribute.getValidValues();
- if (!validValues.isEmpty() && !validValues.contains(instance.getValue().toLowerCase())) {
- StringBuilder textBuf = new StringBuilder("Attribute '"); //$NON-NLS-1$
- textBuf.append(instance.getAttribute().getName());
- textBuf.append("' must have one of these values: \""); //$NON-NLS-1$
- Iterator values = validValues.iterator();
- while (values.hasNext()) {
- textBuf.append(values.next());
- if (values.hasNext()) {
- textBuf.append("\", \""); //$NON-NLS-1$
- }
- }
- textBuf.append("\"."); //$NON-NLS-1$
-
- return new XMLValidationResult(instance, textBuf.toString(), true);
- }
- }
- return XMLValidationResult.OK;
- }
- }
-
- public static IXMLValidator getValidator() {
- return SHARED;
- }
-
- private JFCXMLValidator() {
- }
-
- @Override
- public List validate(XMLModel model) {
- String label;
- if (model.getRoot().getTag() == TAG_CONFIGURATION_V1) {
- label = model.getRoot().getValue(ATTRIBUTE_NAME);
- } else {
- label = model.getRoot().getValue(ATTRIBUTE_LABEL_MANDATORY);
- }
- LOGGER.log(Level.FINE, "Running JFC validation on " + label); //$NON-NLS-1$
- List errors = new ArrayList<>();
- XMLTagInstance configuration = model.getRoot();
- List producers = configuration.getTagsInstances(JFCGrammar.TAG_PRODUCER);
- // General stuff
- collectErrors(null, configuration, new MissingChild(), errors);
- collectErrors(null, configuration, new InvalidAttribute(), errors);
-
- /*
- * Check variables for each producer Variables can span multiple producers, if the are
- * prefixed with producer uri. Example: http://www.oracle.com/hotspot/jvm/file-io-threshold
- */
- Set qualifiedVariableNames = createQualifiedVariableSet(producers, JFCGrammar.ATTRIBUTE_URI);
- for (XMLTagInstance producer : producers) {
- URI producerURI = createTrailingSlashURI(producer.getValue(JFCGrammar.ATTRIBUTE_URI));
- collectErrors(null, producer, new DuplicateDefinition(), errors);
- collectErrors(null, producer, new DanglingReference(qualifiedVariableNames, producerURI), errors);
- }
- return errors;
- }
-
- private void collectErrors(Object parent, Object o, IXMLNodeValidator validator, List result) {
- result.add(validator.validate(parent, o));
- if (o instanceof XMLTagInstance) {
- XMLTagInstance t = (XMLTagInstance) o;
- for (XMLTagInstance i : t.getTagsInstances()) {
- collectErrors(o, i, validator, result);
- }
- for (XMLAttributeInstance i : t.getAttributeInstances()) {
- collectErrors(o, i, validator, result);
- }
- }
- }
-
- // FIXME: Generalize so that an overriding base URI can be applied at any element level?
- // Consider xml:base (http://en.wikipedia.org/wiki/XML_Base).
- public static Set createQualifiedVariableSet(
- List rootElements, XMLAttribute baseUriAttribute) {
- List variables = new ArrayList<>();
- for (XMLTagInstance rootElement : rootElements) {
- URI baseURI = createTrailingSlashURI(rootElement.getValue(baseUriAttribute));
- Queue