BaseRuntimeMBeanpublic class BaseRuntimeMBean extends com.sun.enterprise.admin.BaseAdminMBean implements MBeanRegistrationBase class for Config MBeans which implements basic config
activity according to ModelMBeanInfo provided by MBeanRegistry |
Fields Summary |
---|
private com.sun.enterprise.admin.config.ManagedConfigBean | mcb | private ManagedJsr77MdlBean | mrb | protected com.sun.enterprise.admin.meta.MBeanRegistry | m_registry | ObjectName | mSelfObjectName |
Constructors Summary |
---|
public BaseRuntimeMBean()Construct a ModelMBean with default
ModelMBeanInfo information.
// ----------------------------------------------------------- Constructors
super();
m_registry = MBeanRegistryFactory.getRuntimeMBeanRegistry();
|
Methods Summary |
---|
protected javax.management.ObjectName | createChildElementByType(java.lang.String childElementName, javax.management.Attribute[] attrs, boolean bSkipNullValued, boolean bOnlyOne)
AttributeList list = new AttributeList();
for(int i=0; i<attrs.length; i++)
{
if(!bSkipNullValued || attrs[i].getValue()!=null)
list.add(attrs[i]);
}
ConfigBean bean = mcb.createChildByType(childElementName, list, null, bOnlyOne);
return ConfigMBeanHelper.getChildObjectName(m_registry, info, bean);
| protected javax.management.ObjectName | createChildElementByType(java.lang.String childElementName, javax.management.Attribute[] attrs)
return createChildElementByType(childElementName, attrs, true, false);
| protected javax.management.ObjectName | createChildElementByType(java.lang.String childElementName, javax.management.Attribute[] attrs, boolean bSkipNullValued)
return createChildElementByType(childElementName, attrs, bSkipNullValued, false);
| public java.lang.Object | getAttribute(java.lang.String name)Obtain and return the value of a specific attribute of this MBean.
ModelMBeanAttributeInfo attrInfo = (ModelMBeanAttributeInfo)MBeanHelper.findMatchingAttributeInfo((MBeanInfo)info, name);
if(attrInfo==null)
throw new AttributeNotFoundException();
//FIXME add check "is readable"
//1. MBean
try
{
return super.getAttribute(name);
} catch (Exception e) {}
//2. runtime managed bean
if(mrb!=null)
{
// our delegate is not an MBean and won't have its ObjectName
if ( "objectName".equals( name ) )
{
// use of JMXUtil produces a consistently-ordered String for all ObjectNames
return JMXUtil.toString( mSelfObjectName );
}
else
{
try
{
return mrb.getAttribute(attrInfo, name);
}
catch (Exception e)
{
// yuck, this whole method stinks, but this is the way it was
}
}
}
//3. config managed bean
if(mcb!=null)
{
try {
return mcb.getAttribute(attrInfo, name);
} catch (Exception e) {}
}
throw new AttributeNotFoundException(); //?????
| public javax.management.AttributeList | getAttributes(java.lang.String[] attributeNames)
AttributeList list = new AttributeList();
if(attributeNames!=null)
for(int i=0; i<attributeNames.length; i++)
{
try {
Object value = getAttribute(attributeNames[i]);
list.add(new Attribute(attributeNames[i], value));
} catch (Exception e) {}
}
return list;
| public java.lang.Object | invoke(java.lang.String name, java.lang.Object[] params, java.lang.String[] signature)Invoke a particular method on this MBean, and return any returned
value.
IMPLEMENTATION NOTE - This implementation will
attempt to invoke this method on the MBean itself, or (if not
available) on the managed resource object associated with this
MBean.
ModelMBeanOperationInfo opInfo = (ModelMBeanOperationInfo)MBeanHelper.findMatchingOperationInfo((MBeanInfo)info, name, signature);
if (opInfo == null)
{
String msg = _localStrings.getString( "admin.server.core.mbean.config.base.operation_is_not_found", mbeanType, name);
throw new MBeanException
(new ServiceNotFoundException(msg), msg);
}
//Generic Config invoker
Object ret;
try
{
ret = MBeanHelper.invokeOperationInBean(opInfo, this, params);
if(ret!=MBeanHelper.INVOKE_ERROR_SIGNAL_OBJECT)
return ret;
if(mrb!=null)
{
ret = mrb.invokeOperation(opInfo, params, signature);
if(ret!=MBeanHelper.INVOKE_ERROR_SIGNAL_OBJECT)
return ret;
}
if(mcb!=null)
{
ret = mcb.invokeOperation(opInfo, params, signature);
if(ret!=MBeanHelper.INVOKE_ERROR_SIGNAL_OBJECT)
return ret;
}
}
catch (MBeanException mbe)
{
throw mbe;
}
catch (Exception e)
{
String msg = _localStrings.getString( "admin.server.core.mbean.runtime.base.invoke_error", mbeanType, name);
throw MBeanHelper.extractAndWrapTargetException(e, msg);
}
//TBD FIXME
//value = ConfigBeanHandler.invoke(this.cb, name, params, signature);
return super.invoke(name, params, signature);
| public void | postDeregister()
mSelfObjectName = null;
| public void | postRegister(java.lang.Boolean registrationDone)
| public void | preDeregister()
| public javax.management.ObjectName | preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
mSelfObjectName = name;
return name;
| public void | setAttribute(javax.management.Attribute attribute)Set the value of a specific attribute of this MBean.
ModelMBeanAttributeInfo attrInfo = (ModelMBeanAttributeInfo)MBeanHelper.findMatchingAttributeInfo((MBeanInfo)info, attribute.getName());
if(attrInfo==null)
throw new AttributeNotFoundException();
//FIXME add check "is writable"
//1. MBean
try
{
super.setAttribute(attribute);
return;
} catch (Exception e) {}
//2. runtime managed bean
if(mrb!=null)
{
try {
mrb.setAttribute(attrInfo, attribute);
return;
} catch (Exception e) {}
}
//3. config managed bean
if(mcb!=null)
{
try {
mcb.setAttribute(attrInfo, attribute);
return;
} catch (Exception e) {}
}
| public javax.management.AttributeList | setAttributes(javax.management.AttributeList list)Sets the values of several MBean's attributes.
if(list==null || list.size()<=0)
return null;
AttributeList listRes = new AttributeList();
for(int i=0; i<list.size(); i++)
{
try {
Attribute attr = (Attribute)list.get(i);
setAttribute(attr);
listRes.add(attr);
} catch (Exception e) {}
}
return listRes;
| public void | setManagedResource(java.lang.Object resource, java.lang.String type)Set the instance handle of the object against which we will execute
all methods in this ModelMBean management interface.
if (resource == null)
throw new RuntimeOperationsException
(new IllegalArgumentException("Managed resource is null"),
"Managed resource is null");
if (MBeanMetaConstants.CONFIG_BEAN_REF.equalsIgnoreCase(type)) {
if(! (resource instanceof ConfigBean)) {
throw new RuntimeOperationsException
(new ClassCastException("Managed resource is not a ConfigBean"),
"Managed resource is not a ConfigBean");
}
this.mcb = new ManagedConfigBean(this, (ConfigBean) resource, m_registry);
} else {
if (MBeanMetaConstants.JSR77_MODEL_BEAN_REF.equalsIgnoreCase(type))
{
/* if(! (resource instanceof J2EEManagedObjectMdl)) {
throw new RuntimeOperationsException
(new ClassCastException("Managed resource is not a Jsr77ModelBean :"+resource.getClass().getName()),
"Managed resource is not a Jsr77ModelBean: "+resource.getClass().getName());
}
*/
this.mrb = new ManagedJsr77MdlBean(this, /*(J2EEManagedObjectMdl)*/ resource);
} else
{
super.setManagedResource(resource, type);
}
}
|
|