Interface ContextServicePlugin
Implementations of this interface are automatically discovered and loaded via the Java ServiceLoader mechanism. To
register a plugin, create a service provider configuration file at
META-INF/services/org.apache.camel.spi.ContextServicePlugin containing the fully qualified class name of your
implementation.
Common use cases include:
- Registering beans in the Camel registry
- Adding event notifiers for monitoring
- Configuring global interceptors
- Setting up custom type converters
Example Usage:
public class MyContextServicePlugin implements ContextServicePlugin {
@Override
public void load(CamelContext camelContext) {
// Register a bean in the registry
camelContext.getRegistry().bind("myBean", new MyBean());
// Add an event notifier
camelContext.getManagementStrategy().addEventNotifier(new MyEventNotifier());
}
}
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidload(CamelContext camelContext) Called during CamelContext initialization to allow the plugin to configure or customize the context.default voidonReload(CamelContext camelContext) Called before route reloading in development mode to allow the plugin to refresh its state.default voidunload(CamelContext camelContext) Called during CamelContext stop.
-
Method Details
-
load
Called during CamelContext initialization to allow the plugin to configure or customize the context.This method is invoked after the CamelContext has been created but before routes are started. Implementations should perform any necessary setup operations such as registering beans, adding event notifiers, or configuring global settings.
- Parameters:
camelContext- the CamelContext being initialized, nevernull
-
onReload
Called before route reloading in development mode to allow the plugin to refresh its state.This method is invoked by the route watcher reload strategy before routes are reloaded, giving plugins the opportunity to refresh bean references, re-read configuration, or perform other updates that should happen before the new routes are started.
The default implementation does nothing. Plugins that register beans or other resources that may become stale when properties change should override this method to refresh those resources.
- Parameters:
camelContext- the CamelContext being reloaded, nevernull
-
unload
Called during CamelContext stop. Use it to free allocated resources.- Parameters:
camelContext- the CamelContext being uninitialized, nevernull
-