summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-07-29 17:04:06 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-08-03 11:33:44 +0200
commit6c6281716ac5ee644b6abacf5164dc3e27687503 (patch)
treeedfede8c4e37a42171ca24a023580e68e4dbc408 /opendc-web/opendc-web-runner-quarkus-deployment/src/main/java
parent5c824ecafdc16022456ef05c5eeeeea19a5ac9b3 (diff)
fix(web/runner): Register all available trace formats
This change updates the Quarkus extension to register all the available trace formats that are on the class path during processing time. Without this change, the OpenDC web runner is unable to load any of the available trace formats via Quarkus.
Diffstat (limited to 'opendc-web/opendc-web-runner-quarkus-deployment/src/main/java')
-rw-r--r--opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java b/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java
index b9a334ac..1d01aabc 100644
--- a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java
+++ b/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java
@@ -26,11 +26,17 @@ import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.*;
+import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
+import io.quarkus.deployment.util.ServiceUtil;
import io.quarkus.runtime.RuntimeValue;
+import org.opendc.trace.spi.TraceFormat;
import org.opendc.web.runner.OpenDCRunner;
import org.opendc.web.runner.runtime.OpenDCRunnerRecorder;
import org.opendc.web.runner.runtime.OpenDCRunnerRuntimeConfig;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
import java.util.function.BooleanSupplier;
import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT;
@@ -51,12 +57,18 @@ public class OpenDCRunnerProcessor {
}
/**
- * Build step to index the necessary dependencies for the OpenDC runner.
+ * Build step to register the trace formats used by OpenDC.
*/
@BuildStep
- void addDependencies(BuildProducer<IndexDependencyBuildItem> indexDependency) {
- indexDependency.produce(new IndexDependencyBuildItem("org.opendc.trace", "opendc-trace-opendc"));
- indexDependency.produce(new IndexDependencyBuildItem("org.opendc.trace", "opendc-trace-bitbrains"));
+ void registerTraceFormats(BuildProducer<ServiceProviderBuildItem> services) throws IOException {
+ String service = "META-INF/services/" + TraceFormat.class.getName();
+
+ Set<String> implementations = ServiceUtil.classNamesNamedIn(Thread.currentThread().getContextClassLoader(),
+ service);
+
+ services.produce(
+ new ServiceProviderBuildItem(TraceFormat.class.getName(),
+ implementations.toArray(new String[0])));
}
/**