1 22 package org.jboss.test.aop.marshalling; 23 24 import java.rmi.MarshalledObject ; 25 26 import org.jboss.aop.advice.Interceptor; 27 import org.jboss.aop.joinpoint.Invocation; 28 import org.jboss.aop.joinpoint.MethodInvocation; 29 30 35 public class MarshallingInterceptor implements Interceptor 36 { 37 38 public String getName() 39 { 40 return "MarshallingInterceptor"; 41 } 42 43 public Object invoke(Invocation invocation) throws Throwable 44 { 45 Object [] args = ((MethodInvocation)invocation).getArguments(); 46 47 MarshalledObject mo = new MarshalledObject (invocation); 48 MethodInvocation inv = (MethodInvocation)mo.get(); 49 50 Object [] margs = inv.getArguments(); 51 52 if (args != null) 53 { 54 if (margs == null) throw new RuntimeException ("Unmarshalled args were null"); 55 if (margs.length != args.length) throw new RuntimeException ("Wrong length, expected " + args.length + ", actual " + margs.length); 56 for (int i = 0 ; i < args.length ; i++) 57 { 58 if (!args[i].equals(margs[i])) 59 { 60 throw new RuntimeException (i + " expcted " + args[i] + ", actual " + margs[i]); 61 } 62 } 63 } 64 65 return invocation.invokeNext(); 66 } 67 68 } 69 | Popular Tags |