@Taxonomy(stability=UNCOMMITTED) public final class Util extends Object
Modifier and Type | Field and Description |
---|---|
static String |
TYPE_FIELD
Proxy interfaces may contain a type field denoting the type to be used in the ObjectName;
this is an alternative to an annotation that may be desirable to avoid
a dependency on the amx-core module.
|
Modifier and Type | Method and Description |
---|---|
static AMXProxy |
asAMX(Object o)
A safe way to cast to AMX.
|
static <T extends AMXProxy> |
asProxyList(Collection<? extends AMXProxy> c,
Class<T> intf) |
static String |
concatenateProps(String props1,
String props2) |
static String |
concatenateProps(String props1,
String props2,
String props3) |
static <T extends AMXProxy> |
createNameMap(Set<T> amxs)
Create a Map keyed by the value of the NAME_KEY with
value the AMX item.
|
static Map<String,ObjectName> |
createObjectNameMap(Set<ObjectName> objectNames)
Create a Map keyed by the value of the NAME_KEY with
value the ObjectName.
|
static String |
deduceType(Class<?> intf)
Deduce the type to be used in the path.
|
static <T extends AMXProxy> |
filterAMX(Map<String,T> candidates,
Class<?> desired)
Filter the AMX dynamic proxies to those that implement the specified interface,
and return a new Map with the matching items.
|
static <T extends AMXProxy> |
filterAMX(Set<T> candidates,
Class<?> desired)
Filter the AMX dynamic proxies to those that implement the specified interface,
and return a new Set with the matching items.
|
static Map<String,ObjectName> |
filterByType(ObjectName[] objectNames,
String type) |
static String |
getAdditionalProps(ObjectName objectName)
Extract all properties other than type=
|
static Map<String,Serializable> |
getAMXNotificationData(Notification notif)
All Notifications emitted by AMX MBeans which are not
standard types defined by JMX place a Map
into the userData field of the Notification.
|
static Serializable |
getAMXNotificationValue(Notification notif,
String key)
Use of generic type form taking Class
|
static <T extends Serializable> |
getAMXNotificationValue(Notification notif,
String key,
Class<T> theClass)
Retrieve a particular value associated with the specified
key from an AMX Notification.
|
static ObjectName |
getAncestorByType(MBeanServer mbeanServer,
ObjectName child,
String type) |
static String |
getNameProp(ObjectName objectName)
Get the value of the NAME_KEY property within the ObjectName, or null if
not present.
|
static ObjectName |
getParent(MBeanServer server,
ObjectName objectName) |
static String |
getParentPathProp(AMXProxy amx) |
static String |
getParentPathProp(ObjectName objectName) |
static String |
getSelfProp(ObjectName objectName)
Extract the type and name properties and return it as a single property
type=name
|
static String |
getTypeProp(ObjectName objectName) |
static String |
makeNameProp(String name)
Make an ObjectName property of the form name=value.
|
static String |
makeProp(String name,
String value)
Make an ObjectName property of the form name=value.
|
static String |
makeRequiredProps(String type,
String name) |
static String |
makeTypeProp(String value)
Make an ObjectName property of the form type=value.
|
static ObjectName |
newObjectName(String name)
Create a new ObjectName, caller is guaranteeing that the name is
well-formed (a RuntimeException will be thrown if not).
|
static ObjectName |
newObjectName(String domain,
String props)
Build an ObjectName.
|
static ObjectName |
newObjectNamePattern(ObjectName objectName)
Build an ObjectName pattern.
|
static ObjectName |
newObjectNamePattern(String domain,
String props)
Build an ObjectName pattern.
|
static String |
quoteIfNeeded(String name) |
static void |
sleep(long millis) |
static List<ObjectName> |
toObjectNameList(Collection<? extends AMXProxy> amxs) |
static Map<String,ObjectName> |
toObjectNameMap(Map<String,? extends AMXProxy> amxMap) |
static ObjectName[] |
toObjectNamesArray(AMXProxy[] amx) |
static ObjectName[] |
toObjectNamesArray(Collection<? extends AMXProxy> amxs) |
static String |
typeFromName(String s)
Generate the default MBean type from a String, eg from a classname.
|
static String |
unquoteIfNeeded(String name) |
public static final String TYPE_FIELD
A good example of this is the config MBeans which use lower case types with dashes. Other types may use classnames, or other variants; the proxy code can't assume any particular mapping from a proxy interface to the actual MBean type.
public static ObjectName newObjectName(String name)
name
- public static ObjectName newObjectName(String domain, String props)
domain
- the JMX domainprops
- properties of the ObjectNamepublic static ObjectName newObjectNamePattern(String domain, String props)
domain
- the JMX domainprops
- properties of the ObjectNamepublic static ObjectName newObjectNamePattern(ObjectName objectName)
objectName
- public static String makeProp(String name, String value)
name
- value
- public static String makeTypeProp(String value)
value
- public static String makeNameProp(String name)
public static String makeRequiredProps(String type, String name)
type
- name
- public static String getSelfProp(ObjectName objectName)
objectName
- public static String getAdditionalProps(ObjectName objectName)
objectName
- public static List<ObjectName> toObjectNameList(Collection<? extends AMXProxy> amxs)
public static Map<String,ObjectName> toObjectNameMap(Map<String,? extends AMXProxy> amxMap)
public static ObjectName[] toObjectNamesArray(AMXProxy[] amx)
public static ObjectName[] toObjectNamesArray(Collection<? extends AMXProxy> amxs)
public static <T extends AMXProxy> Map<String,T> createNameMap(Set<T> amxs)
amxs
- Set of AMXpublic static final Map<String,ObjectName> createObjectNameMap(Set<ObjectName> objectNames)
objectNames
- Set of ObjectNamepublic static <T extends AMXProxy> List<T> asProxyList(Collection<? extends AMXProxy> c, Class<T> intf)
public static Map<String,Serializable> getAMXNotificationData(Notification notif)
public static Serializable getAMXNotificationValue(Notification notif, String key)
public static <T extends Serializable> T getAMXNotificationValue(Notification notif, String key, Class<T> theClass)
public static void sleep(long millis)
public static <T extends AMXProxy> Set<T> filterAMX(Set<T> candidates, Class<?> desired)
candidates
- the Set to be filtereddesired
- the interface to filter bypublic static Map<String,ObjectName> filterByType(ObjectName[] objectNames, String type)
public static <T extends AMXProxy> Map<String,T> filterAMX(Map<String,T> candidates, Class<?> desired)
candidates
- the Map to be filtereddesired
- the interface to filter bypublic static String getTypeProp(ObjectName objectName)
public static String getNameProp(ObjectName objectName)
public static String getParentPathProp(ObjectName objectName)
public static ObjectName getParent(MBeanServer server, ObjectName objectName)
public static String typeFromName(String s)
public static String deduceType(Class<?> intf)
public static ObjectName getAncestorByType(MBeanServer mbeanServer, ObjectName child, String type)
Copyright © 2018. All rights reserved.