Methods Summary |
---|
public synchronized javax.management.ObjectName | addChild(java.lang.String name, MonitoredObjectType type, com.sun.enterprise.admin.monitor.BaseMonitorMBean mBean)Add an MBean to the MBean tree below this MBean. This method also adds
the specified child MBean to the MBeanServer. Adding monitoring MBean to
MBeanServer requires object name and can be derived for the child, if
this MBean (parent) was already added to MBeanServer.
if (name == null || type == null || mBean == null) {
String str1 = (name == null) ? "Child Name (name); " : "";
String str2 = (type == null) ? "Child Type (type); " : "";
String str3 = (mBean == null) ? "MBean (mBean); " : "";
String msg = localStrings.getString( "admin.monitor.null_arguments", str1, str2, str3 );
throw new IllegalArgumentException( msg );
}
if (objectName == null || nodeName == null || nodeType == null) {
String msg = localStrings.getString( "admin.monitor.monitoring_mbean_not_added_to_mbeantree" );
throw new IllegalStateException( msg );
}
boolean exists = false;
int size = childList.size();
for (int i = 0; i < size; i++) {
BaseMonitorMBean m = (BaseMonitorMBean)childList.elementAt(i);
if (type.isSingleton()) {
if (m.nodeType.equals(type.getTypeName())) {
exists = true;
break;
}
} else {
if (m.nodeType.equals(type.getTypeName())
&& m.nodeName.equals(name)) {
exists = true;
break;
}
}
}
if (exists) {
String msg = localStrings.getString( "admin.monitor.mbean_already_exists", type, name );
throw new InstanceAlreadyExistsException( msg );
}
if (type.isSingleton()) {
name = type.getTypeName();
}
childList.add(mBean);
mBean.setNodeName(name);
mBean.setNodeType(type.getTypeName());
ObjectName childObjName = getChildObjectName(objectName, type, name);
mBean.setObjectName(childObjName);
MBeanServer mbs = getMBeanServer();
/**
* Commenting this block for now
try {
mbs.registerMBean(mBean, childObjName);
} catch (NotCompliantMBeanException ncme) {
logger.log(Level.WARNING, NON_COMPLIANT_MBEAN, childObjName);
throw new MBeanRegistrationException(ncme);
}
*/
objectNameMap.put(childObjName, mBean);
if (type.isMonitoringEnabled()) {
mBean.startMonitoring();
}
return childObjName;
|
private static java.util.Map | convertKeysToCamelCase(java.util.Map attrNameTypeMap)Converts the keys in the passed map into camel-case strings.
The given map must not be null.
Iterator keys = attrNameTypeMap.keySet().iterator();
Iterator values = attrNameTypeMap.values().iterator();
Map newMap = new HashMap();
while(keys.hasNext()) {
String key = (String)keys.next();
String camelCaseKey = toCamelCase(key);
newMap.put(camelCaseKey, values.next());
}
return newMap;
|
protected static java.util.Map | createAttrNameTypeMap(java.lang.Object[][] attrNameTypeArray)Convenience method to create a map of monitorable attribute names and
their types from a 2-d array of attribute names and attribute types.
Attribute types are instances of class MonitoredAttributeType in the
package com.sun.enterprise.admin.monitor.types. This method can be called
from static initializer of sub-classes to initialize a static variable
with a Map of attribute names and types (which can then be returned by
the method getMonitoringMetaData)
HashMap map = new HashMap();
for (int i = attrNameTypeArray.length; i > 0; i--) {
map.put(attrNameTypeArray[i-1][0], attrNameTypeArray[i-1][1]);
}
return map;
|
protected static javax.management.MBeanInfo | createMBeanInfo(java.util.Map attrNameTypeMap)Convenience method to create MBeanInfo from a HashMap of attribute
names and attribute types. This method can be called from static
initializer of sub-classes to initialize a static variable with
MBeanInfo (which can then be returned by the method getMBeanInfo). This
method assumes that sub-classes of BaseMonitorMBean do not implement any
additional JMX operations or notifications. If the sub-classes need to
implement their own operations and/or notifications the MBeanInfo
returned from this method should be updated to add those.
return (createMBeanInfo(attrNameTypeMap, new MBeanOperationInfo[0]));
|
protected static javax.management.MBeanInfo | createMBeanInfo(java.util.Map attrNameTypeMap, javax.management.MBeanOperationInfo[] operationInfoArray)Convenience method to create MBeanInfo from a HashMap of attribute
names and attribute types. This method can be called from static
initializer of sub-classes to initialize a static variable with
MBeanInfo (which can then be returned by the method getMBeanInfo). This
method assumes that sub-classes of BaseMonitorMBean do not implement any
additional JMX operations or notifications. If the sub-classes need to
implement their own operations and/or notifications the MBeanInfo
returned from this method should be updated to add those.
String className = GenericMonitorMBean.class.getName();
String description = "Generic Monitoring MBean";
attrNameTypeMap = convertKeysToCamelCase(attrNameTypeMap);
Set keys = attrNameTypeMap.keySet();
Iterator names = keys.iterator();
MBeanAttributeInfo[] attrList = new MBeanAttributeInfo[keys.size()];
int i = 0;
while (names.hasNext()) {
String name = (String)names.next();
String type = ((MonitoredAttributeType)attrNameTypeMap.get(name)).getJavaTypeName();
String desc = "Monitored attribute " + name;
attrList[i] = new MBeanAttributeInfo(name, type, desc, true, false, false);
i++;
}
MBeanConstructorInfo[] constructorList = new MBeanConstructorInfo[0];
//MBeanOperationInfo[] operationList = new MBeanOperationInfo[0];
MBeanNotificationInfo[] notificationList = new MBeanNotificationInfo[0];
return new MBeanInfo(className, description, attrList, constructorList,
operationInfoArray, notificationList);
|
public java.lang.String[] | getAllAttributeNames()Get name of all attributes exposed by this MBean. The method returns
a string array of length zero or more. The default implementation
uses MBeanInfo to derive list of attribute names and throws an
IllegalStateException if MBeanInfo is null.
return getAllAttributeNamesFromMBeanInfo();
|
private java.lang.String[] | getAllAttributeNamesFromMBeanInfo()Get name of all attributes exposed by this MBean. This method uses
MBeanInfo to derive list of all attributes and caches it. Therefore,
if MBeanInfo is changed after a call to this method it will not affect
the return value of this method. JMX specification requires that
MBeanInfo returned by DynamicMBean implementation does not change once
the MBean has been registered.
if (attrNames == null) {
MBeanInfo info = this.getMBeanInfo();
if (info == null) {
String msg = localStrings.getString( "admin.monitor.null_mbean_info", this.getClass() );
throw new IllegalStateException( msg );
}
MBeanAttributeInfo[] attrInfoList = info.getAttributes();
if (attrInfoList == null) {
String msg = localStrings.getString( "admin.monitor.null_attribute_info_in_mbeaninfo", this.getClass() );
throw new IllegalStateException( msg );
}
int size = attrInfoList.length;
attrNames = new String[size];
for (int i = 0; i < size; i++) {
attrNames[i] = attrInfoList[i].getName();
}
}
return attrNames;
|
public abstract java.lang.Object | getAttribute(java.lang.String attribute)Obtains the value of a specific monitored attribute.
|
public abstract com.sun.enterprise.admin.monitor.types.MonitoredAttributeType | getAttributeType(java.lang.String attrName)Get type of the specified monitored attribute.
|
public abstract javax.management.AttributeList | getAttributes(java.lang.String[] attributes)Get the values of several attributes of the monitoring MBean.
|
public com.sun.enterprise.admin.monitor.BaseMonitorMBean | getChild(MonitoredObjectType type, java.lang.String name)Get specified child MBean. If type is singleton, then name parameter is
not used for searching.
BaseMonitorMBean found = getChildOrNull(type, name);
if (found == null) {
String msg = localStrings.getString( "admin.monitor.mbean_not_found", type, name );
throw new InstanceNotFoundException( msg );
}
return found;
|
public java.util.ArrayList | getChildList(MonitoredObjectType type)Get list of children of specified type for this MBean. This method
returns all children of specified type for this MBean. If there is no
child of specified type, the method returns an empty list.
if (type == null) {
String msg = localStrings.getString( "admin.monitor.null_argument_mbean_type" );
throw new IllegalArgumentException( msg );
}
ArrayList list = new ArrayList();
Iterator iter = childList.iterator();
while (iter.hasNext()) {
BaseMonitorMBean mBean = (BaseMonitorMBean)iter.next();
if (mBean.nodeType.equals(type.getTypeName())) {
list.add(mBean);
}
}
return list;
|
public java.util.ArrayList | getChildList(java.lang.String name)Get list of children of specified name for this MBean. This method
returns all children of specified name for this MBean. If there is no
child of specified name, the method returns an empty list.
ArrayList list = new ArrayList();
Iterator iter = childList.iterator();
while (iter.hasNext()) {
BaseMonitorMBean mBean = (BaseMonitorMBean)iter.next();
if (mBean.nodeName.equals(name)) {
list.add(mBean);
}
}
return list;
|
public java.util.ArrayList | getChildList()Get list of children of this MBean. This method returns all children of
this MBean. If there is no child, the method returns an empty list.
ArrayList list = new ArrayList();
list.addAll(childList);
return list;
|
private static javax.management.ObjectName | getChildObjectName(javax.management.ObjectName parent, MonitoredObjectType childType, java.lang.String childName)Derive Object Name for the child MBean.
Hashtable props = parent.getKeyPropertyList();
Hashtable newProps = (Hashtable)props.clone();
String type = (String)props.get(MON_OBJTYPE);
String name = (String)props.get(MON_OBJNAME);
newProps.put(type, name);
newProps.put(MON_OBJTYPE, childType.getTypeName());
newProps.put(MON_OBJNAME, childName);
ObjectName newName = null;
try {
newName = new ObjectName(parent.getDomain(), newProps);
} catch (MalformedObjectNameException mone) {
throw new MBeanRegistrationException(mone, mone.getMessage());
}
return newName;
|
com.sun.enterprise.admin.monitor.BaseMonitorMBean | getChildOrNull(MonitoredObjectType type, java.lang.String name)Get specified child mbean or null if there is no such child.
if (type == null) {
String msg = localStrings.getString( "admin.monitor.monitored_object_type_null" );
throw new IllegalArgumentException( msg );
}
BaseMonitorMBean found = null;
Iterator iter = childList.iterator();
while (iter.hasNext()) {
BaseMonitorMBean mBean = (BaseMonitorMBean)iter.next();
if (type.isSingleton()) {
if (mBean.nodeType.equals(type.getTypeName())) {
found = mBean;
}
} else {
if (mBean.nodeType.equals(type.getTypeName())
&& mBean.nodeName.equals(name)) {
found = mBean;
}
}
}
return found;
|
com.sun.enterprise.admin.monitor.BaseMonitorMBean | getFirstChildByName(java.lang.String name)Get first child MBean with the specified name.
ArrayList list = getChildList(name);
if (list.isEmpty()) {
String msg = localStrings.getString( "admin.monitor.child_mbean_not_available", name, objectName );
throw new InstanceNotFoundException( msg );
}
return ((BaseMonitorMBean)list.get(0));
|
private static java.lang.String | getLocalString(java.lang.String key, java.lang.String dflt)
return dflt;
|
public abstract javax.management.MBeanInfo | getMBeanInfo()Provides the exposed attributes and actions of the monitoring MBean using
an MBeanInfo object. The implementation for this method should ensure
that the returned value is always same (not necessarily same reference,
but same contained values).
|
private static javax.management.MBeanServer | getMBeanServer()Get MBeanServer. If MBeanServer is not found then this method throws
RuntimeException.
return MBeanServerFactory.getMBeanServer();
|
public final java.lang.Object | getMonitoredAttributeValue(java.lang.String monitorAttributeName)Get value of specified monitored attribute. This method is from interface
IMonitorable and is implemented to use method getAttribute from
DynamicMBean interface.
Object result = null;
try {
result = getAttribute(monitorAttributeName);
} catch (AttributeNotFoundException anfe) {
}
return result;
|
public final java.util.Map | getMonitoredAttributeValues(java.util.Set monitorAttributeNameSet)Get values of specified monitored attributes. This method returns a
map of monitored attribute names and their corresponding values. This
method is from interface IMonitorable and is implemented to use method
getAttributes from DynamicMBean interface.
return null;
|
public abstract java.util.Map | getMonitoringMetaData()Get a map of monitored attribute names and their types. The keys in
the map are names of the attribute and the values are their types. The
type value are instances of class
com.iplanet.ias.monitor.type.MonitoredAttributeType (or its sub-classes)
|
public java.lang.String | getNodeName()Get name of this MBean. A typical example is - for a stateless session
bean called fortune, this method will return fortune. The MBean has
a fully qualified name in the MBeanServer, but this method only returns
name from the current context.
return nodeName;
|
public java.lang.String | getNodeType()Get type of this MBean. This is the type used in the hierarchy of
monitoring MBeans.
return nodeType;
|
public javax.management.ObjectName | getObjectName()Get name of this MBean as registered in MBean server.
return objectName;
|
public java.lang.Object | invoke(java.lang.String str, java.lang.Object[] obj, java.lang.String[] str2)Invoke a operation on this MBean.
throw new UnsupportedOperationException(
getLocalString(UNSUPPORTED_ERRCODE, UNSUPPORTED_ERRMSG));
|
private static void | removeAllChild(com.sun.enterprise.admin.monitor.BaseMonitorMBean mbean)Remove all child MBeans of specified mbean. This methos also unregisters
all child Mbeans from MBean server. It recusrively calls itself if the
child mbeans also have child(ren).
Iterator iter = mbean.childList.iterator();
while (iter.hasNext()) {
BaseMonitorMBean child = (BaseMonitorMBean)iter.next();
removeAllChild(child);
objectNameMap.remove(child.objectName);
MBeanServer mbs = getMBeanServer();
// Commenting this line for now
// mbs.unregisterMBean(child.objectName);
}
mbean.childList.removeAllElements();
|
public synchronized void | removeChild(MonitoredObjectType type, java.lang.String name)Remove specified monitoring MBean from MBean tree. This method will
remove the specified MBean from MBeanServer as well. If the specified
MBean has any child(ren) they are also removed from the MBean tree and
MBeanServer.
BaseMonitorMBean mBean = getChild(type, name);
removeChild(mBean);
|
synchronized void | removeChild(com.sun.enterprise.admin.monitor.BaseMonitorMBean child)Remove specified child MBean from MBean tree. This method will
remove the specified MBean from MBeanServer as well. If the specified
MBean has any child(ren) they are also removed from the MBean tree and
MBeanServer.
removeAllChild(child);
childList.remove(child);
objectNameMap.remove(child.objectName);
MBeanServer mbs = getMBeanServer();
// Commenting this line for now
// mbs.unregisterMBean(child.objectName);
|
public final void | setAttribute(javax.management.Attribute attribute)Set an attribute on this MBean.
throw new UnsupportedOperationException(
getLocalString(UNSUPPORTED_ERRCODE, UNSUPPORTED_ERRMSG));
|
public final javax.management.AttributeList | setAttributes(javax.management.AttributeList attributeList)Set specified attributes on this MBean
throw new UnsupportedOperationException(
getLocalString(UNSUPPORTED_ERRCODE, UNSUPPORTED_ERRMSG));
|
protected void | setNodeName(java.lang.String name)Set name of the node to specified value. Invoked from addChild method of
the parent of this MBean. So, this method need not be called elsewhere.
A call to this method does not affect the name in MBeanServer, so the
caller of this method should also handle naming within MBeanServer.
nodeName = name;
|
protected void | setNodeType(java.lang.String type)Set type of this MBean to specified value. This method is invoked from
the method addChild of the parent of this MBean. A call to this method
does not affect the naming within MBeanServer, so the caller of this
method should also handle naming within MBeanServer.
nodeType = type;
|
protected void | setObjectName(javax.management.ObjectName objName)Set object name for this MBean. This should be same as the name used
to register this MBean to MBeanServer.
objectName = objName;
|
public void | startMonitoring()Start monitoring on this component. This will be called when monitoring
is enabled on this component (or the group containing this component)
through user interface.
|
public void | stopMonitoring()Stop monitoring on this component. Called when monitoring is disabled on
user interface.
|
private static java.lang.String | toCamelCase(java.lang.String illegalIdentifier)Converts the given string with characters that are illegal identifier parts and converts it
into a String with camel-case. The entire BNF is out of the scope.
Following are the basic rules:
gets rid of all the illegal characters in given string.
all consecutive illegal characters are collapsed.
leading and trailing illegal characters are ignored.
given string should have no other illegal characters (that make it
an illegal java-identifier). This is asserted.
The case of an already upper-case character is NOT changed.
final StringBuffer from = new StringBuffer(illegalIdentifier);
final StringBuffer to = new StringBuffer();
final int length = from.length();
boolean illegalFound = false;
for (int i = 0 ; i < length ; i++) {
char currentChar = from.charAt(i);
/* First char should be valid start and char at any other position
should be valid part, otherwise ignore it. */
if (i == 0 && !Character.isJavaIdentifierStart(currentChar) ||
i > 0 && !Character.isJavaIdentifierPart(currentChar)) {
illegalFound = true;
continue;
}
if (illegalFound) {
to.append(Character.toUpperCase(currentChar));
illegalFound = false;
}
else {
to.append(currentChar);
}
}
return (to.toString());
|