1 25 package org.objectweb.easybeans.tests.common.interceptors.lifecycle.misc; 26 27 import javax.annotation.PostConstruct; 28 import javax.annotation.PreDestroy; 29 import javax.ejb.EJB ; 30 import javax.ejb.PostActivate ; 31 import javax.ejb.PrePassivate ; 32 import javax.interceptor.InvocationContext; 33 34 import org.objectweb.easybeans.log.JLog; 35 import org.objectweb.easybeans.log.JLogFactory; 36 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType; 37 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess; 38 39 45 public class AllLifeCallbackEJBAccess00 { 46 47 50 private JLog logger = JLogFactory.getLog(AllLifeCallbackEJBAccess00.class); 51 52 55 @EJB (beanName="SLSBCallbackLoggerAccess") 56 private ItfCallbackLoggerAccess beanLogger; 57 58 62 @PostActivate 63 public void postActivate(final InvocationContext ic) { 64 this.intercept(ic, CallbackType.POST_ACTIVATE); 65 } 66 67 71 @PostConstruct 72 public void postConstruct(final InvocationContext ic) { 73 this.intercept(ic, CallbackType.POST_CONSTRUCT); 74 } 75 76 80 @PreDestroy 81 public void preDestroy(final InvocationContext ic) { 82 this.intercept(ic, CallbackType.PRE_DESTROY); 83 } 84 85 89 @PrePassivate 90 public void prePassivate(final InvocationContext ic) { 91 this.intercept(ic, CallbackType.PRE_PASSIVATE); 92 } 93 94 99 protected void intercept(final InvocationContext ic, final CallbackType type){ 100 try { 101 String beanClassName = ic.getTarget().getClass().getName(); 102 103 logger.debug("{0} - Testing access - Instance: {1}.", type.name(), beanClassName); 104 beanLogger.insertCallbackLogger(beanClassName, type, AllLifeCallbackEJBAccess00.class.getName()); 105 logger.debug("{0} - Access is ok - Instance: {1}.", type.name(), beanClassName); 106 107 ic.proceed(); 108 } catch (Exception e) { 109 throw new IllegalStateException (type.name() + " Exception. ", e); 110 } 111 } 112 } 113 | Popular Tags |