Package org.jolokia.server.detector.jee
Class AbstractServerDetector
java.lang.Object
org.jolokia.server.detector.jee.AbstractServerDetector
- All Implemented Interfaces:
Comparable<org.jolokia.server.core.detector.ServerDetector>,org.jolokia.server.core.detector.ServerDetector,org.jolokia.server.core.service.api.JolokiaService<org.jolokia.server.core.detector.ServerDetector>
- Direct Known Subclasses:
AbstractOsgiServerDetector,ActiveMQDetector,ArtemisDetector,GeronimoDetector,GlassfishDetector,JBossDetector,JettyDetector,LightstreamerDetector,TomcatDetector,WeblogicDetector,WebsphereDetector
public abstract class AbstractServerDetector
extends Object
implements org.jolokia.server.core.detector.ServerDetector
Base class for server detectors.
- Since:
- 05.11.10
- Author:
- roland
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jolokia.server.core.service.api.JolokiaService
org.jolokia.server.core.service.api.JolokiaService.Init -
Field Summary
Fields inherited from interface org.jolokia.server.core.detector.ServerDetector
FALLBACK -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractServerDetector(String pName, int pOrder) The order of this detector -
Method Summary
Modifier and TypeMethodDescriptionprotected voidactiveWait(Instrumentation instrumentation, Supplier<Boolean> checker, String failedMessageFormat) A helper for dedicated detectors that implements active-waiting loopintcompareTo(org.jolokia.server.core.detector.ServerDetector pDetector) voiddestroy()booleanprotected StringgetAttributeValue(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerAccess, String pMBean, String pAttribute) Get the string representation of an attributeprotected StringgetAttributeValue(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerAccess, ObjectName pMBean, String pAttribute) Get the string representation of an attributeprotected Class<?>getClassLoaded(String className, Instrumentation instrumentation) Just likeisClassLoaded(java.lang.String, java.lang.instrument.Instrumentation)but returns the loaded class instead of a booleanprotected Objectorg.jolokia.server.core.service.container.ContainerLocatorgetContainerLocator(org.jolokia.server.core.service.api.LogHandler logHandler) protected intA final delay between ending the active-wait loop.protected intA wait (in ms) between active-loop waiting cycles.protected intIf a detector requires an active-wait loop, this is the total timeout (in ms).getName()intgetOrder()org.jolokia.server.core.service.request.RequestInterceptorgetRequestInterceptor(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerAccess) protected StringgetSingleStringAttribute(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerAccess, String pMBeanName, String pAttribute) Get a single attribute for a given MBeanName pattern.protected StringgetVersionFromJsr77(org.jolokia.server.core.util.jmx.MBeanServerAccess pMbeanServers) Get the version number from a JSR-77 compliant serverinthashCode()voidvoidinit(org.jolokia.server.core.service.api.JolokiaContext pJolokiaContext) protected booleanisClassLoaded(String className, Instrumentation instrumentation) Tests if the given class name has been loaded by the JVM.booleanisEnabled(org.jolokia.server.core.service.api.JolokiaContext pContext) jvmAgentStartup(Instrumentation instrumentation) By default do nothing during JVM agent startupprotected booleanmBeanExists(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerManger, String pObjectName) Check whether a certain MBean existsprotected Set<ObjectName>searchMBeans(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerAccess, String pMbeanPattern) Check for the existence of a certain MBean.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jolokia.server.core.detector.ServerDetector
detect, getType
-
Constructor Details
-
AbstractServerDetector
The order of this detector- Parameters:
pOrder- detector's order
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceorg.jolokia.server.core.detector.ServerDetector
-
init
- Specified by:
initin interfaceorg.jolokia.server.core.detector.ServerDetector
-
destroy
public void destroy()- Specified by:
destroyin interfaceorg.jolokia.server.core.service.api.JolokiaService<org.jolokia.server.core.detector.ServerDetector>
-
init
public void init(org.jolokia.server.core.service.api.JolokiaContext pJolokiaContext) - Specified by:
initin interfaceorg.jolokia.server.core.service.api.JolokiaService<org.jolokia.server.core.detector.ServerDetector>
-
isEnabled
public boolean isEnabled(org.jolokia.server.core.service.api.JolokiaContext pContext) - Specified by:
isEnabledin interfaceorg.jolokia.server.core.service.api.JolokiaService<org.jolokia.server.core.detector.ServerDetector>
-
getConfig
-
searchMBeans
protected Set<ObjectName> searchMBeans(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerAccess, String pMbeanPattern) Check for the existence of a certain MBean. All known MBeanServers are queried- Parameters:
pMBeanServerAccess- mbean servers to query forpMbeanPattern- MBean name pattern for MBeans to check for- Returns:
- set of
ObjectNames if the pattern matches, or an empty set if not mbean has been found
-
mBeanExists
protected boolean mBeanExists(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerManger, String pObjectName) Check whether a certain MBean exists- Parameters:
pMBeanServerManger- set of MBeanServers to query forpObjectName- the objectname to check. Can be a pattern in which case this method return true if one or more MBeans of all MBeanServers match this pattern- Returns:
- true if at least one MBean of the given name (or pattern) exists
-
getAttributeValue
protected String getAttributeValue(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerAccess, String pMBean, String pAttribute) Get the string representation of an attribute- Parameters:
pMBeanServerAccess- set of MBeanServers to query. The first one wins.pMBean- object name of MBean to lookuppAttribute- attribute to lookup- Returns:
- string value of attribute or
nullif the attribute could not be fetched
-
getAttributeValue
protected String getAttributeValue(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerAccess, ObjectName pMBean, String pAttribute) Get the string representation of an attribute- Parameters:
pMBeanServerAccess- set of MBeanServers to query. The first one wins.pMBean- name of MBean to lookuppAttribute- attribute to lookup- Returns:
- string value of attribute or
nullif the attribute could not be fetched
-
getSingleStringAttribute
protected String getSingleStringAttribute(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerAccess, String pMBeanName, String pAttribute) Get a single attribute for a given MBeanName pattern.- Parameters:
pMBeanServerAccess- MBeanServer manager to querypMBeanName- a MBean name or pattern. If multiple MBeans are found, each is queried for the attributepAttribute- the attribute to lookup- Returns:
- the string value of the attribute or null if either no MBeans could be found, or 0 or more than 1 attribute are found on those mbeans
-
getVersionFromJsr77
protected String getVersionFromJsr77(org.jolokia.server.core.util.jmx.MBeanServerAccess pMbeanServers) Get the version number from a JSR-77 compliant server- Parameters:
pMbeanServers- servers to query- Returns:
- version number or null if not found.
-
getMBeanServers
- Specified by:
getMBeanServersin interfaceorg.jolokia.server.core.detector.ServerDetector
-
getRequestInterceptor
public org.jolokia.server.core.service.request.RequestInterceptor getRequestInterceptor(org.jolokia.server.core.util.jmx.MBeanServerAccess pMBeanServerAccess) - Specified by:
getRequestInterceptorin interfaceorg.jolokia.server.core.detector.ServerDetector
-
compareTo
public int compareTo(org.jolokia.server.core.detector.ServerDetector pDetector) - Specified by:
compareToin interfaceComparable<org.jolokia.server.core.detector.ServerDetector>
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.jolokia.server.core.service.api.JolokiaService<org.jolokia.server.core.detector.ServerDetector>- Specified by:
getOrderin interfaceorg.jolokia.server.core.detector.ServerDetector
-
equals
-
hashCode
public int hashCode() -
jvmAgentStartup
By default do nothing during JVM agent startup- Specified by:
jvmAgentStartupin interfaceorg.jolokia.server.core.detector.ServerDetector
-
getContainerLocator
public org.jolokia.server.core.service.container.ContainerLocator getContainerLocator(org.jolokia.server.core.service.api.LogHandler logHandler) - Specified by:
getContainerLocatorin interfaceorg.jolokia.server.core.detector.ServerDetector
-
isClassLoaded
Tests if the given class name has been loaded by the JVM. Don't use this method in case you have access to the class loader which will be loading the class because the used approach is not very efficient.- Parameters:
className- the name of the class to checkinstrumentation-- Returns:
- true if the class has been loaded by the JVM
- Throws:
IllegalArgumentException- in case instrumentation or the provided class is null
-
getClassLoaded
Just likeisClassLoaded(java.lang.String, java.lang.instrument.Instrumentation)but returns the loaded class instead of a boolean- Parameters:
className-instrumentation-- Returns:
-
getDetectionTimeout
protected int getDetectionTimeout()If a detector requires an active-wait loop, this is the total timeout (in ms). If-1, it means the waiting is disabled. But given detector has to actively invoke waiting code.- Returns:
-
getDetectionInterval
protected int getDetectionInterval()A wait (in ms) between active-loop waiting cycles.- Returns:
-
getDetectionFinalDelay
protected int getDetectionFinalDelay()A final delay between ending the active-wait loop.- Returns:
-
activeWait
protected void activeWait(Instrumentation instrumentation, Supplier<Boolean> checker, String failedMessageFormat) A helper for dedicated detectors that implements active-waiting loop- Parameters:
instrumentation-checker-failedMessageFormat- a message format with a placeholder for total timeout used to format exception message for failed active-wait loop.
-