Methods Summary |
---|
public java.lang.Object | getAttribute(java.lang.String attribute)
Method getter = getGetter(attribute);
try
{
return container.localInvoke(getter, new Object[0]);
}
catch (Throwable t)
{
if (t instanceof Exception) throw new MBeanException((Exception) t);
else throw new RuntimeException(t);
}
|
public javax.management.AttributeList | getAttributes(java.lang.String[] attributes)
AttributeList list = new AttributeList();
for (int i = 0; i < attributes.length; i++)
{
try
{
Object obj = getAttribute(attributes[i]);
list.add(new Attribute(attributes[i], obj));
}
catch (Exception e)
{
throw new RuntimeException("Error reading attribute: " + attributes[i], e);
}
}
return list;
|
private java.lang.reflect.Method | getGetter(java.lang.String attribute)
Method getter = getterMethods.get(attribute);
if (getter == null && !getterBlackList.contains(attribute))
{
synchronized (getterMethods)
{
getter = getterMethods.get(attribute);
if (getter == null)
{
try
{
MBeanAttributeInfo[] attrInfos = mbeanInfo.getAttributes();
for (int i = 0; i < attrInfos.length; i++)
{
MBeanAttributeInfo attrInfo = attrInfos[i];
if (attrInfo.getName().equals(attribute))
{
if (!attrInfo.isReadable())
{
throw new AttributeNotFoundException("Attribute '" + attribute + "' is not writable in " + container.getBeanClass().getName());
}
String getterName = ((attrInfo.isIs()) ? "is" : "get") + attribute;
getter = container.getBeanClass().getMethod(getterName);
getterMethods.put(attribute, getter);
}
}
if (getter == null)
{
throw new AttributeNotFoundException("No attribute called '" + attribute + "' in " + container.getBeanClass());
}
}
catch (NoSuchMethodException e)
{
throw new AttributeNotFoundException("Could not find getter for attribute '" + attribute + "' on " + container.getBeanClass().getName());
}
finally
{
if (getter == null)
{
getterBlackList.add(attribute);
}
}
}
}
}
return getter;
|
public javax.management.MBeanInfo | getMBeanInfo()
return mbeanInfo;
|
public javax.management.ObjectName | getObjectName()
return serviceOn;
|
private java.lang.reflect.Method | getOperation(java.lang.String actionName, java.lang.String[] signature)
String opSig = getOperationSignature(actionName, signature);
Method operation = operations.get(actionName);
if (operation == null && !setterBlackList.contains(opSig))
{
synchronized (setterMethods)
{
operation = operations.get(opSig);
if (operation == null)
{
try
{
MBeanOperationInfo[] opInfos = mbeanInfo.getOperations();
for (int i = 0; i < opInfos.length; i++)
{
MBeanOperationInfo op = opInfos[i];
if (op.getName().equals(actionName))
{
boolean match = true;
MBeanParameterInfo[] sigTypes = op.getSignature();
if (sigTypes.length == signature.length)
{
for (int j = 0; j < sigTypes.length; j++)
{
if (!sigTypes[j].getType().equals(signature[j]))
{
match = false;
break;
}
}
}
if (match)
{
Class[] types = null;
if (signature.length > 0)
{
types = new Class[signature.length];
for (int j = 0; j < signature.length; j++)
{
types[j] = Classes.loadClass(signature[j]);
}
}
else
{
types = new Class[0];
}
operation = container.getBeanClass().getMethod(actionName, types);
operations.put(opSig, operation);
}
}
}
if (operation == null)
{
throw new RuntimeException("No operation called '" + actionName + "' in " + container.getBeanClass());
}
}
catch (ClassNotFoundException e)
{
throw new RuntimeException("Could not find type for operation '" + actionName + "' on " + container.getBeanClass().getName());
}
catch (NoSuchMethodException e)
{
throw new RuntimeException("Could not find method for operation '" + actionName + "' on " + container.getBeanClass().getName());
}
finally
{
if (operation == null)
{
operationBlackList.add(opSig);
}
}
}
}
}
return operation;
|
private java.lang.String | getOperationSignature(java.lang.String actionName, java.lang.String[] types)
//Not really the signature, just something unique
StringBuffer sig = new StringBuffer();
sig.append(actionName);
if (types != null)
{
for (int i = 0; i < types.length; i++)
{
sig.append(" ");
sig.append(types[i]);
}
}
return sig.toString();
|
private java.lang.reflect.Method | getSetter(javax.management.Attribute attribute)
String attrName = attribute.getName();
Method setter = setterMethods.get(attrName);
if (setter == null && !setterBlackList.contains(attrName))
{
synchronized (setterMethods)
{
setter = setterMethods.get(attrName);
if (setter == null)
{
try
{
MBeanAttributeInfo[] attrInfos = mbeanInfo.getAttributes();
for (int i = 0; i < attrInfos.length; i++)
{
MBeanAttributeInfo attrInfo = attrInfos[i];
if (attrInfo.getName().equals(attrName))
{
if (!attrInfo.isWritable())
{
throw new AttributeNotFoundException("Attribute '" + attrName + "' is not readable in " + container.getBeanClass().getName());
}
String setterName = "set" + attrName;
Class type = Classes.loadClass(attrInfo.getType());
setter = container.getBeanClass().getMethod(setterName, type);
setterMethods.put(attrName, setter);
}
}
if (setter == null)
{
throw new AttributeNotFoundException("No attribute called '" + attribute + "' in " + container.getBeanClass());
}
}
catch (ClassNotFoundException e)
{
throw new AttributeNotFoundException("Could not load setter type for attribute '" + attrName + "' on " + container.getBeanClass().getName());
}
catch (NoSuchMethodException e)
{
throw new AttributeNotFoundException("Could not find setter for attribute '" + attrName + "' on " + container.getBeanClass().getName());
}
finally
{
if (setter == null)
{
setterBlackList.add(attrName);
}
}
}
}
}
return setter;
|
public java.lang.Object | invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
if(log.isTraceEnabled())
log.trace("invoke: " + actionName);
try
{
// EJBTHREE-655: intercept lifecycle methods
// if(isMagicLifecycleMethod(actionName))
// {
// invokeMagicLifecycleMethod(actionName);
// return null;
// }
Method operation = getOperation(actionName, signature);
return container.localInvoke(operation, params);
}
catch (Throwable t)
{
if (t instanceof Exception) throw new MBeanException((Exception) t);
else throw new RuntimeException(t);
}
|
public void | register(javax.management.ObjectName on, java.lang.Class intf)
server.registerMBean(this, serviceOn);
|
public void | setAttribute(javax.management.Attribute attribute)
Method setter = getSetter(attribute);
try
{
container.localInvoke(setter, new Object[]{attribute.getValue()});
}
catch (Throwable t)
{
if (t instanceof Exception) throw new MBeanException((Exception) t);
else throw new RuntimeException(t);
}
|
public javax.management.AttributeList | setAttributes(javax.management.AttributeList attributes)
for (Iterator it = attributes.iterator(); it.hasNext();)
{
Attribute attribute = (Attribute) it.next();
try
{
setAttribute(attribute);
}
catch (Exception e)
{
throw new RuntimeException("Error setting attribute: " + attribute, e);
}
}
return attributes;
|
public void | unregister()
server.unregisterMBean(serviceOn);
|