1 23 package enterprise.interceptor_stateless_ejb; 24 25 import java.lang.reflect.Method ; 26 27 import javax.interceptor.AroundInvoke; 28 import javax.interceptor.InvocationContext; 29 30 public class ArgumentsChecker { 31 32 @AroundInvoke 33 public Object checkArgument(InvocationContext ctx) throws Exception { 34 Method method = ctx.getMethod(); 35 if (method.getName().equals("initUpperCase")) { 36 String param = (String ) (ctx.getParameters()[0]); 37 char c = param.charAt(0); 40 if (!Character.isLetter(c)) { 41 throw new BadArgumentException("Illegal argument: " + param); 45 } 46 } 47 48 return ctx.proceed(); 50 } 51 52 } 53 | Popular Tags |