This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch 3.27.x in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 6dd85da394d71d8227cd6128cc93d8b35d42d999 Author: James Netherton <[email protected]> AuthorDate: Thu Oct 30 09:17:45 2025 +0000 Remove QuarkusContextServiceLoaderPlugin and use the default impl --- .../camel/quarkus/core/FastCamelContext.java | 6 -- .../core/QuarkusContextServiceLoaderPlugin.java | 86 ---------------------- ...ultContextServiceLoaderPluginSubstitutions.java | 32 ++++++++ 3 files changed, 32 insertions(+), 92 deletions(-) diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java index c9f69d368c..2380ac62be 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java @@ -36,7 +36,6 @@ import org.apache.camel.spi.CamelBeanPostProcessor; import org.apache.camel.spi.ClassResolver; import org.apache.camel.spi.ComponentNameResolver; import org.apache.camel.spi.ComponentResolver; -import org.apache.camel.spi.ContextServiceLoaderPluginResolver; import org.apache.camel.spi.DataFormat; import org.apache.camel.spi.FactoryFinderResolver; import org.apache.camel.spi.Language; @@ -157,11 +156,6 @@ public class FastCamelContext extends DefaultCamelContext implements CatalogCame return null; } - @Override - protected ContextServiceLoaderPluginResolver createContextServiceLoaderPlugin() { - return new QuarkusContextServiceLoaderPlugin(); - } - @Override protected ClassResolver createClassResolver() { return new CamelQuarkusClassResolver(Objects.requireNonNull(getApplicationContextClassLoader(), diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/QuarkusContextServiceLoaderPlugin.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/QuarkusContextServiceLoaderPlugin.java deleted file mode 100644 index fe4e28b04c..0000000000 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/QuarkusContextServiceLoaderPlugin.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.core; - -import java.util.ServiceLoader; - -import org.apache.camel.CamelContext; -import org.apache.camel.spi.ContextServiceLoaderPluginResolver; -import org.apache.camel.spi.ContextServicePlugin; -import org.apache.camel.support.service.ServiceSupport; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class QuarkusContextServiceLoaderPlugin extends ServiceSupport implements ContextServiceLoaderPluginResolver { - private static final Logger LOG = LoggerFactory.getLogger(QuarkusContextServiceLoaderPlugin.class); - - private CamelContext camelContext; - - /** - * Discovers and loads all {@link ContextServicePlugin} implementations found on the classpath. - * <p> - * This method is called during service startup and uses {@link ServiceLoader} to automatically discover plugin - * implementations. Each discovered plugin's {@code load} method is invoked with the current CamelContext, allowing - * plugins to perform their initialization logic. - * <p> - * The plugins are loaded in the order they are discovered by the ServiceLoader, which may vary between JVM - * implementations and is generally not guaranteed to be deterministic. - * - * @throws Exception if any plugin fails to load or throws an exception during initialization - */ - @Override - protected void doStart() throws Exception { - ServiceLoader<ContextServicePlugin> contextServicePlugins = ServiceLoader.load(ContextServicePlugin.class, - camelContext.getApplicationContextClassLoader()); - for (ContextServicePlugin plugin : contextServicePlugins) { - try { - plugin.load(camelContext); - } catch (Exception e) { - LOG.warn( - "Loading of plugin {} failed, however the exception will be ignored so others plugins can be initialized. Reason: {}", - plugin.getClass().getName(), e.getMessage(), e); - } - } - } - - @Override - protected void doStop() throws Exception { - ServiceLoader<ContextServicePlugin> contextServicePlugins = ServiceLoader.load(ContextServicePlugin.class, - camelContext.getApplicationContextClassLoader()); - if (contextServicePlugins != null) { - for (ContextServicePlugin plugin : contextServicePlugins) { - try { - plugin.unload(camelContext); - } catch (Exception e) { - LOG.warn( - "Unloading of plugin {} failed, however the exception will be ignored so shutdown can continue. Reason: {}", - plugin.getClass().getName(), e.getMessage(), e); - } - } - } - } - - @Override - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } - - @Override - public CamelContext getCamelContext() { - return camelContext; - } -} diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/graal/DefaultContextServiceLoaderPluginSubstitutions.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/graal/DefaultContextServiceLoaderPluginSubstitutions.java new file mode 100644 index 0000000000..5a88ec2def --- /dev/null +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/graal/DefaultContextServiceLoaderPluginSubstitutions.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.core.graal; + +import java.util.ServiceLoader; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.RecomputeFieldValue; +import com.oracle.svm.core.annotate.TargetClass; +import org.apache.camel.impl.engine.DefaultContextServiceLoaderPlugin; +import org.apache.camel.spi.ContextServicePlugin; + +@TargetClass(DefaultContextServiceLoaderPlugin.class) +final class DefaultContextServiceLoaderPluginSubstitutions { + @Alias + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) + private ServiceLoader<ContextServicePlugin> contextServicePlugins; +}
