[jboss-cvs] JBossAS SVN: r76579 - projects/jboss-aspects/trunk/remoting/src/main/java/org/jboss/aspects/remoting.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 1 10:56:00 EDT 2008


Author: ALRubinger
Date: 2008-08-01 10:56:00 -0400 (Fri, 01 Aug 2008)
New Revision: 76579

Modified:
   projects/jboss-aspects/trunk/remoting/src/main/java/org/jboss/aspects/remoting/PojiProxy.java
Log:
Extract out logic in PojiProxy for more flexible extending/overriding

Modified: projects/jboss-aspects/trunk/remoting/src/main/java/org/jboss/aspects/remoting/PojiProxy.java
===================================================================
--- projects/jboss-aspects/trunk/remoting/src/main/java/org/jboss/aspects/remoting/PojiProxy.java	2008-08-01 14:45:00 UTC (rev 76578)
+++ projects/jboss-aspects/trunk/remoting/src/main/java/org/jboss/aspects/remoting/PojiProxy.java	2008-08-01 14:56:00 UTC (rev 76579)
@@ -34,6 +34,7 @@
  * comment
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="andrew.rubinger at jboss.org">ALR</a> Maintain only 
  */
 public class PojiProxy implements java.io.Serializable, InvocationHandler
 {
@@ -47,17 +48,51 @@
    {
       this.oid = oid;
       this.uri = uri;
-      this.interceptors = interceptors;
+      this.interceptors = interceptors;      
    }
 
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
    {
-      long hash = MethodHashing.calculateHash(method);
-      MethodInvocation sri = new MethodInvocation(interceptors, hash, method, method, null);
+      MethodInvocation sri = this.constructMethodInvocation(method, args);
       sri.setArguments(args);
-      sri.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, oid, PayloadKey.AS_IS);
-      sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.INVOKER_LOCATOR, uri, PayloadKey.AS_IS);
-      sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.SUBSYSTEM, "AOP", PayloadKey.AS_IS);
+      this.addMetadataToInvocation(sri);
       return sri.invokeNext();
    }
+   
+   /**
+    * Constructs a MethodInvocation from the specified Method and
+    * arguments
+    * 
+    * @param method
+    * @param args
+    * @return
+    */
+   protected MethodInvocation constructMethodInvocation(Method method, Object[] args)
+   {
+      long hash = MethodHashing.calculateHash(method);
+      MethodInvocation sri = new MethodInvocation(interceptors, hash, method, method, null);
+      return sri;
+   }
+   
+   /**
+    * Adds metadata to the specified MethodInvocation before
+    * invocation is called.  Extracted to allow subclasses to control
+    * which metadata is added to a PojiProxy 
+    * 
+    * @param methodInvocation
+    */
+   protected void addMetadataToInvocation(MethodInvocation methodInvocation)
+   {
+      methodInvocation.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, oid, PayloadKey.AS_IS);
+      methodInvocation.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING,
+            InvokeRemoteInterceptor.INVOKER_LOCATOR, uri, PayloadKey.AS_IS);
+      methodInvocation.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.SUBSYSTEM,
+            "AOP", PayloadKey.AS_IS);
+   }
+
+   protected Interceptor[] getInterceptors()
+   {
+      return interceptors;
+   }
+   
 }




More information about the jboss-cvs-commits mailing list