Class DynamicJmxOperationService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.jmx.JmxOperationImpl
-
- com.adaptris.core.services.jmx.DynamicJmxOperationService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Execute a JMX operation", tag="service,jmx", since="3.6.5") public class DynamicJmxOperationService extends JmxOperationImpl
Allows you to dynamically connect to differentJMXServiceURL
s and execute JMX Operations.Note that because of the dynamic nature of this service, it does not support username/password/jmx-environment that are supported by
JmxConnection
. If it can be defined in the URL, then it should be (e.g. jmx+jms rather than jmxmp). A small (configurable) cache of connections is kept for performance reasons. This is emptied whenever the service is stopped.Note that parameters are not configurable in the same way, so this is really designed for calling the same
operation
for differentObjectName
instances on differentJMXServiceURL
s.- Since:
- 3.6.5
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_CACHE_SIZE
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description DynamicJmxOperationService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeService()
void
doService(AdaptrisMessage msg)
Apply the service to the message.java.lang.String
getJmxServiceUrl()
java.lang.Integer
getMaxJmxConnectionCache()
Get the max number of entries in the cache.ValueTranslator
getResultValueTranslator()
protected void
initService()
void
prepare()
Prepare for initialisation.void
setJmxServiceUrl(java.lang.String s)
The JMX Service URL to target.void
setMaxJmxConnectionCache(java.lang.Integer maxSize)
Set the max number of entries in the cache.void
setResultValueTranslator(ValueTranslator t)
void
start()
Starts the component.void
stop()
Stop the componentDynamicJmxOperationService
withJmxServiceUrl(java.lang.String s)
DynamicJmxOperationService
withMaxJmxConnectionCache(java.lang.Integer i)
DynamicJmxOperationService
withObjectName(java.lang.String s)
DynamicJmxOperationService
withOperationName(java.lang.String s)
DynamicJmxOperationService
withOperationParameters(java.util.List<ValueTranslator> l)
DynamicJmxOperationService
withResultValueTranslator(ValueTranslator t)
-
Methods inherited from class com.adaptris.core.services.jmx.JmxOperationImpl
getObjectName, getOperationName, getOperationParameters, parametersToArray, parametersToTypeArray, setObjectName, setOperationName, setOperationParameters
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
-
-
-
Field Detail
-
DEFAULT_MAX_CACHE_SIZE
public static final int DEFAULT_MAX_CACHE_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:Service
Apply the service to the message.
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
initService
protected void initService() throws CoreException
- Overrides:
initService
in classJmxOperationImpl
- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
- Overrides:
stop
in classServiceImp
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Specified by:
start
in interfaceComponentLifecycle
- Overrides:
start
in classServiceImp
- Throws:
CoreException
- wrapping any underlyingException
s
-
getJmxServiceUrl
public java.lang.String getJmxServiceUrl()
-
setJmxServiceUrl
public void setJmxServiceUrl(java.lang.String s)
The JMX Service URL to target.- Parameters:
s
- the jmxservice url.
-
getResultValueTranslator
public ValueTranslator getResultValueTranslator()
-
setResultValueTranslator
public void setResultValueTranslator(ValueTranslator t)
-
getMaxJmxConnectionCache
public java.lang.Integer getMaxJmxConnectionCache()
Get the max number of entries in the cache.- Returns:
- the maximum number of entries.
-
setMaxJmxConnectionCache
public void setMaxJmxConnectionCache(java.lang.Integer maxSize)
Set the max number of entries in the cache.Entries will be removed on a least recently accessed basis.
- Parameters:
maxSize
- the maximum number of entries, default is 16
-
withResultValueTranslator
public DynamicJmxOperationService withResultValueTranslator(ValueTranslator t)
-
withJmxServiceUrl
public DynamicJmxOperationService withJmxServiceUrl(java.lang.String s)
-
withMaxJmxConnectionCache
public DynamicJmxOperationService withMaxJmxConnectionCache(java.lang.Integer i)
-
withOperationName
public DynamicJmxOperationService withOperationName(java.lang.String s)
-
withObjectName
public DynamicJmxOperationService withObjectName(java.lang.String s)
-
withOperationParameters
public DynamicJmxOperationService withOperationParameters(java.util.List<ValueTranslator> l)
-
-