FileDocCategorySizeDatePackage
ManagedJsr77MdlBean.javaAPI DocGlassfish v2 API10430Fri May 04 22:25:40 BST 2007com.sun.enterprise.admin.runtime

ManagedJsr77MdlBean

public class ManagedJsr77MdlBean extends Object

Fields Summary
DynamicMBean
m_mbean
Object
m_baseJsr77Bean
Constructors Summary
public ManagedJsr77MdlBean(DynamicMBean mbean, Object cb)


       /*J2EEManagedObjectMdl*/  
    
        m_baseJsr77Bean = cb;
        m_mbean = mbean;
    
Methods Summary
public java.lang.ObjectgetAttribute(javax.management.modelmbean.ModelMBeanAttributeInfo attrInfo, java.lang.String attrName)
Gets MBean's attribute value.

param
externalName the MBean's attribute name.
return
The value of the attribute retrieved.
throws
MBeanException exception
throws
AttributeNotFoundException exception

        Descriptor descr = attrInfo.getDescriptor();
        String getter = (String)descr.getFieldValue(MBeanMetaConstants.GETTER_FIELD_NAME);
        if(getter==null)
            throw new MBeanException(new MBeanRuntimeException("ManagedJsr77MdlBean:getAttribute:No getter found in descriptor"));
        try 
        {
            Method method = m_baseJsr77Bean.getClass().getMethod(getter);
            return method.invoke(m_baseJsr77Bean);
        }
        catch (Exception e)
        {
            //throw new MBeanException(e, "Exception invoking getter method in runtime bean " + getter);
            throw MBeanHelper.extractAndWrapTargetException(e, 
                "Exception invoking getter method in runtime bean " + getter);
        }
    
private java.lang.ClassgetClassForName(java.lang.String type)

        if(type.equals("int"))
           return Integer.TYPE;
        if(type.equals("long"))
           return Long.TYPE;
        if(type.equals("boolean"))
           return Boolean.TYPE;
        return Class.forName(type);
    
public java.lang.ObjectinvokeOperation(javax.management.modelmbean.ModelMBeanOperationInfo opInfo, java.lang.Object[] params, java.lang.String[] signature)

       String name = opInfo.getName();
        try 
        {
            Object ret = MBeanHelper.invokeOperationInBean(opInfo, this, params);
            if(ret!=MBeanHelper.INVOKE_ERROR_SIGNAL_OBJECT)
            {
                return ret;
            }
        } 
        catch (Exception e)
        {
            //throw new MBeanException(e, "Exception invoking method in runtime bean" + name);
            throw MBeanHelper.extractAndWrapTargetException(e, 
                "Exception invoking method in runtime bean " + name);
        }

       try 
        {
            return MBeanHelper.invokeOperationInBean(opInfo, m_baseJsr77Bean, params);
            // IT MAYBE:MBeanHelper.INVOKE_ERROR_SIGNAL_OBJECT !!!
        } 
        catch (Exception e)
        {
            //throw new MBeanException(e, "Exception invoking method in runtime bean" + name);
            throw MBeanHelper.extractAndWrapTargetException(e, 
                "Exception invoking method in runtime bean " + name);
        }
    
public voidsetAttribute(javax.management.modelmbean.ModelMBeanAttributeInfo attrInfo, javax.management.Attribute attr)
Sets MBean's attribute value.

param
attr The identification of the attribute to be set and the value it is to be set to.
throws
MBeanException exception
throws
AttributeNotFoundException exception

        Descriptor descr = attrInfo.getDescriptor();
        String setter = (String)descr.getFieldValue(MBeanMetaConstants.SETTER_FIELD_NAME);
        if(setter==null)
            throw new MBeanException(new MBeanRuntimeException("ManagedJsr77MdlBean:getAttribute:No setter found in descriptor"));
        try 
        {
            Method method = m_baseJsr77Bean.getClass().getMethod(setter, new Class[]{getClassForName(attrInfo.getType())});
            method.invoke(m_baseJsr77Bean, new Object[]{attr.getValue()});
        }
        catch (Exception e)
        {
//e.printStackTrace();
            //throw new MBeanException(e, "Exception invoking setter method in runtime bean " + setter);
            throw MBeanHelper.extractAndWrapTargetException(e, 
                "Exception invoking setter method in runtime bean " + setter);
        }