Class JmxManagementLifecycleStrategy

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.management.JmxManagementLifecycleStrategy
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.LifecycleStrategy, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

public class JmxManagementLifecycleStrategy extends org.apache.camel.support.service.ServiceSupport implements org.apache.camel.spi.LifecycleStrategy, org.apache.camel.CamelContextAware
Default JMX managed lifecycle strategy that registered objects using the configured ManagementStrategy.
See Also:
  • ManagementStrategy
  • 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
    Constructor
    Description
     
    JmxManagementLifecycleStrategy(org.apache.camel.CamelContext camelContext)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
     
    org.apache.camel.CamelContext
     
    protected void
    Strategy for managing the object
    void
    onComponentAdd(String name, org.apache.camel.Component component)
     
    void
    onComponentRemove(String name, org.apache.camel.Component component)
     
    void
    onContextStarting(org.apache.camel.CamelContext context)
     
    void
    onContextStopped(org.apache.camel.CamelContext context)
     
    void
    onEndpointAdd(org.apache.camel.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(org.apache.camel.Endpoint endpoint)
     
    void
    onRouteContextCreate(org.apache.camel.Route route)
     
    void
    onRoutesAdd(Collection<org.apache.camel.Route> routes)
     
    void
    onRoutesRemove(Collection<org.apache.camel.Route> routes)
     
    void
    onServiceAdd(org.apache.camel.CamelContext context, org.apache.camel.Service service, org.apache.camel.Route route)
     
    void
    onServiceRemove(org.apache.camel.CamelContext context, org.apache.camel.Service service, org.apache.camel.Route route)
     
    void
    onThreadPoolAdd(org.apache.camel.CamelContext camelContext, ThreadPoolExecutor threadPool, String id, String sourceId, String routeId, String threadPoolProfileId)
     
    void
    onThreadPoolRemove(org.apache.camel.CamelContext camelContext, ThreadPoolExecutor threadPool)
     
    protected boolean
    registerProcessor(org.apache.camel.model.ProcessorDefinition<?> processor)
    Should the given processor be registered.
    void
    setCamelContext(org.apache.camel.CamelContext camelContext)
     
    protected boolean
    shouldRegister(Object service, org.apache.camel.Route route)
    Whether to register the mbean.
    protected void
    Un-manages the object.

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, 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.spi.LifecycleStrategy

    onContextInitialized, onContextInitializing, onContextStarted, onContextStopping, onDataFormatCreated, onLanguageCreated

    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

  • Method Details

    • getCamelContext

      public org.apache.camel.CamelContext getCamelContext()
      Specified by:
      getCamelContext in interface org.apache.camel.spi.HasCamelContext
    • setCamelContext

      public void setCamelContext(org.apache.camel.CamelContext camelContext)
      Specified by:
      setCamelContext in interface org.apache.camel.CamelContextAware
    • onContextStarting

      public void onContextStarting(org.apache.camel.CamelContext context) throws org.apache.camel.VetoCamelContextStartException
      Specified by:
      onContextStarting in interface org.apache.camel.spi.LifecycleStrategy
      Throws:
      org.apache.camel.VetoCamelContextStartException
    • onContextStopped

      public void onContextStopped(org.apache.camel.CamelContext context)
      Specified by:
      onContextStopped in interface org.apache.camel.spi.LifecycleStrategy
    • onComponentAdd

      public void onComponentAdd(String name, org.apache.camel.Component component)
      Specified by:
      onComponentAdd in interface org.apache.camel.spi.LifecycleStrategy
    • onComponentRemove

      public void onComponentRemove(String name, org.apache.camel.Component component)
      Specified by:
      onComponentRemove in interface org.apache.camel.spi.LifecycleStrategy
    • onEndpointAdd

      public void onEndpointAdd(org.apache.camel.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 org.apache.camel.spi.LifecycleStrategy
      Parameters:
      endpoint - the Endpoint attempted to be added
    • onEndpointRemove

      public void onEndpointRemove(org.apache.camel.Endpoint endpoint)
      Specified by:
      onEndpointRemove in interface org.apache.camel.spi.LifecycleStrategy
    • onServiceAdd

      public void onServiceAdd(org.apache.camel.CamelContext context, org.apache.camel.Service service, org.apache.camel.Route route)
      Specified by:
      onServiceAdd in interface org.apache.camel.spi.LifecycleStrategy
    • onServiceRemove

      public void onServiceRemove(org.apache.camel.CamelContext context, org.apache.camel.Service service, org.apache.camel.Route route)
      Specified by:
      onServiceRemove in interface org.apache.camel.spi.LifecycleStrategy
    • onRoutesAdd

      public void onRoutesAdd(Collection<org.apache.camel.Route> routes)
      Specified by:
      onRoutesAdd in interface org.apache.camel.spi.LifecycleStrategy
    • onRoutesRemove

      public void onRoutesRemove(Collection<org.apache.camel.Route> routes)
      Specified by:
      onRoutesRemove in interface org.apache.camel.spi.LifecycleStrategy
    • onThreadPoolAdd

      public void onThreadPoolAdd(org.apache.camel.CamelContext camelContext, ThreadPoolExecutor threadPool, String id, String sourceId, String routeId, String threadPoolProfileId)
      Specified by:
      onThreadPoolAdd in interface org.apache.camel.spi.LifecycleStrategy
    • onThreadPoolRemove

      public void onThreadPoolRemove(org.apache.camel.CamelContext camelContext, ThreadPoolExecutor threadPool)
      Specified by:
      onThreadPoolRemove in interface org.apache.camel.spi.LifecycleStrategy
    • onRouteContextCreate

      public void onRouteContextCreate(org.apache.camel.Route route)
      Specified by:
      onRouteContextCreate in interface org.apache.camel.spi.LifecycleStrategy
    • registerProcessor

      protected boolean registerProcessor(org.apache.camel.model.ProcessorDefinition<?> processor)
      Should the given processor be registered.
    • manageObject

      protected void manageObject(Object me) throws Exception
      Strategy for managing the object
      Parameters:
      me - the managed object
      Throws:
      Exception - is thrown if error registering the object for management
    • unmanageObject

      protected void unmanageObject(Object me) throws Exception
      Un-manages the object.
      Parameters:
      me - the managed object
      Throws:
      Exception - is thrown if error unregistering the managed object
    • shouldRegister

      protected boolean shouldRegister(Object service, org.apache.camel.Route route)
      Whether 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
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception