public abstract class MBeanHelper extends Base
Modifier and Type | Class and Description |
---|---|
static class |
MBeanHelper.QueryExpFilter
|
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
static Map<String,SimpleType> |
SCALAR_SIMPLETYPES
A map of scalar SimpleTypes (classes) keyed by the corresponding JMX signatures.
|
static Map<String,Class> |
SCALAR_TYPES
A map of scalar types (classes) keyed by the corresponding JMX signatures.
|
Constructor and Description |
---|
MBeanHelper() |
Modifier and Type | Method and Description |
---|---|
static int |
compareKeyList(ObjectName oname1,
ObjectName oname2)
Compare two
global MBean names
forcing numeric comparison of the node ID while using string comparison
on all other key properties. |
static DynamicMBean |
createMapAdapterMbean(Map<String,String> mapDescr,
Map<String,?> mapValue)
Create a DynamicMBean driven by maps containing attribute descriptions and
values.
|
static String |
ensureDomain(String sCanonical)
Ensure the Canonical name is prefixed with the domain name.
|
static MBeanReference |
ensureSingletonMBean(String sName)
Ensure that there is an instance of a local MBean of the specified type
registered with the default MBeansServer.
|
static JMXServiceURL |
findJMXServiceUrl(String sDefaultDomain,
com.tangosol.internal.net.management.GatewayDependencies deps)
Find the JMXServiceURL for the MBeanConnector used by the
Coherence JMX framework.
|
static MBeanServer |
findMBeanServer()
Find an MBeanServer that Coherence MBeans are registered with.
|
static MBeanServer |
findMBeanServer(String sDefaultDomain)
Find an MBeanServer that has the specified default domain name.
|
static MBeanServer |
findMBeanServer(String sDefaultDomain,
com.tangosol.internal.net.management.GatewayDependencies deps)
Find an MBeanServer that has the specified default domain name.
|
protected static Method |
findMethod(Class clzMBean,
MBeanOperationInfo op)
Find a
Method for the specified MBeanOperationInfo in
the specified MBean class or interface. |
protected static Method |
findMethod(Class clz,
String sName,
String... asParamTypes)
Find a
Method with the specified name and parameter types in
the specified class. |
static String |
getDefaultDomain()
Return the the default domain name as configured in the Coherence
operational configuration descriptor ("default-domain-name" element).
|
static String |
getDescription(Class<?> clzMBeanIface,
MBeanInfo info)
Retrieve the description for the MBean from the MBean interface annotation.
|
static String |
getDescription(Class clzMBeanIface,
MBeanAttributeInfo info)
Retrieve a description for a particular attribute by finding a
Description annotation on the getter method for the attribute. |
static String |
getDescription(Class clzMBeanIface,
MBeanOperationInfo info)
Retrieve a description for the particular
MBeanOperationInfo by
finding a Description annotation on the corresponding method. |
static MBeanNotificationInfo[] |
getNotificationInfo(Class<?> clzMBeanIface)
Return an
MBeanNotificationInfo if a Notification
annotation is present on the provided MBean interface. |
protected static <A extends Annotation> |
getParameterAnnotation(Method meth,
int iParam,
Class<A> clzAnno)
Retrieve an
Annotation for a parameter to a method. |
static String |
getParameterName(Class clzMBeanIface,
MBeanOperationInfo infoOp,
MBeanParameterInfo infoParam,
int iParam)
Retrieve the parameter name for the specified parameter by finding a
Description annotation on the corresponding method. |
static boolean |
hasDomain(String sCanonical)
Return true if the Canonical name is prefixed with the domain name.
|
static boolean |
isQuoteRequired(String s)
Determine if the string requires quotes.
|
static boolean |
isQuoteRequired(String s,
boolean fKey)
Determine if the string requires quotes.
|
static String |
quote(String s)
Create an escape-sequence string that allows for special characters to
be included in a JMX ObjectName.
|
protected static String |
quote(String s,
boolean fKey)
Create an escape-sequence string that allows for special characters to
be included in a JMX ObjectName.
|
static String |
quoteCanonical(String sCanonical)
Return a quoted
KeyPropertyString
or a quoted canonical name. |
static void |
registerCacheMBean(CacheService service,
String sCacheName,
String sContext,
Map map)
Register the specified map with the cluster registry.
|
static void |
registerCacheMBean(NamedCache cache,
String sContext)
Register the specified NamedCache with the cluster registry.
|
static void |
registerQueryMBeans(String sMBeanServerDomain,
String sQuery,
String sPrefix,
Registry registry)
Find all MBeans matching to the specified query at a local MBeanServer and
register them with the specified Registry.
|
static String |
safeUnquote(String s)
Unquote a string iff given string is quoted otherwise return original string.
|
static Object |
startHttpConnector(int nPort,
MBeanServer mbs)
Start a com.sun.jdmk.comm.HtmlAdaptorServer, which is a part of
the Sun JMX reference implementation.
|
static JMXConnectorServer |
startRmiConnector(String sAddr,
int nRegPort,
int nConPort,
MBeanServer mbs,
Map mapEnv)
Start a
JMXConnectorServer . |
static String |
stripDomain(String sCanonical)
Remove the domain prefix from the canonical name if one exists.
|
static String |
unquote(String s)
Convert a string returned from the
quote(java.lang.String) method to the original
string. |
static void |
unregisterCacheMBean(CacheService service,
String sCacheName)
Unregister all managed objects that are related to the specified cache
from the registry.
|
static void |
unregisterCacheMBean(CacheService service,
String sCacheName,
String sContext)
Unregister all managed objects that are related to the specified cache
from the registry.
|
static void |
unregisterCacheMBean(Cluster cluster,
String sServiceName,
String sCacheName,
String sContext)
Unregister all managed objects that are related to the specified cache
from the registry.
|
static void |
unregisterCacheMBean(NamedCache cache,
String sContext)
Unregister all managed objects related to the given cache name and
context from the cluster registry.
|
static void |
unregisterCacheMBean(String sCacheName,
String sContext)
Unregister all managed objects related to the given cache name and
context from the cluster registry.
|
static void |
unregisterCacheMBean(String sServiceName,
String sCacheName,
String sContext)
Unregister all managed objects that are related to the specified cache
from the registry.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
public static final Map<String,Class> SCALAR_TYPES
public static final Map<String,SimpleType> SCALAR_SIMPLETYPES
public static String getDefaultDomain()
public static MBeanServer findMBeanServer()
public static MBeanServer findMBeanServer(String sDefaultDomain)
sDefaultDomain
- the default domain namepublic static MBeanServer findMBeanServer(String sDefaultDomain, com.tangosol.internal.net.management.GatewayDependencies deps)
sDefaultDomain
- the default domain namedeps
- the GatewayDependencies
containing the
management configuration to usepublic static JMXServiceURL findJMXServiceUrl(String sDefaultDomain, com.tangosol.internal.net.management.GatewayDependencies deps)
sDefaultDomain
- the default domain namedeps
- the GatewayDependencies
containing the
management configuration to usepublic static void registerQueryMBeans(String sMBeanServerDomain, String sQuery, String sPrefix, Registry registry)
Note: the MBeanServer that the query runs against is not necessarily the one used by the Registry.
sMBeanServerDomain
- the default domain of the MBeanServer where the
query should be executed. If this value is empty
or null the Coherence default domain is usedsQuery
- a JMX query string that will be used to find
the MBeanssPrefix
- a target location to prepend to converted MBean namesregistry
- a Registry to register the JMX query results withpublic static void registerCacheMBean(NamedCache cache, String sContext)
cache
- the NamedCache object to registersContext
- the cache context (tier)public static void registerCacheMBean(CacheService service, String sCacheName, String sContext, Map map)
service
- the CacheService that the cache belongs tosCacheName
- the cache namesContext
- the cache context (tier)map
- the map object to registerpublic static void unregisterCacheMBean(CacheService service, String sCacheName)
service
- the CacheService that the cache belongs tosCacheName
- the cache namepublic static void unregisterCacheMBean(String sServiceName, String sCacheName, String sContext)
sServiceName
- the CacheService namesCacheName
- the cache namesContext
- the cache context (tier)public static void unregisterCacheMBean(CacheService service, String sCacheName, String sContext)
service
- the CacheService that the cache belongs tosCacheName
- the cache namesContext
- the cache context (tier)public static void unregisterCacheMBean(Cluster cluster, String sServiceName, String sCacheName, String sContext)
cluster
- the Cluster objectsServiceName
- the CacheService that the cache belongs tosCacheName
- the cache namesContext
- the cache context (tier)public static void unregisterCacheMBean(String sCacheName, String sContext)
sCacheName
- the cache namesContext
- the cache context (tier)public static void unregisterCacheMBean(NamedCache cache, String sContext)
cache
- the cachesContext
- the cache context (tier)public static MBeanReference ensureSingletonMBean(String sName)
sName
- an MBean namepublic static DynamicMBean createMapAdapterMbean(Map<String,String> mapDescr, Map<String,?> mapValue)
mapDescr
- Map<String, String> keyed by the attribute names with
values being attribute descriptionsmapValue
- Map<String, Object> keyed by the attribute names with
values being attribute valuespublic static JMXConnectorServer startRmiConnector(String sAddr, int nRegPort, int nConPort, MBeanServer mbs, Map mapEnv)
JMXConnectorServer
. This method is used to expose the
specified MBeanServer to external agents (such as JConsole) using RMI.
This method also allows for the RMI functionality to emulate the JConsole remote connection security.
For the list of relevant system properties please see: Java 1.6 Agent Documentation.
sAddr
- host to bind tonRegPort
- port used for the JMX RMI registrynConPort
- port used for the JMX RMI connectionmbs
- MBeanServer
that contains Coherence MBeansmapEnv
- a set of attributes to control the new connector server's
behaviorJMXConnectorServerFactory
public static Object startHttpConnector(int nPort, MBeanServer mbs)
nPort
- port to bind the HTTP server tombs
- MBeanServer that this HTTP server will exposepublic static String quote(String s)
s
- the string to be quotedprotected static String quote(String s, boolean fKey)
s
- the string to be quotedfKey
- true if a key in the ObjectName is being quotedpublic static String safeUnquote(String s)
s
- the stringpublic static String unquote(String s)
quote(java.lang.String)
method to the original
string.s
- the string to be unquotedIllegalArgumentException
- if the passed string could not have
been returned by the quote(java.lang.String)
method; for instance
if it does not begin and end with a quote (")public static boolean isQuoteRequired(String s)
s
- the string to be quotedquote(java.lang.String)
method needs to be calledpublic static boolean isQuoteRequired(String s, boolean fKey)
s
- the string to be quotedfKey
- true if a key in the ObjectName is being quotedquote(java.lang.String)
method needs to be calledpublic static String quoteCanonical(String sCanonical) throws MalformedObjectNameException
KeyPropertyString
or a quoted canonical name. Wildcard and AnyCharacter (* and ? respectively)
are not escaped when present on the value of a key value pair.sCanonical
- a string to be quotedMalformedObjectNameException
- if the name is invalidpublic static boolean hasDomain(String sCanonical)
sCanonical
- a canonical MBean name or key property listpublic static String ensureDomain(String sCanonical)
sCanonical
- a canonical MBean name or key property listpublic static String stripDomain(String sCanonical)
sCanonical
- a canonical MBean name or key property listpublic static int compareKeyList(ObjectName oname1, ObjectName oname2)
global MBean names
forcing numeric comparison of the node ID while using string comparison
on all other key properties. For example, the following order is enforced:
Coherence:type=Node,nodeId=2 < Coherence:type=Node,nodeId=10 Coherence:type=Cache,nodeId=20 < Coherence:type=Node,nodeId=1If the key sets are different the lexicographical comparison is used.
oname1
- the first ObjectName to be comparedoname2
- the second ObjectName to be comparedpublic static String getDescription(Class<?> clzMBeanIface, MBeanInfo info)
clzMBeanIface
- the MBean interfaceinfo
- the MBeanInfo
for the MBeanpublic static String getDescription(Class clzMBeanIface, MBeanAttributeInfo info)
Description
annotation on the getter method for the attribute.
If a description is not found on the getter method, the setter will
be checked.clzMBeanIface
- the MBean interfaceinfo
- the MBeanAttributeInfo
for the attributepublic static String getDescription(Class clzMBeanIface, MBeanOperationInfo info)
MBeanOperationInfo
by
finding a Description
annotation on the corresponding method.clzMBeanIface
- the MBean interfaceinfo
- the MBeanOperationInfo
public static String getParameterName(Class clzMBeanIface, MBeanOperationInfo infoOp, MBeanParameterInfo infoParam, int iParam)
Description
annotation on the corresponding method.clzMBeanIface
- the MBean interfaceinfoOp
- the MBeanOperationInfo
for the opinfoParam
- the MBeanParameterInfo
for the parameteriParam
- zero-based sequence number of the parameterpublic static MBeanNotificationInfo[] getNotificationInfo(Class<?> clzMBeanIface)
MBeanNotificationInfo
if a Notification
annotation is present on the provided MBean interface.clzMBeanIface
- the MBean interfaceprotected static <A extends Annotation> A getParameterAnnotation(Method meth, int iParam, Class<A> clzAnno)
Annotation
for a parameter to a method.A
- the Annotation sub typemeth
- the Method
iParam
- zero-based index of the parameterclzAnno
- the Annotation Class
to be retrievedAnnotation
is foundprotected static Method findMethod(Class clzMBean, MBeanOperationInfo op)
Method
for the specified MBeanOperationInfo
in
the specified MBean class or interface.clzMBean
- the MBean class (interface)op
- the MBeanOperationInfo
Method
or null if no method is found