1 4 package org.oddjob.jmx.server; 5 6 import java.lang.reflect.InvocationTargetException ; 7 import java.lang.reflect.Method ; 8 9 import javax.management.MBeanException ; 10 import javax.management.Notification ; 11 import javax.management.ReflectionException ; 12 13 public class OperationsHandler implements InterfaceHandler { 14 15 private final Object target; 16 17 public OperationsHandler(Object target){ 18 this.target = target; 19 } 20 21 public Object invoke(String actionName, Object [] params, String [] signature) throws MBeanException , ReflectionException { 22 Class [] paramTypes = new Class [signature.length]; 23 try { 24 for (int i = 0; i < paramTypes.length; ++i) { 25 paramTypes[i] = Class.forName(signature[i]); 26 } 27 } catch (ClassNotFoundException e) { 28 throw new MBeanException (e); 29 } 30 31 try { 32 Method m = target.getClass().getMethod(actionName, paramTypes); 33 try { 34 return m.invoke(target, params); 35 } catch (IllegalArgumentException e1) { 36 throw new ReflectionException (e1, actionName); 37 } catch (IllegalAccessException e1) { 38 throw new ReflectionException (e1, actionName); 39 } catch (InvocationTargetException e1) { 40 throw new ReflectionException (e1, actionName); 41 } 42 } catch (NoSuchMethodException e) { 43 throw new ReflectionException (e, actionName); 44 } 45 } 46 47 public Notification [] getLastNotifications() { 48 return null; 49 } 50 51 public void destroy() { 52 } 53 } 54 | Popular Tags |