org.apache.camel.management
Class DefaultManagementAgent

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.management.DefaultManagementAgent
All Implemented Interfaces:
CamelContextAware, Service, ShutdownableService, ManagementAgent, StatefulService, SuspendableService

public class DefaultManagementAgent
extends ServiceSupport
implements ManagementAgent, CamelContextAware

Default implementation of the Camel JMX service agent


Field Summary
static int DEFAULT_CONNECTION_PORT
           
static String DEFAULT_DOMAIN
           
static String DEFAULT_HOST
           
static int DEFAULT_REGISTRY_PORT
           
static String DEFAULT_SERVICE_URL_PATH
           
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
DefaultManagementAgent()
           
DefaultManagementAgent(CamelContext camelContext)
           
 
Method Summary
protected  void createJmxConnector(String host)
           
protected  void createMBeanServer()
           
protected  void doStart()
          Implementations override this method to support customized start/stop.
protected  void doStop()
          Implementations override this method to support customized start/stop.
protected  void finalizeSettings()
           
protected  MBeanServer findOrCreateMBeanServer()
           
 CamelContext getCamelContext()
          Get the CamelContext
 Integer getConnectorPort()
          Gets the port clients must use to connect
 Boolean getCreateConnector()
          Whether connector is created, allowing clients to connect remotely
 String getMBeanObjectDomainName()
          Get domain name for Camel MBeans.
 MBeanServer getMBeanServer()
          Get the MBeanServer which hosts managed objects.
 String getMBeanServerDefaultDomain()
          Gets the default domain on the MBean server
 Boolean getOnlyRegisterProcessorWithCustomId()
          Whether to only register processors which has a custom id assigned.
 Boolean getRegisterAlways()
          Whether to always register mbeans.
 Boolean getRegisterNewRoutes()
          Whether to register mbeans when starting a new route

This option is default true.

 Integer getRegistryPort()
          Gets the port used by LocateRegistry.
 String getServiceUrlPath()
          Gets the service url
 Boolean getUsePlatformMBeanServer()
          Whether to use the platform MBean Server.
 boolean isRegistered(ObjectName name)
          Is the given object registered
 void register(Object obj, ObjectName name)
          Registers object with management infrastructure with a specific name.
 void register(Object obj, ObjectName name, boolean forceRegistration)
          Registers object with management infrastructure with a specific name.
 void setCamelContext(CamelContext camelContext)
          Injects the CamelContext
 void setConnectorPort(Integer port)
          Sets the port clients must use to connect
 void setCreateConnector(Boolean flag)
          Whether connector should be created, allowing clients to connect remotely
 void setMBeanObjectDomainName(String domainName)
          Sets the object domain name
 void setMBeanServer(MBeanServer mbeanServer)
          Sets a custom mbean server to use
 void setMBeanServerDefaultDomain(String domain)
          Sets the default domain on the MBean server
 void setOnlyRegisterProcessorWithCustomId(Boolean onlyRegisterProcessorWithCustomId)
          Whether to only register processors which has a custom id assigned.
 void setRegisterAlways(Boolean registerAlways)
          Whether to always register mbeans.
 void setRegisterNewRoutes(Boolean registerNewRoutes)
          Whether to register mbeans when starting a new route

This option is default true.

 void setRegistryPort(Integer port)
          Sets the port used by LocateRegistry.
 void setServiceUrlPath(String url)
          Sets the service url
 void setUsePlatformMBeanServer(Boolean flag)
          Whether to use the platform MBean Server.
 void unregister(ObjectName name)
          Unregisters object based upon registered name
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, 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
start, stop
 

Field Detail

DEFAULT_DOMAIN

public static final String DEFAULT_DOMAIN
See Also:
Constant Field Values

DEFAULT_HOST

public static final String DEFAULT_HOST
See Also:
Constant Field Values

DEFAULT_REGISTRY_PORT

public static final int DEFAULT_REGISTRY_PORT
See Also:
Constant Field Values

DEFAULT_CONNECTION_PORT

public static final int DEFAULT_CONNECTION_PORT
See Also:
Constant Field Values

DEFAULT_SERVICE_URL_PATH

public static final String DEFAULT_SERVICE_URL_PATH
See Also:
Constant Field Values
Constructor Detail

DefaultManagementAgent

public DefaultManagementAgent()

DefaultManagementAgent

public DefaultManagementAgent(CamelContext camelContext)
Method Detail

finalizeSettings

protected void finalizeSettings()

setRegistryPort

public void setRegistryPort(Integer port)
Description copied from interface: ManagementAgent
Sets the port used by LocateRegistry.

Specified by:
setRegistryPort in interface ManagementAgent
Parameters:
port - the port

getRegistryPort

public Integer getRegistryPort()
Description copied from interface: ManagementAgent
Gets the port used by LocateRegistry.

Specified by:
getRegistryPort in interface ManagementAgent
Returns:
the port

setConnectorPort

public void setConnectorPort(Integer port)
Description copied from interface: ManagementAgent
Sets the port clients must use to connect

Specified by:
setConnectorPort in interface ManagementAgent
Parameters:
port - the port

getConnectorPort

public Integer getConnectorPort()
Description copied from interface: ManagementAgent
Gets the port clients must use to connect

Specified by:
getConnectorPort in interface ManagementAgent
Returns:
the port

setMBeanServerDefaultDomain

public void setMBeanServerDefaultDomain(String domain)
Description copied from interface: ManagementAgent
Sets the default domain on the MBean server

Specified by:
setMBeanServerDefaultDomain in interface ManagementAgent
Parameters:
domain - the domain

getMBeanServerDefaultDomain

public String getMBeanServerDefaultDomain()
Description copied from interface: ManagementAgent
Gets the default domain on the MBean server

Specified by:
getMBeanServerDefaultDomain in interface ManagementAgent
Returns:
the domain

setMBeanObjectDomainName

public void setMBeanObjectDomainName(String domainName)
Description copied from interface: ManagementAgent
Sets the object domain name

Specified by:
setMBeanObjectDomainName in interface ManagementAgent
Parameters:
domainName - the object domain name

getMBeanObjectDomainName

public String getMBeanObjectDomainName()
Description copied from interface: ManagementAgent
Get domain name for Camel MBeans.

Notice: That this can be different that the default domain name of the MBean Server.

Specified by:
getMBeanObjectDomainName in interface ManagementAgent
Returns:
domain name

setServiceUrlPath

public void setServiceUrlPath(String url)
Description copied from interface: ManagementAgent
Sets the service url

Specified by:
setServiceUrlPath in interface ManagementAgent
Parameters:
url - the service url

getServiceUrlPath

public String getServiceUrlPath()
Description copied from interface: ManagementAgent
Gets the service url

Specified by:
getServiceUrlPath in interface ManagementAgent
Returns:
the url

setCreateConnector

public void setCreateConnector(Boolean flag)
Description copied from interface: ManagementAgent
Whether connector should be created, allowing clients to connect remotely

Specified by:
setCreateConnector in interface ManagementAgent
Parameters:
flag - true to create connector

getCreateConnector

public Boolean getCreateConnector()
Description copied from interface: ManagementAgent
Whether connector is created, allowing clients to connect remotely

Specified by:
getCreateConnector in interface ManagementAgent
Returns:
true if connector is created

setUsePlatformMBeanServer

public void setUsePlatformMBeanServer(Boolean flag)
Description copied from interface: ManagementAgent
Whether to use the platform MBean Server.

Specified by:
setUsePlatformMBeanServer in interface ManagementAgent
Parameters:
flag - true to use platform MBean server

getUsePlatformMBeanServer

public Boolean getUsePlatformMBeanServer()
Description copied from interface: ManagementAgent
Whether to use the platform MBean Server.

Specified by:
getUsePlatformMBeanServer in interface ManagementAgent
Returns:
true if platform MBean server is to be used

getOnlyRegisterProcessorWithCustomId

public Boolean getOnlyRegisterProcessorWithCustomId()
Description copied from interface: ManagementAgent
Whether to only register processors which has a custom id assigned.

This allows you to filter unwanted processors.

Specified by:
getOnlyRegisterProcessorWithCustomId in interface ManagementAgent
Returns:
true if only processors with custom id is registered

setOnlyRegisterProcessorWithCustomId

public void setOnlyRegisterProcessorWithCustomId(Boolean onlyRegisterProcessorWithCustomId)
Description copied from interface: ManagementAgent
Whether to only register processors which has a custom id assigned.

This allows you to filter unwanted processors.

Specified by:
setOnlyRegisterProcessorWithCustomId in interface ManagementAgent
Parameters:
onlyRegisterProcessorWithCustomId - true to only register if custom id has been assigned

setMBeanServer

public void setMBeanServer(MBeanServer mbeanServer)
Description copied from interface: ManagementAgent
Sets a custom mbean server to use

Specified by:
setMBeanServer in interface ManagementAgent
Parameters:
mbeanServer - the custom mbean server

getMBeanServer

public MBeanServer getMBeanServer()
Description copied from interface: ManagementAgent
Get the MBeanServer which hosts managed objects.

Notice: If the JMXEnabled configuration is not set to true, this method will return null.

Specified by:
getMBeanServer in interface ManagementAgent
Returns:
the MBeanServer

getRegisterAlways

public Boolean getRegisterAlways()
Description copied from interface: ManagementAgent
Whether to always register mbeans.

This option is default false.

Important: If this option is enabled then any service is registered as mbean. When using dynamic EIP patterns using unique endpoint urls, you may create excessive mbeans in the registry. This could lead to degraded performance as memory consumption will rise due the rising number of mbeans.

Specified by:
getRegisterAlways in interface ManagementAgent
Returns:
true if always registering

setRegisterAlways

public void setRegisterAlways(Boolean registerAlways)
Description copied from interface: ManagementAgent
Whether to always register mbeans.

This option is default false.

Important: If this option is enabled then any service is registered as mbean. When using dynamic EIP patterns using unique endpoint urls, you may create excessive mbeans in the registry. This could lead to degraded performance as memory consumption will rise due the rising number of mbeans.

Specified by:
setRegisterAlways in interface ManagementAgent
Parameters:
registerAlways - true to always register

getRegisterNewRoutes

public Boolean getRegisterNewRoutes()
Description copied from interface: ManagementAgent
Whether to register mbeans when starting a new route

This option is default true.

Specified by:
getRegisterNewRoutes in interface ManagementAgent
Returns:
true to register when starting a new route

setRegisterNewRoutes

public void setRegisterNewRoutes(Boolean registerNewRoutes)
Description copied from interface: ManagementAgent
Whether to register mbeans when starting a new route

This option is default true.

Specified by:
setRegisterNewRoutes in interface ManagementAgent
Parameters:
registerNewRoutes - true to register when starting a new route

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

register

public void register(Object obj,
                     ObjectName name)
              throws JMException
Description copied from interface: ManagementAgent
Registers object with management infrastructure with a specific name. Object must be annotated or implement standard MBean interface.

Specified by:
register in interface ManagementAgent
Parameters:
obj - the object to register
name - the name
Throws:
JMException - is thrown if the registration failed

register

public void register(Object obj,
                     ObjectName name,
                     boolean forceRegistration)
              throws JMException
Description copied from interface: ManagementAgent
Registers object with management infrastructure with a specific name. Object must be annotated or implement standard MBean interface.

Specified by:
register in interface ManagementAgent
Parameters:
obj - the object to register
name - the name
forceRegistration - if set to true, then object will be registered despite existing object is already registered with the name.
Throws:
JMException - is thrown if the registration failed

unregister

public void unregister(ObjectName name)
                throws JMException
Description copied from interface: ManagementAgent
Unregisters object based upon registered name

Specified by:
unregister in interface ManagementAgent
Parameters:
name - the name
Throws:
JMException - is thrown if the unregistration failed

isRegistered

public boolean isRegistered(ObjectName name)
Description copied from interface: ManagementAgent
Is the given object registered

Specified by:
isRegistered in interface ManagementAgent
Parameters:
name - the name
Returns:
true if registered

doStart

protected void doStart()
                throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: See ServiceSupport.doStop() for more details.

Specified by:
doStart in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStop()

doStop

protected void doStop()
               throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: Camel will invoke this ServiceSupport.doStop() method when the service is being stopped. This method will also be invoked if the service is still in uninitialized state (eg has not been started). The method is always called to allow the service to do custom logic when the service is being stopped, such as when CamelContext is shutting down.

Specified by:
doStop in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStart()

createMBeanServer

protected void createMBeanServer()

findOrCreateMBeanServer

protected MBeanServer findOrCreateMBeanServer()

createJmxConnector

protected void createJmxConnector(String host)
                           throws IOException
Throws:
IOException


Apache CAMEL