Package org.jolokia.server.core.util.jmx
Interface MBeanServerAccess
- All Known Implementing Classes:
DefaultMBeanServerAccess,SingleMBeanServerAccess
public interface MBeanServerAccess
An MBeanSever executor is responsible to perform actions on one or more MBeanServers which involve
operations on one or more MBeans. It encapsulates completely all available MBeanServers, so no direct
access to the MBeanServers are required. This interface is also suitable for implementations with
remote
MBeanServerConnections, e.g. for implementing it with JSR-160 connections.- Since:
- 17.01.13
- Author:
- roland
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA MBeanAction represent a single action on a MBeanServer for a given object name.static interfaceThis callback is used together witheach(ObjectName, MBeanEachCallback)for iterating over all active MBeanServers. -
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.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
-
Method Details
-
each
void each(ObjectName pObjectName, MBeanServerAccess.MBeanEachCallback pCallback) throws IOException, ReflectionException, MBeanException Iterate 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.- 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
<R> R call(ObjectName pObjectName, MBeanServerAccess.MBeanAction<R> pMBeanAction, Object... pExtraArgs) throws IOException, ReflectionException, MBeanException, AttributeNotFoundException, InstanceNotFoundException 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. If no action was succesful, anIllegalArgumentExceptionis raised (containing the lastInstanceNotFoundExceptionfrom the last tried server)- 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
Query all MBeanServer and return the union of all results- 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.
-
hasMBeansListChangedSince
boolean hasMBeansListChangedSince(long pTimestamp) Check 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).- Parameters:
pTimestamp- seconds since 1.1.1970- Returns:
- true if the MBeans has been updated since this time, false otherwise
-
getMBeanServers
Set<MBeanServerConnection> getMBeanServers()Get all MBeanServers which are handled by this manager- Returns:
- set of MBeanServers to handle (in the proper merge order)
-