Class DefaultContextServiceLoaderPlugin
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.ContextServiceLoaderPluginResolver
,org.apache.camel.spi.HasCamelContext
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
ContextServicePlugin
implementations using the
Java ServiceLoader mechanism.
This service is responsible for scanning the classpath for implementations of ContextServicePlugin
and
invoking their load
method during CamelContext startup. Plugin implementations are discovered through service
provider configuration files located at: META-INF/services/org.apache.camel.spi.ContextServicePlugin
The loading process occurs during the doStart()
phase, ensuring that all plugins are initialized before
routes are started but after the CamelContext has been created and configured.
This class extends ServiceSupport
to participate in the Camel service lifecycle and implements
CamelContextAware
to receive the CamelContext instance that plugins will operate on.
- See Also:
-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doStart()
Discovers and loads allContextServicePlugin
implementations found on the classpath.org.apache.camel.CamelContext
void
setCamelContext
(org.apache.camel.CamelContext camelContext) Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doStop, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.camel.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
DefaultContextServiceLoaderPlugin
public DefaultContextServiceLoaderPlugin()
-
-
Method Details
-
doStart
Discovers and loads allContextServicePlugin
implementations found on the classpath.This method is called during service startup and uses
ServiceLoader
to automatically discover plugin implementations. Each discovered plugin'sload
method is invoked with the current CamelContext, allowing plugins to perform their initialization logic.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.
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
- if any plugin fails to load or throws an exception during initialization
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContext
in interfaceorg.apache.camel.CamelContextAware
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
getCamelContext
in interfaceorg.apache.camel.spi.HasCamelContext
-