org.apache.camel.management
Class DefaultManagementStrategy

java.lang.Object
  extended by org.apache.camel.management.DefaultManagementStrategy
All Implemented Interfaces:
CamelContextAware, Service, ManagementStrategy
Direct Known Subclasses:
ManagedManagementStrategy

public class DefaultManagementStrategy
extends Object
implements ManagementStrategy, CamelContextAware

A default management strategy that does not manage.

This is default only used if Camel detects that it cannot use the JMX capable ManagedManagementStrategy strategy. Then Camel will fallback to use this instead that is basically a simple and noop strategy.

This class can also be used to extend your custom management implement. In fact the JMX capable provided by Camel extends this class as well.

Version:
See Also:
ManagedManagementStrategy

Constructor Summary
DefaultManagementStrategy()
           
DefaultManagementStrategy(CamelContext camelContext)
           
 
Method Summary
 void addEventNotifier(EventNotifier eventNotifier)
          Adds the event notifier to use.
 Statistic createStatistic(String name, Object owner, Statistic.UpdateMode updateMode)
           
 CamelContext getCamelContext()
          Get the CamelContext
 EventFactory getEventFactory()
          Gets the event factory
 List<EventNotifier> getEventNotifiers()
          Gets the event notifiers.
<T> T
getManagedObjectName(Object managedObject, String customName, Class<T> nameType)
          Construct an object name, where either the object to be managed and/or a custom name component are provided
 ManagementAgent getManagementAgent()
          Gets the management agent
 ManagementNamingStrategy getManagementNamingStrategy()
          Gets the naming strategy to use
 ManagementObjectStrategy getManagementObjectStrategy()
          Gets the object strategy to use
 ManagementStatisticsLevel getStatisticsLevel()
          Gets the statistics level
 boolean isManaged(Object managedObject, Object name)
          Determines if an object or name is managed.
 boolean isOnlyManageProcessorWithCustomId()
          Checks whether only to manage processors if they have been configured with a custom id
 void manageNamedObject(Object managedObject, Object preferredName)
          Adds a managed object allowing the ManagementStrategy implementation to record or expose the object as it sees fit.
 void manageObject(Object managedObject)
          Adds a managed object allowing the ManagementStrategy implementation to record or expose the object as it sees fit.
 boolean manageProcessor(ProcessorDefinition<?> definition)
          Filter whether the processor should be managed or not.
 void notify(EventObject event)
          Management events provide a single model for capturing information about execution points in the application code.
 void onlyManageProcessorWithCustomId(boolean flag)
          Sets the whether only manage processors if they have been configured with a custom id

Default is false.

 boolean removeEventNotifier(EventNotifier eventNotifier)
          Removes the event notifier
 void setCamelContext(CamelContext camelContext)
          Injects the CamelContext
 void setEventFactory(EventFactory eventFactory)
          Sets the event factory to use
 void setEventNotifiers(List<EventNotifier> eventNotifiers)
          Sets the list of event notifier to use.
 void setManagementAgent(ManagementAgent managementAgent)
          Sets the management agent to use
 void setManagementNamingStrategy(ManagementNamingStrategy managementNamingStrategy)
          Sets the naming strategy to use
 void setManagementObjectStrategy(ManagementObjectStrategy managementObjectStrategy)
          Sets the object strategy to use
 void setStatisticsLevel(ManagementStatisticsLevel level)
          Sets the statistics level

Default is ManagementStatisticsLevel.All

 void start()
          Starts the service
 void stop()
          Stops the service
 void unmanageNamedObject(Object name)
          Removes a managed object by name.
 void unmanageObject(Object managedObject)
          Removes the managed object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultManagementStrategy

public DefaultManagementStrategy()

DefaultManagementStrategy

public DefaultManagementStrategy(CamelContext camelContext)
Method Detail

getEventNotifiers

public List<EventNotifier> getEventNotifiers()
Description copied from interface: ManagementStrategy
Gets the event notifiers.

Specified by:
getEventNotifiers in interface ManagementStrategy
Returns:
event notifiers

addEventNotifier

public void addEventNotifier(EventNotifier eventNotifier)
Description copied from interface: ManagementStrategy
Adds the event notifier to use.

Ensure the event notifier has been started if its a Service, as otherwise it would not be used.

Specified by:
addEventNotifier in interface ManagementStrategy
Parameters:
eventNotifier - event notifier

removeEventNotifier

public boolean removeEventNotifier(EventNotifier eventNotifier)
Description copied from interface: ManagementStrategy
Removes the event notifier

Specified by:
removeEventNotifier in interface ManagementStrategy
Parameters:
eventNotifier - event notifier to remove
Returns:
true if removed, false if already removed

setEventNotifiers

public void setEventNotifiers(List<EventNotifier> eventNotifiers)
Description copied from interface: ManagementStrategy
Sets the list of event notifier to use.

Specified by:
setEventNotifiers in interface ManagementStrategy
Parameters:
eventNotifiers - list of event notifiers

getEventFactory

public EventFactory getEventFactory()
Description copied from interface: ManagementStrategy
Gets the event factory

Specified by:
getEventFactory in interface ManagementStrategy
Returns:
event factory

setEventFactory

public void setEventFactory(EventFactory eventFactory)
Description copied from interface: ManagementStrategy
Sets the event factory to use

Specified by:
setEventFactory in interface ManagementStrategy
Parameters:
eventFactory - event factory

getManagementNamingStrategy

public ManagementNamingStrategy getManagementNamingStrategy()
Description copied from interface: ManagementStrategy
Gets the naming strategy to use

Specified by:
getManagementNamingStrategy in interface ManagementStrategy
Returns:
naming strategy

setManagementNamingStrategy

public void setManagementNamingStrategy(ManagementNamingStrategy managementNamingStrategy)
Description copied from interface: ManagementStrategy
Sets the naming strategy to use

Specified by:
setManagementNamingStrategy in interface ManagementStrategy
Parameters:
managementNamingStrategy - naming strategy

getManagementObjectStrategy

public ManagementObjectStrategy getManagementObjectStrategy()
Description copied from interface: ManagementStrategy
Gets the object strategy to use

Specified by:
getManagementObjectStrategy in interface ManagementStrategy
Returns:
object strategy

setManagementObjectStrategy

public void setManagementObjectStrategy(ManagementObjectStrategy managementObjectStrategy)
Description copied from interface: ManagementStrategy
Sets the object strategy to use

Specified by:
setManagementObjectStrategy in interface ManagementStrategy
Parameters:
managementObjectStrategy - object strategy

getManagementAgent

public ManagementAgent getManagementAgent()
Description copied from interface: ManagementStrategy
Gets the management agent

Specified by:
getManagementAgent in interface ManagementStrategy
Returns:
management agent

setManagementAgent

public void setManagementAgent(ManagementAgent managementAgent)
Description copied from interface: ManagementStrategy
Sets the management agent to use

Specified by:
setManagementAgent in interface ManagementStrategy
Parameters:
managementAgent - management agent

onlyManageProcessorWithCustomId

public void onlyManageProcessorWithCustomId(boolean flag)
Description copied from interface: ManagementStrategy
Sets the whether only manage processors if they have been configured with a custom id

Default is false.

Specified by:
onlyManageProcessorWithCustomId in interface ManagementStrategy
Parameters:
flag - true will only manage if custom id was set.

isOnlyManageProcessorWithCustomId

public boolean isOnlyManageProcessorWithCustomId()
Description copied from interface: ManagementStrategy
Checks whether only to manage processors if they have been configured with a custom id

Specified by:
isOnlyManageProcessorWithCustomId in interface ManagementStrategy
Returns:
true or false

manageProcessor

public boolean manageProcessor(ProcessorDefinition<?> definition)
Description copied from interface: ManagementStrategy
Filter whether the processor should be managed or not.

Is used to filter out unwanted processors to avoid managing at too fine grained level.

Specified by:
manageProcessor in interface ManagementStrategy
Parameters:
definition - definition of the processor
Returns:
true to manage it

manageObject

public void manageObject(Object managedObject)
                  throws Exception
Description copied from interface: ManagementStrategy
Adds a managed object allowing the ManagementStrategy implementation to record or expose the object as it sees fit.

Specified by:
manageObject in interface ManagementStrategy
Parameters:
managedObject - the managed object
Throws:
Exception - can be thrown if the object could not be added

manageNamedObject

public void manageNamedObject(Object managedObject,
                              Object preferredName)
                       throws Exception
Description copied from interface: ManagementStrategy
Adds a managed object allowing the ManagementStrategy implementation to record or expose the object as it sees fit.

Specified by:
manageNamedObject in interface ManagementStrategy
Parameters:
managedObject - the managed object
preferredName - representing the preferred name, maybe a String, or a JMX ObjectName
Throws:
Exception - can be thrown if the object could not be added

getManagedObjectName

public <T> T getManagedObjectName(Object managedObject,
                                  String customName,
                                  Class<T> nameType)
                       throws Exception
Description copied from interface: ManagementStrategy
Construct an object name, where either the object to be managed and/or a custom name component are provided

Specified by:
getManagedObjectName in interface ManagementStrategy
Parameters:
managedObject - the object to be managed
customName - a custom name component
nameType - the name type required
Returns:
an object name of the required type if supported, otherwise null
Throws:
Exception - can be thrown if the object name could not be created

unmanageObject

public void unmanageObject(Object managedObject)
                    throws Exception
Description copied from interface: ManagementStrategy
Removes the managed object.

Specified by:
unmanageObject in interface ManagementStrategy
Parameters:
managedObject - the managed object
Throws:
Exception - can be thrown if the object could not be removed

unmanageNamedObject

public void unmanageNamedObject(Object name)
                         throws Exception
Description copied from interface: ManagementStrategy
Removes a managed object by name.

Specified by:
unmanageNamedObject in interface ManagementStrategy
Parameters:
name - an object name previously created by this strategy.
Throws:
Exception - can be thrown if the object could not be removed

isManaged

public boolean isManaged(Object managedObject,
                         Object name)
Description copied from interface: ManagementStrategy
Determines if an object or name is managed.

Specified by:
isManaged in interface ManagementStrategy
Parameters:
managedObject - the object to consider
name - the name to consider
Returns:
true if the given object or name is managed

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

notify

public void notify(EventObject event)
            throws Exception
Description copied from interface: ManagementStrategy
Management events provide a single model for capturing information about execution points in the application code. Management strategy implementations decide if and where to record these events. Applications communicate events to management strategy implementations via the notify(EventObject) method.

Specified by:
notify in interface ManagementStrategy
Parameters:
event - the event
Throws:
Exception - can be thrown if the notification failed

createStatistic

public Statistic createStatistic(String name,
                                 Object owner,
                                 Statistic.UpdateMode updateMode)

setStatisticsLevel

public void setStatisticsLevel(ManagementStatisticsLevel level)
Description copied from interface: ManagementStrategy
Sets the statistics level

Default is ManagementStatisticsLevel.All

Specified by:
setStatisticsLevel in interface ManagementStrategy
Parameters:
level - the new level

getStatisticsLevel

public ManagementStatisticsLevel getStatisticsLevel()
Description copied from interface: ManagementStrategy
Gets the statistics level

Specified by:
getStatisticsLevel in interface ManagementStrategy
Returns:
the level

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


Apache CAMEL