1 22 package org.jboss.ejb3.test.interceptors2; 23 24 import javax.ejb.EJB ; 25 import javax.annotation.PostConstruct; 26 import javax.interceptor.AroundInvoke; 27 import javax.interceptor.ExcludeClassInterceptors; 28 import javax.interceptor.ExcludeDefaultInterceptors; 29 import javax.interceptor.Interceptors; 30 import javax.interceptor.InvocationContext; 31 import javax.annotation.PreDestroy; 32 import javax.ejb.Remote ; 33 import javax.ejb.Stateless ; 34 35 40 @Stateless 41 @Remote (AnnotatedOnlySLSBRemote.class) 42 @Interceptors(AnnotatedClassInterceptor.class) 43 @ExcludeDefaultInterceptors 44 public class AnnotatedOnlySLSB implements AnnotatedOnlySLSBRemote 45 { 46 @EJB 47 StatusRemote status; 48 49 public void methodWithClassLevel() 50 { 51 System.out.println("AnnotatedOnlySLSB.methodWithClassLevel"); 52 } 53 54 @ExcludeClassInterceptors 55 public void methodExcludingClassInterceptors() 56 { 57 System.out.println("AnnotatedOnlySLSB.methodExcludingClassInterceptors"); 58 } 59 60 @Interceptors(AnnotatedMethodInterceptor.class) 61 public void methodWithOwnInterceptors() 62 { 63 System.out.println("AnnotatedOnlySLSB.methodWithOwnInterceptors"); 64 } 65 66 @Interceptors(AnnotatedMethodInterceptor.class) 67 @ExcludeClassInterceptors 68 public void methodWithOwnInterceptorsExcludeClass() 69 { 70 System.out.println("AnnotatedOnlySLSB.methodWithOwnInterceptors"); 71 } 72 73 @AroundInvoke 74 public Object intercept(InvocationContext ctx) throws Exception 75 { 76 System.out.println("AnnotatedOnlySLSB intercepting!"); 77 status.addInterception(new Interception(this, "intercept")); 78 return ctx.proceed(); 79 } 80 81 @PostConstruct 82 void postConstruct() 83 { 84 System.out.println("AnnotatedOnlySLSB postConstruct"); 85 StatusBean.addPostConstruct(new Interception(this, "postConstruct")); 86 } 87 88 @PreDestroy() 89 void preDestroy() 90 { 91 System.out.println("AnnotatedOnlySLSB preDestroy!"); 92 StatusBean.addPreDestroy(new Interception(this, "preDestroy")); 93 } 94 } 95 | Popular Tags |