public abstract class ComponentManagerImpl<E extends StateManagedComponent> extends javax.management.NotificationBroadcasterSupport implements AdapterRuntimeComponent<E>
Modifier and Type | Class and Description |
---|---|
protected static class |
ComponentManagerImpl.ComponentNotificationType |
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log |
ADAPTER_PREFIX, CHANNEL_PREFIX, EQUALS, ID_PREFIX, JMX_ADAPTER_TYPE, JMX_CHANNEL_TYPE, JMX_CONSUMER_MONITOR_TYPE, JMX_DOMAIN_NAME, JMX_FAILED_MESSAGE_RETRIER_TYPE, JMX_FS_MONITOR_TYPE, JMX_INFLIGHT_TYPE, JMX_LOG_HANDLER_TYPE, JMX_METRICS_TYPE, JMX_MSG_ERR_DIGESTER_TYPE, JMX_NOTIFIER_TYPE, JMX_RETRY_MONITOR_TYPE, JMX_WORKFLOW_TYPE, KEY_ADAPTER, KEY_CHANNEL, KEY_ID, KEY_WORKFLOW, NOTIF_MSG_CLOSED, NOTIF_MSG_CONFIG_UPDATED, NOTIF_MSG_INITIALISED, NOTIF_MSG_RESTARTED, NOTIF_MSG_STARTED, NOTIF_MSG_STOPPED, NOTIF_TYPE_ADAPTER_CONFIG, NOTIF_TYPE_ADAPTER_LIFECYCLE, NOTIF_TYPE_CHANNEL_CONFIG, NOTIF_TYPE_CHANNEL_LIFECYCLE, NOTIF_TYPE_WORKFLOW_CONFIG, NOTIF_TYPE_WORKFLOW_LIFECYCLE, PROPERTY_SEPARATOR, WORKFLOW_PREFIX
Constructor and Description |
---|
ComponentManagerImpl() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
asXml(java.lang.Object o)
Marshal the object as XML.
|
protected abstract void |
checkTransitionTo(ComponentState futureState)
Check whether the transition is allowed in the context of the current component's (or parent's) state.
|
protected void |
closeQuietly(AdaptrisComponent c) |
protected javax.management.Notification |
createLifecycleNotification(java.lang.String message,
javax.management.ObjectName objectName) |
protected void |
ensureState(ComponentState... states) |
ComponentState |
getComponentState()
Get the state of this managed runtime component.
|
java.lang.String |
getConfiguration()
Get a marshalled copy of the configuration for this item.
|
protected abstract java.lang.String |
getNotificationType(ComponentManagerImpl.ComponentNotificationType type) |
java.lang.String |
getUniqueId()
Get the name of this runtime component.
|
java.lang.String |
getWrappedComponentClassname()
Get the class name that is wrapped by this MBean.
|
protected void |
marshalAndSendNotification()
Store the XML representation of the object and send a config-update notification.
|
protected void |
marshalConfig()
Store the XML representation of the object.
|
protected void |
registerSelf()
Convenience method to handle
BaseComponentMBean.registerMBean() |
void |
requestClose()
Close this component.
|
void |
requestClose(long timeout)
Close this component.
|
void |
requestInit()
Initialise this component.
|
void |
requestInit(long timeout)
Initialise this component.
|
void |
requestRestart()
Restart this channel.
|
void |
requestRestart(long timeout)
Restart this component.
|
void |
requestStart()
Start this component.
|
void |
requestStart(long timeout)
Start this component.
|
void |
requestStop()
stop this component.
|
void |
requestStop(long timeout)
Stop this component.
|
protected void |
sendConfigUpdateNotification() |
protected void |
unregisterSelf()
Convenience method to handle
BaseComponentMBean.unregisterMBean() |
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAllDescendants, getWrappedComponent
requestStartTime, requestStopTime
createObjectName, registerMBean, unregisterMBean
protected abstract void checkTransitionTo(ComponentState futureState) throws CoreException, java.lang.IllegalArgumentException
futureState
- the state we want to transition to.CoreException
- if the state transition check fails.java.lang.IllegalArgumentException
- - if the futureState could not be handled.public java.lang.String getUniqueId()
AdapterComponentMBean
getUniqueId
in interface AdapterComponentMBean
Workflow.getUniqueId()
or Channel.getUniqueId()
public ComponentState getComponentState()
AdapterComponentMBean
getComponentState
in interface AdapterComponentMBean
public void requestInit() throws CoreException
AdapterComponentMBean
requestInit
in interface AdapterComponentMBean
CoreException
- wrapping any underlying Exceptionpublic void requestInit(long timeout) throws CoreException, java.util.concurrent.TimeoutException
AdapterComponentMBean
A timeout is required as Connections within the adapter may be configured to retry forever (if a broker is not available for instance) which would cause this method to never return.
requestInit
in interface AdapterComponentMBean
timeout
- the max timeout to wait for in millisecondsCoreException
- wrapping any underlying adapter exceptionjava.util.concurrent.TimeoutException
- if the timeout was exceeded.public void requestStart() throws CoreException
AdapterComponentMBean
requestStart
in interface AdapterComponentMBean
CoreException
- wrapping any underlying Exceptionpublic void requestStart(long timeout) throws CoreException, java.util.concurrent.TimeoutException
AdapterComponentMBean
A timeout is required as Connections within the adapter may be configured to retry forever (if a broker is not available for instance) which would cause this method to never return.
requestStart
in interface AdapterComponentMBean
timeout
- the max timeout to wait for in millisecondsCoreException
- wrapping any underlying adapter exceptionjava.util.concurrent.TimeoutException
- if the timeout was exceeded.public void requestStop() throws CoreException
AdapterComponentMBean
requestStop
in interface AdapterComponentMBean
CoreException
- wrapping any underlying Exceptionpublic void requestStop(long timeout) throws CoreException, java.util.concurrent.TimeoutException
AdapterComponentMBean
A timeout is required as Connections within the adapter may be configured to retry forever (if a broker is not available for instance) which would cause this method to never return.
requestStop
in interface AdapterComponentMBean
timeout
- the max timeout to wait for in millisecondsCoreException
- wrapping any underlying adapter exceptionjava.util.concurrent.TimeoutException
- if the timeout was exceeded.public void requestClose() throws CoreException
AdapterComponentMBean
requestClose
in interface AdapterComponentMBean
CoreException
- wrapping any underlying Exceptionpublic void requestClose(long timeout) throws CoreException, java.util.concurrent.TimeoutException
AdapterComponentMBean
A timeout is required as Connections within the adapter may be configured to retry forever (if a broker is not available for instance) which would cause this method to never return.
requestClose
in interface AdapterComponentMBean
timeout
- the max timeout to wait for in millisecondsCoreException
- wrapping any underlying adapter exceptionjava.util.concurrent.TimeoutException
- if the timeout was exceeded.public void requestRestart() throws CoreException
AdapterComponentMBean
This is semantically equivalent to calling AdapterComponentMBean.requestClose()
and AdapterComponentMBean.requestStart()
requestRestart
in interface AdapterComponentMBean
CoreException
- wrapping any underlying Exceptionpublic void requestRestart(long timeout) throws CoreException, java.util.concurrent.TimeoutException
AdapterComponentMBean
This just invokes AdapterComponentMBean.requestClose(long)
and AdapterComponentMBean.requestStart(long)
in sequence with the timeoutMs parameter. Bear in
mind that a TimeoutException
may not occur until 2 * timeoutMs depending on how long the component takes to close and
start.
requestRestart
in interface AdapterComponentMBean
timeout
- the max timeout to pass into AdapterComponentMBean.requestClose(long)
and AdapterComponentMBean.requestStart(long)
in ms. This means
that a TimeoutException
might not occur until 2 * timeoutMs.CoreException
- wrapping any underlying adapter exceptionjava.util.concurrent.TimeoutException
- if the timeout was exceeded.protected java.lang.String asXml(java.lang.Object o) throws CoreException
CoreException
public java.lang.String getConfiguration() throws CoreException
AdapterComponentMBean
getConfiguration
in interface AdapterComponentMBean
CoreException
- wrapping any underlying ExceptionDefaultMarshaller.getDefaultMarshaller()
public java.lang.String getWrappedComponentClassname()
AdapterRuntimeComponent
getWrappedComponentClassname
in interface AdapterComponentMBean
getWrappedComponentClassname
in interface AdapterRuntimeComponent<E extends StateManagedComponent>
com.adaptris.core.StandardWorkflow
)protected void marshalConfig() throws CoreException
Note that this does not send any notifications, and is only intended for use upon first initialisation; you should probably use
marshalAndSendNotification()
if the config has been updated at runtime.
CoreException
protected void marshalAndSendNotification() throws CoreException
CoreException
protected void unregisterSelf() throws CoreException
BaseComponentMBean.unregisterMBean()
CoreException
protected void registerSelf() throws CoreException
BaseComponentMBean.registerMBean()
CoreException
protected void ensureState(ComponentState... states)
protected javax.management.Notification createLifecycleNotification(java.lang.String message, javax.management.ObjectName objectName)
protected void sendConfigUpdateNotification()
protected abstract java.lang.String getNotificationType(ComponentManagerImpl.ComponentNotificationType type)
protected void closeQuietly(AdaptrisComponent c)