public class DefaultManagementStrategy extends ServiceSupport implements ManagementStrategy, CamelContextAware
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.ManagedManagementStrategy
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
DefaultManagementStrategy() |
DefaultManagementStrategy(CamelContext camelContext) |
Modifier and Type | Method and Description |
---|---|
void |
addEventNotifier(EventNotifier eventNotifier)
Adds the event notifier to use.
|
Statistic |
createStatistic(String name,
Object owner,
Statistic.UpdateMode updateMode) |
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStartManagementStrategy() |
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
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()
Deprecated.
|
boolean |
isLoadStatisticsEnabled()
Deprecated.
|
boolean |
isManaged(Object managedObject,
Object name)
Determines if an object or name is managed.
|
boolean |
isOnlyManageProcessorWithCustomId()
Deprecated.
|
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)
Deprecated.
|
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 |
setLoadStatisticsEnabled(boolean loadStatisticsEnabled)
Deprecated.
|
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)
Deprecated.
|
void |
unmanageNamedObject(Object name)
Removes a managed object by name.
|
void |
unmanageObject(Object managedObject)
Removes the managed object.
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public DefaultManagementStrategy()
public DefaultManagementStrategy(CamelContext camelContext)
public List<EventNotifier> getEventNotifiers()
ManagementStrategy
getEventNotifiers
in interface ManagementStrategy
public void addEventNotifier(EventNotifier eventNotifier)
ManagementStrategy
Service
, as otherwise
it would not be used.addEventNotifier
in interface ManagementStrategy
eventNotifier
- event notifierpublic boolean removeEventNotifier(EventNotifier eventNotifier)
ManagementStrategy
removeEventNotifier
in interface ManagementStrategy
eventNotifier
- event notifier to removepublic void setEventNotifiers(List<EventNotifier> eventNotifiers)
ManagementStrategy
setEventNotifiers
in interface ManagementStrategy
eventNotifiers
- list of event notifierspublic EventFactory getEventFactory()
ManagementStrategy
getEventFactory
in interface ManagementStrategy
public void setEventFactory(EventFactory eventFactory)
ManagementStrategy
setEventFactory
in interface ManagementStrategy
eventFactory
- event factorypublic ManagementNamingStrategy getManagementNamingStrategy()
ManagementStrategy
getManagementNamingStrategy
in interface ManagementStrategy
public void setManagementNamingStrategy(ManagementNamingStrategy managementNamingStrategy)
ManagementStrategy
setManagementNamingStrategy
in interface ManagementStrategy
managementNamingStrategy
- naming strategypublic ManagementObjectStrategy getManagementObjectStrategy()
ManagementStrategy
getManagementObjectStrategy
in interface ManagementStrategy
public void setManagementObjectStrategy(ManagementObjectStrategy managementObjectStrategy)
ManagementStrategy
setManagementObjectStrategy
in interface ManagementStrategy
managementObjectStrategy
- object strategypublic ManagementAgent getManagementAgent()
ManagementStrategy
getManagementAgent
in interface ManagementStrategy
public void setManagementAgent(ManagementAgent managementAgent)
ManagementStrategy
setManagementAgent
in interface ManagementStrategy
managementAgent
- management agent@Deprecated public void onlyManageProcessorWithCustomId(boolean flag)
ManagementStrategy
onlyManageProcessorWithCustomId
in interface ManagementStrategy
flag
- true will only manage if custom id was set.@Deprecated public boolean isOnlyManageProcessorWithCustomId()
ManagementStrategy
isOnlyManageProcessorWithCustomId
in interface ManagementStrategy
public boolean manageProcessor(ProcessorDefinition<?> definition)
ManagementStrategy
manageProcessor
in interface ManagementStrategy
definition
- definition of the processorpublic void manageObject(Object managedObject) throws Exception
ManagementStrategy
manageObject
in interface ManagementStrategy
managedObject
- the managed objectException
- can be thrown if the object could not be addedpublic void manageNamedObject(Object managedObject, Object preferredName) throws Exception
ManagementStrategy
manageNamedObject
in interface ManagementStrategy
managedObject
- the managed objectpreferredName
- representing the preferred name, maybe a String, or a JMX ObjectNameException
- can be thrown if the object could not be addedpublic <T> T getManagedObjectName(Object managedObject, String customName, Class<T> nameType) throws Exception
ManagementStrategy
getManagedObjectName
in interface ManagementStrategy
managedObject
- the object to be managedcustomName
- a custom name componentnameType
- the name type requiredException
- can be thrown if the object name could not be createdpublic void unmanageObject(Object managedObject) throws Exception
ManagementStrategy
unmanageObject
in interface ManagementStrategy
managedObject
- the managed objectException
- can be thrown if the object could not be removedpublic void unmanageNamedObject(Object name) throws Exception
ManagementStrategy
unmanageNamedObject
in interface ManagementStrategy
name
- an object name previously created by this strategy.Exception
- can be thrown if the object could not be removedpublic boolean isManaged(Object managedObject, Object name)
ManagementStrategy
isManaged
in interface ManagementStrategy
managedObject
- the object to considername
- the name to considerpublic CamelContext getCamelContext()
CamelContextAware
CamelContext
getCamelContext
in interface CamelContextAware
public void setCamelContext(CamelContext camelContext)
CamelContextAware
CamelContext
setCamelContext
in interface CamelContextAware
camelContext
- the Camel contextpublic void notify(EventObject event) throws Exception
ManagementStrategy
notify
in interface ManagementStrategy
event
- the eventException
- can be thrown if the notification failedpublic Statistic createStatistic(String name, Object owner, Statistic.UpdateMode updateMode)
@Deprecated public void setStatisticsLevel(ManagementStatisticsLevel level)
ManagementStrategy
ManagementStatisticsLevel.Default
setStatisticsLevel
in interface ManagementStrategy
level
- the new level@Deprecated public ManagementStatisticsLevel getStatisticsLevel()
ManagementStrategy
getStatisticsLevel
in interface ManagementStrategy
@Deprecated public boolean isLoadStatisticsEnabled()
ManagementStrategy
isLoadStatisticsEnabled
in interface ManagementStrategy
@Deprecated public void setLoadStatisticsEnabled(boolean loadStatisticsEnabled)
ManagementStrategy
setLoadStatisticsEnabled
in interface ManagementStrategy
loadStatisticsEnabled
- true to enable load statisticsprotected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStartManagementStrategy() throws Exception
Exception
protected void doStop() throws Exception
ServiceSupport
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.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
Apache Camel