1 22 package org.jboss.ejb.plugins; 23 24 import org.jboss.invocation.Invocation; 25 import org.jboss.invocation.InvocationType; 26 27 import javax.ejb.TimerHandle ; 28 29 38 public class CallValidationInterceptor 39 extends AbstractInterceptor 40 { 41 43 45 47 49 51 53 public Object invokeHome(final Invocation mi) throws Exception 54 { 55 validateArguments(mi); 56 Object obj = getNext().invokeHome(mi); 57 return validateReturnValue(mi, obj); 58 } 59 60 public Object invoke(final Invocation mi) throws Exception 61 { 62 validateArguments(mi); 63 Object obj = getNext().invoke(mi); 64 return validateReturnValue(mi, obj); 65 } 66 67 68 protected void validateArguments(Invocation mi) 69 { 70 if (mi.getType() == InvocationType.REMOTE) 71 { 72 Object [] params = mi.getArguments(); 73 for (int i = 0; i < params.length; i++) 74 { 75 Object obj = params[i]; 76 if (obj instanceof TimerHandle ) 77 throw new IllegalArgumentException ("Cannot pass TimerHandle through remote interface"); 78 } 79 } 80 } 81 82 83 protected Object validateReturnValue(Invocation mi, Object retValue) 84 { 85 if (mi.getType() == InvocationType.REMOTE) 86 { 87 if (retValue instanceof TimerHandle ) 88 throw new IllegalArgumentException ("Cannot return TimerHandle from remote interface"); 89 } 90 return retValue; 91 } 92 93 } 94 | Popular Tags |