User: squirest
Date: 02/03/07 16:41:37
Modified: src/main/org/jboss/mx/interceptor Invocation.java
Added: src/main/org/jboss/mx/interceptor
ObjectReferenceInterceptor.java
Removed: src/main/org/jboss/mx/interceptor MBeanInterceptor.java
MBeanInvocation.java MBeanInvoker.java
MBeanTarget.java
Log:
added interceptor to route ModelMBean invocations to a dispatcher
removed all irrelevant code not compatible with accepted strategy for interceptors
Revision Changes Path
1.3 +13 -8 jmx/src/main/org/jboss/mx/interceptor/Invocation.java
Index: Invocation.java
===================================================================
RCS file: /cvsroot/jboss/jmx/src/main/org/jboss/mx/interceptor/Invocation.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Invocation.java 8 Dec 2001 16:06:50 -0000 1.2
+++ Invocation.java 8 Mar 2002 00:41:37 -0000 1.3
@@ -15,8 +15,8 @@
* @see org.jboss.mx.interceptor.Interceptor
*
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
- * @version $Revision: 1.2 $
- *
+ * @version $Revision: 1.3 $
+ *
*/
public class Invocation
{
@@ -36,7 +36,7 @@
private String name;
private String[] signature;
private String fullName;
-
+
// Constructors --------------------------------------------------
public Invocation(String name, int type, int impact, Object[] args, String[]
signature, Descriptor[] descriptors)
{
@@ -68,26 +68,31 @@
return name;
}
+ public String[] getSignature()
+ {
+ return signature;
+ }
+
public String getOperationWithSignature()
{
if (signature == null && type == OPERATION)
return name;
-
+
if (fullName != null)
return fullName;
-
+
StringBuffer strBuf = new StringBuffer(1000);
-
+
if (type == ATTRIBUTE && impact == READ)
strBuf.append("get");
if (type == ATTRIBUTE && impact == WRITE)
strBuf.append("set");
-
+
strBuf.append(name);
if (signature != null)
for (int i = 0; i < signature.length; ++i)
strBuf.append(signature[i]);
-
+
fullName = strBuf.toString();
return fullName;
}
1.1
jmx/src/main/org/jboss/mx/interceptor/ObjectReferenceInterceptor.java
Index: ObjectReferenceInterceptor.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.mx.interceptor;
import org.jboss.mx.capability.DispatcherFactory;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.HashMap;
import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanParameterInfo;
import javax.management.ReflectionException;
import javax.management.DynamicMBean;
import javax.management.IntrospectionException;
import javax.management.MBeanException;
import javax.management.Attribute;
import javax.management.modelmbean.ModelMBeanInfo;
import javax.management.modelmbean.ModelMBeanInfoSupport;
/**
* Lifted the functionality seen in MBeanAttributeInterceptor to
* delegate to a dispatcher which implements DynamicMBean.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Trevor Squires</a>.
*/
public class ObjectReferenceInterceptor
extends Interceptor
{
// Attributes ----------------------------------------------------
private MBeanInfo info;
private DynamicMBean resource;
// Constructors --------------------------------------------------
public ObjectReferenceInterceptor(Object resource, ModelMBeanInfo info) throws
ReflectionException
{
super("Model MBean Interceptor");
try
{
this.resource = DispatcherFactory.create(new ModelMBeanInfoSupport(info),
resource);
}
catch (IntrospectionException e)
{
throw new ReflectionException(e);
}
}
// Public ------------------------------------------------------------
// Interceptor overrides ----------------------------------------------
public Object invoke(Invocation invocation) throws InvocationException
{
try
{
if (invocation.getInvocationType() == Invocation.OPERATION)
return resource.invoke(invocation.getName(), invocation.getArgs(),
invocation.getSignature());
if (invocation.getImpact() == Invocation.WRITE)
{
resource.setAttribute((Attribute) invocation.getArgs()[0]);
return null;
}
else
{
return resource.getAttribute(invocation.getName());
}
}
catch (Throwable t)
{
// FIXME: need to check this exception handling
throw new InvocationException(t);
}
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development