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 voiddoStart()Discovers and loads allContextServicePluginimplementations found on the classpath.protected voiddoStop()org.apache.camel.CamelContextvoidsetCamelContext(org.apache.camel.CamelContext camelContext) Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
DefaultContextServiceLoaderPlugin
public DefaultContextServiceLoaderPlugin()
-
-
Method Details
-
doStart
Discovers and loads allContextServicePluginimplementations found on the classpath.This method is called during service startup and uses
ServiceLoaderto automatically discover plugin implementations. Each discovered plugin'sloadmethod 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:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception- if any plugin fails to load or throws an exception during initialization
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
getCamelContextin interfaceorg.apache.camel.spi.HasCamelContext
-