1 25 26 package org.objectweb.easybeans.examples.statelessbean; 27 28 import java.lang.reflect.Method ; 29 30 import javax.annotation.PostConstruct; 31 import javax.interceptor.AroundInvoke; 32 import javax.interceptor.InvocationContext; 33 34 38 public class StatelessInterceptor { 39 40 46 @SuppressWarnings ("finally") 47 @AroundInvoke 48 public Object toto(final InvocationContext invocationContext) throws Exception { 49 System.out.println("Another class interceptor"); 50 Method m = invocationContext.getMethod(); 51 Object returnedValue = null; 53 try { 54 returnedValue = invocationContext.proceed(); 55 } finally { 56 if (m.getName().equals("add")) { 57 return returnedValue; 60 } 61 return returnedValue; 62 } 63 } 64 65 69 @PostConstruct 70 public void myPostConst(final InvocationContext invocationContext) { 71 System.out.println("postConstruct in class Statelesslistener of bean " + invocationContext.getTarget()); 72 try { 73 invocationContext.proceed(); 74 } catch (Exception e) { 75 throw new RuntimeException ("Cannot proceed invocationContext", e); 76 } 77 } 78 79 } 80 | Popular Tags |