Package org.jolokia.server.core.util.jmx
Class SingleMBeanServerAccess
java.lang.Object
org.jolokia.server.core.util.jmx.SingleMBeanServerAccess
- All Implemented Interfaces:
MBeanServerAccess
A simple executor which uses only a single connection. It does not support
update change detection.
- Since:
- 14.01.14
- Author:
- roland
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jolokia.server.core.util.jmx.MBeanServerAccess
MBeanServerAccess.MBeanAction<R>, MBeanServerAccess.MBeanEachCallback -
Constructor Summary
ConstructorsConstructorDescriptionSingleMBeanServerAccess(MBeanServerConnection pConnection) Constructor for wrapping a remote connection -
Method Summary
Modifier and TypeMethodDescription<R> Rcall(ObjectName pObjectName, MBeanServerAccess.MBeanAction<R> pMBeanAction, Object... pExtraArgs) Call an action an the first MBeanServer on which the action does not throw an InstanceNotFoundException will considered to be successful and this method returns with the return value of the succesful action.voiddestroy()voideach(ObjectName pObjectName, MBeanServerAccess.MBeanEachCallback pCallback) Iterate over all MBeanServers managed and call the handler via a callback.Get all MBeanServers which are handled by this managerbooleanhasMBeansListChangedSince(long pTimestamp) Check whether the set of MBeans in all managed MBeanServer has been changed since the given time.queryNames(ObjectName pObjectName) Query all MBeanServer and return the union of all results
-
Constructor Details
-
SingleMBeanServerAccess
Constructor for wrapping a remote connection- Parameters:
pConnection- remote connection to wrap
-
-
Method Details
-
each
public void each(ObjectName pObjectName, MBeanServerAccess.MBeanEachCallback pCallback) throws IOException, ReflectionException, MBeanException Description copied from interface:MBeanServerAccessIterate over all MBeanServers managed and call the handler via a callback. If is null or a pattern, the MBean names are queried on each MBeanServer and feed into the callback. If it is a full object name, then all MBeanServers are called with this object name in turn.- Specified by:
eachin interfaceMBeanServerAccess- Parameters:
pObjectName- object name to lookup, which can be a pattern in which case a query is performed.pCallback- the action to be called for each MBean found on every server- Throws:
IOExceptionReflectionExceptionMBeanException
-
call
public <R> R call(ObjectName pObjectName, MBeanServerAccess.MBeanAction<R> pMBeanAction, Object... pExtraArgs) throws IOException, ReflectionException, MBeanException, AttributeNotFoundException, InstanceNotFoundException Description copied from interface:MBeanServerAccessCall an action an the first MBeanServer on which the action does not throw an InstanceNotFoundException will considered to be successful and this method returns with the return value of the succesful action. If no action was succesful, anIllegalArgumentExceptionis raised (containing the lastInstanceNotFoundExceptionfrom the last tried server)- Specified by:
callin interfaceMBeanServerAccess- Type Parameters:
R- type of the return value- Parameters:
pObjectName- objectname given through to the actionpMBeanAction- the action to callpExtraArgs- any extra args given also to the action- Returns:
- the return value of the succesful action
- Throws:
IOExceptionReflectionExceptionMBeanException- if the JMX call causes an issueAttributeNotFoundExceptionInstanceNotFoundException
-
queryNames
Description copied from interface:MBeanServerAccessQuery all MBeanServer and return the union of all results- Specified by:
queryNamesin interfaceMBeanServerAccess- Parameters:
pObjectName- pattern to query for. If null, then all MBean of all MBeanServers are returned- Returns:
- the found MBeans
- Throws:
IOException- if called remotely and an IOError occured.
-
destroy
public void destroy() -
hasMBeansListChangedSince
public boolean hasMBeansListChangedSince(long pTimestamp) Description copied from interface:MBeanServerAccessCheck whether the set of MBeans in all managed MBeanServer has been changed since the given time. The input is the epoch time in seconds, however, milliseconds would be much more appropriate. However, the Jolokia responses contain currently time measured in seconds. This should be changed in a future version, but this implies a quite heavy API changed (and if this is changed, the key "timestamp" should be changed to "time", too, in order to fail early in case of problems). In order to avoid inconsistencies for sub-second updates, we are comparing conservatively (so hasBeenUpdated might return "true" more often than required).- Specified by:
hasMBeansListChangedSincein interfaceMBeanServerAccess- Parameters:
pTimestamp- seconds since 1.1.1970- Returns:
- true if the MBeans has been updated since this time, false otherwise
-
getMBeanServers
Get all MBeanServers which are handled by this manager- Specified by:
getMBeanServersin interfaceMBeanServerAccess- Returns:
- set of MBeanServers to handle (in the proper merge order)
-