org.apache.camel.management
Class DefaultManagementLifecycleStrategy

java.lang.Object
  extended by org.apache.camel.management.DefaultManagementLifecycleStrategy
All Implemented Interfaces:
CamelContextAware, Service, LifecycleStrategy

public class DefaultManagementLifecycleStrategy
extends Object
implements LifecycleStrategy, Service, CamelContextAware

Default JMX managed lifecycle strategy that registered objects using the configured ManagementStrategy.

Version:
See Also:
ManagementStrategy

Constructor Summary
DefaultManagementLifecycleStrategy()
           
DefaultManagementLifecycleStrategy(CamelContext camelContext)
           
 
Method Summary
 CamelContext getCamelContext()
          Get the CamelContext
 void onComponentAdd(String name, Component component)
          Notification on adding an Component.
 void onComponentRemove(String name, Component component)
          Notification on removing an Component.
 void onContextStart(CamelContext context)
          Notification on starting a CamelContext.
 void onContextStop(CamelContext context)
          Notification on stopping a CamelContext.
 void onEndpointAdd(Endpoint endpoint)
          If the endpoint is an instance of ManagedResource then register it with the mbean server, if it is not then wrap the endpoint in a ManagedEndpoint and register that with the mbean server.
 void onEndpointRemove(Endpoint endpoint)
          Notification on removing an Endpoint.
 void onErrorHandlerAdd(RouteContext routeContext, Processor errorHandler, ErrorHandlerBuilder errorHandlerBuilder)
          Notification on adding error handler.
 void onRouteContextCreate(RouteContext routeContext)
          Notification on adding RouteContext(s).
 void onRoutesAdd(Collection<Route> routes)
          Notification on adding Route(s).
 void onRoutesRemove(Collection<Route> routes)
          Notification on removing Route(s).
 void onServiceAdd(CamelContext context, Service service, Route route)
          Notification on adding a Service.
 void onServiceRemove(CamelContext context, Service service, Route route)
          Notification on removing a Service.
 void onThreadPoolAdd(CamelContext camelContext, ThreadPoolExecutor threadPool, String id, String sourceId, String routeId, String threadPoolProfileId)
          Notification on adding a thread pool.
protected  boolean registerProcessor(ProcessorDefinition processor)
          Should the given processor be registered.
 void setCamelContext(CamelContext camelContext)
          Injects the CamelContext
protected  boolean shouldRegister(Object service, Route route)
          Whether or not to register the mbean.
 void start()
          Starts the service
 void stop()
          Stops the service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultManagementLifecycleStrategy

public DefaultManagementLifecycleStrategy()

DefaultManagementLifecycleStrategy

public DefaultManagementLifecycleStrategy(CamelContext camelContext)
Method Detail

getCamelContext

public CamelContext getCamelContext()
Description copied from interface: CamelContextAware
Get the CamelContext

Specified by:
getCamelContext in interface CamelContextAware
Returns:
camelContext the Camel context

setCamelContext

public void setCamelContext(CamelContext camelContext)
Description copied from interface: CamelContextAware
Injects the CamelContext

Specified by:
setCamelContext in interface CamelContextAware
Parameters:
camelContext - the Camel context

onContextStart

public void onContextStart(CamelContext context)
                    throws VetoCamelContextStartException
Description copied from interface: LifecycleStrategy
Notification on starting a CamelContext.

Specified by:
onContextStart in interface LifecycleStrategy
Parameters:
context - the camel context
Throws:
VetoCamelContextStartException - can be thrown to veto starting CamelContext. Any other runtime exceptions will be logged at WARN level by Camel will continue starting itself.

onContextStop

public void onContextStop(CamelContext context)
Description copied from interface: LifecycleStrategy
Notification on stopping a CamelContext.

Specified by:
onContextStop in interface LifecycleStrategy
Parameters:
context - the camel context

onComponentAdd

public void onComponentAdd(String name,
                           Component component)
Description copied from interface: LifecycleStrategy
Notification on adding an Component.

Specified by:
onComponentAdd in interface LifecycleStrategy
Parameters:
name - the unique name of this component
component - the added component

onComponentRemove

public void onComponentRemove(String name,
                              Component component)
Description copied from interface: LifecycleStrategy
Notification on removing an Component.

Specified by:
onComponentRemove in interface LifecycleStrategy
Parameters:
name - the unique name of this component
component - the removed component

onEndpointAdd

public void onEndpointAdd(Endpoint endpoint)
If the endpoint is an instance of ManagedResource then register it with the mbean server, if it is not then wrap the endpoint in a ManagedEndpoint and register that with the mbean server.

Specified by:
onEndpointAdd in interface LifecycleStrategy
Parameters:
endpoint - the Endpoint attempted to be added

onEndpointRemove

public void onEndpointRemove(Endpoint endpoint)
Description copied from interface: LifecycleStrategy
Notification on removing an Endpoint.

Specified by:
onEndpointRemove in interface LifecycleStrategy
Parameters:
endpoint - the removed endpoint

onServiceAdd

public void onServiceAdd(CamelContext context,
                         Service service,
                         Route route)
Description copied from interface: LifecycleStrategy
Notification on adding a Service.

Specified by:
onServiceAdd in interface LifecycleStrategy
Parameters:
context - the camel context
service - the added service
route - the route the service belongs to if any possible to determine

onServiceRemove

public void onServiceRemove(CamelContext context,
                            Service service,
                            Route route)
Description copied from interface: LifecycleStrategy
Notification on removing a Service.

Specified by:
onServiceRemove in interface LifecycleStrategy
Parameters:
context - the camel context
service - the removed service
route - the route the service belongs to if any possible to determine

onRoutesAdd

public void onRoutesAdd(Collection<Route> routes)
Description copied from interface: LifecycleStrategy
Notification on adding Route(s).

Specified by:
onRoutesAdd in interface LifecycleStrategy
Parameters:
routes - the added routes

onRoutesRemove

public void onRoutesRemove(Collection<Route> routes)
Description copied from interface: LifecycleStrategy
Notification on removing Route(s).

Specified by:
onRoutesRemove in interface LifecycleStrategy
Parameters:
routes - the removed routes

onErrorHandlerAdd

public void onErrorHandlerAdd(RouteContext routeContext,
                              Processor errorHandler,
                              ErrorHandlerBuilder errorHandlerBuilder)
Description copied from interface: LifecycleStrategy
Notification on adding error handler.

Specified by:
onErrorHandlerAdd in interface LifecycleStrategy
Parameters:
routeContext - the added route context
errorHandler - the error handler
errorHandlerBuilder - the error handler builder

onThreadPoolAdd

public void onThreadPoolAdd(CamelContext camelContext,
                            ThreadPoolExecutor threadPool,
                            String id,
                            String sourceId,
                            String routeId,
                            String threadPoolProfileId)
Description copied from interface: LifecycleStrategy
Notification on adding a thread pool.

Specified by:
onThreadPoolAdd in interface LifecycleStrategy
Parameters:
camelContext - the camel context
threadPool - the thread pool
id - id of the thread pool (can be null in special cases)
sourceId - id of the source creating the thread pool (can be null in special cases)
routeId - id of the route for the source (is null if no source)
threadPoolProfileId - id of the thread pool profile, if used for creating this thread pool (can be null)

onRouteContextCreate

public void onRouteContextCreate(RouteContext routeContext)
Description copied from interface: LifecycleStrategy
Notification on adding RouteContext(s).

Specified by:
onRouteContextCreate in interface LifecycleStrategy
Parameters:
routeContext - the added route context

registerProcessor

protected boolean registerProcessor(ProcessorDefinition processor)
Should the given processor be registered.


start

public void start()
           throws Exception
Description copied from interface: Service
Starts the service

Specified by:
start in interface Service
Throws:
Exception - is thrown if starting failed

stop

public void stop()
          throws Exception
Description copied from interface: Service
Stops the service

Specified by:
stop in interface Service
Throws:
Exception - is thrown if stopping failed

shouldRegister

protected boolean shouldRegister(Object service,
                                 Route route)
Whether or not to register the mbean.

The ManagementAgent has options which controls when to register. This allows us to only register mbeans accordingly. For example by default any dynamic endpoints is not registered. This avoids to register excessive mbeans, which most often is not desired.

Parameters:
service - the object to register
route - an optional route the mbean is associated with, can be null
Returns:
true to register, false to skip registering


Apache CAMEL