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 JmxOperationImplAllows you to dynamically connect to differentJMXServiceURLs 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
operationfor differentObjectNameinstances on differentJMXServiceURLs.- Since:
- 3.6.5
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_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 voidcloseService()voiddoService(AdaptrisMessage msg)Apply the service to the message.java.lang.StringgetJmxServiceUrl()java.lang.IntegergetMaxJmxConnectionCache()Get the max number of entries in the cache.ValueTranslatorgetResultValueTranslator()protected voidinitService()voidprepare()Prepare for initialisation.voidsetJmxServiceUrl(java.lang.String s)The JMX Service URL to target.voidsetMaxJmxConnectionCache(java.lang.Integer maxSize)Set the max number of entries in the cache.voidsetResultValueTranslator(ValueTranslator t)voidstart()Starts the component.voidstop()Stop the componentDynamicJmxOperationServicewithJmxServiceUrl(java.lang.String s)DynamicJmxOperationServicewithMaxJmxConnectionCache(java.lang.Integer i)DynamicJmxOperationServicewithObjectName(java.lang.String s)DynamicJmxOperationServicewithOperationName(java.lang.String s)DynamicJmxOperationServicewithOperationParameters(java.util.List<ValueTranslator> l)DynamicJmxOperationServicewithResultValueTranslator(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:ServiceApply the service to the message.
- Parameters:
msg- theAdaptrisMessageto process- Throws:
ServiceException- wrapping any underlyingExceptions
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Throws:
CoreException
-
initService
protected void initService() throws CoreException- Overrides:
initServicein classJmxOperationImpl- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeServicein classServiceImp
-
stop
public void stop()
Description copied from interface:ComponentLifecycleStop 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 aRuntimeExceptionmay cause unintended consequences- Specified by:
stopin interfaceComponentLifecycle- Overrides:
stopin classServiceImp
-
start
public void start() throws CoreExceptionDescription copied from interface:ComponentLifecycleStarts 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:
startin interfaceComponentLifecycle- Overrides:
startin classServiceImp- Throws:
CoreException- wrapping any underlyingExceptions
-
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)
-
-