1 22 package org.jboss.jmx.connector.invoker.client; 23 24 import org.jboss.invocation.Invocation; 25 import org.jboss.invocation.PayloadKey; 26 import org.jboss.proxy.Interceptor; 27 28 import javax.management.ObjectName ; 29 30 37 public class InvokerAdaptorClientInterceptor 38 extends Interceptor 39 { 40 42 44 46 public InvokerAdaptorClientInterceptor() 47 { 48 } 50 51 53 56 public Object invoke(Invocation invocation) 57 throws Throwable 58 { 59 ObjectName objectName = getObjectNameFromArguments(invocation); 61 if (objectName != null) 62 invocation.setValue("JMX_OBJECT_NAME", objectName, PayloadKey.AS_IS); 63 64 try 65 { 66 return getNext().invoke(invocation); 67 } 68 catch (InvokerAdaptorException e) 69 { 70 throw e.getWrapped(); 71 } 72 } 73 74 82 public ObjectName getObjectNameFromArguments(Invocation invocation) 83 { 84 String method = invocation.getMethod().getName(); 85 if (method.equals("invoke") || 86 method.equals("setAttribute") || 87 method.equals("setAttributes") || 88 method.equals("addNotificationListener") || 89 method.equals("removeNotificationListener")) 90 { 91 return (ObjectName ) invocation.getArguments()[0]; 92 } 93 94 return null; 95 } 96 97 99 } 101 | Popular Tags |