User: juhalindfors Date: 01/12/08 08:03:50 Modified: src/main/org/jboss/mx/server StandardMBean.java Log: standard attributes Revision Changes Path 1.3 +56 -18 jmx/src/main/org/jboss/mx/server/StandardMBean.java Index: StandardMBean.java =================================================================== RCS file: /cvsroot/jboss/jmx/src/main/org/jboss/mx/server/StandardMBean.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- StandardMBean.java 2001/12/06 22:50:53 1.2 +++ StandardMBean.java 2001/12/08 16:03:50 1.3 @@ -43,7 +43,7 @@ * @see org.jboss.mx.interceptor.StandardMBeanInterceptor * * @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>. - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * */ public class StandardMBean @@ -95,18 +95,70 @@ } // DynamicMBean implementation ----------------------------------- + public Object invoke(String operationName, Object[] args, String[] signature) throws MBeanException, ReflectionException + { + try { + Invocation invocation = new Invocation( + operationName, + Invocation.OPERATION, + 0, args, signature, null + ); + return stack.invoke(invocation); + } + catch (InvocationException e) { + // FIXME: bad exception handling + if (e.getTargetException() instanceof Exception) + throw new MBeanException((Exception)e.getTargetException(), e.getTargetException().toString()); + else + throw new RuntimeErrorException((Error)e.getTargetException(), e.getTargetException().toString()); + } + } + public Object getAttribute(java.lang.String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { - throw new Error("NYI"); - // FIXME: deal with runtime exceptions and errors from the resource + try { + Invocation invocation = new Invocation( + attribute, + Invocation.ATTRIBUTE, + Invocation.READ, + null, null, null + ); + return stack.invoke(invocation); + } + catch (InvocationException e) { + // FIXME: bad exception handling + if (e.getTargetException() instanceof Exception) { + MBeanException mbe = new MBeanException((Exception)e.getTargetException(), e.getTargetException().toString()); + mbe.fillInStackTrace(); + throw mbe; + } + else + throw new RuntimeErrorException((Error)e.getTargetException(), e.getTargetException().toString()); + } } public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { - throw new Error("NYI"); - // FIXME: deal with runtime exceptions and errors from the resource + try { + Invocation invocation = new Invocation( + attribute.getName(), + Invocation.ATTRIBUTE, + Invocation.WRITE, + new Object[] { attribute.getValue() }, + new String[] { attribute.getValue().getClass().getName() }, + null + ); + stack.invoke(invocation); + } + catch (InvocationException e) { + // FIXME: bad exception handling + if (e.getTargetException() instanceof Exception) + throw new MBeanException((Exception)e.getTargetException(), e.getTargetException().toString()); + else + throw new RuntimeErrorException((Error)e.getTargetException(), e.getTargetException().toString()); + } } public AttributeList getAttributes(java.lang.String[] attributes) @@ -162,20 +214,6 @@ return info; } - // Interceptor overrides ----------------------------------------- - public Object invoke(String operationName, Object[] args, String[] signature) throws MBeanException, ReflectionException - { - try { - Invocation invocation = new Invocation(operationName, Invocation.OPERATION, 0, args, signature, null); - return stack.invoke(invocation); - } - catch (InvocationException e) { - if (e.getTargetException() instanceof Exception) - throw new MBeanException((Exception)e.getTargetException(), e.getTargetException().toString()); - else - throw new RuntimeErrorException((Error)e.getTargetException(), e.getTargetException().toString()); - } - } }
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development