1 23 24 package com.sun.enterprise.admin.server.core.mbean.config; 25 26 import javax.management.DynamicMBean ; 28 import javax.management.AttributeList ; 29 import javax.management.MBeanInfo ; 30 import javax.management.Attribute ; 31 import javax.management.AttributeNotFoundException ; 32 import javax.management.MBeanException ; 33 import javax.management.ReflectionException ; 34 import javax.management.InvalidAttributeValueException ; 35 36 import com.sun.enterprise.util.i18n.StringManager; 38 39 import com.sun.enterprise.admin.server.core.jmx.Introspector; 40 import java.lang.reflect.Method ; 41 42 43 49 50 public abstract class AdminBase implements DynamicMBean 51 { 52 private static StringManager localStrings = 54 StringManager.getManager( AdminBase.class ); 55 56 protected AdminBase() { 57 } 58 59 public Object getAttribute(String attributeName) throws 60 AttributeNotFoundException , MBeanException , ReflectionException { 61 String msg = localStrings.getString( "admin.server.core.mbean.config.getattribute_not_implemented" ); 62 throw new UnsupportedOperationException ( msg ); 63 } 64 65 public AttributeList getAttributes(String [] attributeNames) { 66 String msg = localStrings.getString( "admin.server.core.mbean.config.getattribute_not_implemented" ); 67 throw new UnsupportedOperationException ( msg ); 68 } 69 70 public MBeanInfo getMBeanInfo() { 71 String msg = localStrings.getString( "admin.server.core.mbean.config.getmbeaninfo_not_implemented" ); 72 throw new UnsupportedOperationException ( msg ); 73 } 74 75 78 protected abstract Class getImplementingClass(); 79 80 81 protected abstract Object getImplementingMBean(); 82 83 94 public Object invoke(String methodName, Object [] methodParams, 95 String [] methodSignature) throws MBeanException , ReflectionException { 96 97 final Class implClass = getImplementingClass(); 98 final Object mbeanReference = getImplementingMBean(); 99 final Introspector reflector = new Introspector(implClass); 100 Object value = null; 101 try { 102 103 final Method method = reflector.getMethod(methodName, methodSignature); 104 value = reflector.invokeMethodOn(method, mbeanReference, methodParams); 105 return ( value ); 106 } 107 catch (java.lang.ClassNotFoundException cnfe) { 108 throw new javax.management.ReflectionException (cnfe); 109 } 110 catch (java.lang.NoSuchMethodException nsme) { 111 throw new javax.management.ReflectionException (nsme); 112 } 113 catch (java.lang.SecurityException se) { 114 throw new javax.management.ReflectionException (se); 115 } 116 catch (java.lang.reflect.InvocationTargetException ite) { 117 Throwable t = ite.getTargetException(); 118 if (t instanceof MBeanException ) { 119 throw (MBeanException )t; 120 } 121 else 122 if (t instanceof Exception ) { 123 throw new MBeanException ((Exception ) t); 124 } 125 else { String msg = localStrings.getString( "admin.server.core.jmx.error_from_mbean", t.getMessage() ); 127 RuntimeException re = new RuntimeException ( msg ); 128 throw new MBeanException (re); 129 } 131 } 132 catch (java.lang.IllegalAccessException iae) { 133 throw new javax.management.ReflectionException (iae); 134 } 135 catch (Exception e) { 136 throw new MBeanException (e); 137 } 138 139 } 140 141 public void setAttribute(Attribute attribute) throws 142 AttributeNotFoundException , InvalidAttributeValueException , 143 MBeanException , ReflectionException { 144 145 String msg = localStrings.getString( "admin.server.core.mbean.config.setattribute_not_implemented" ); 146 throw new UnsupportedOperationException ( msg ); 147 } 148 149 public AttributeList setAttributes(AttributeList parm1) { 150 String msg = localStrings.getString( "admin.server.core.mbean.config.setattributes_not_implemented" ); 151 throw new UnsupportedOperationException ( msg ); 152 } 153 } 154 | Popular Tags |