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.annotation.Resource; 30 import javax.ejb.EJB ; 31 import javax.ejb.PostActivate ; 32 import javax.ejb.PrePassivate ; 33 import javax.interceptor.InvocationContext; 34 import javax.sql.DataSource ; 35 36 import org.objectweb.easybeans.log.JLog; 37 import org.objectweb.easybeans.log.JLogFactory; 38 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType; 39 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess; 40 import org.objectweb.easybeans.tests.common.resources.JEnvCompTester; 41 42 49 public class AllLifeCallbackJEnvCompAccess00 extends JEnvCompTester{ 50 51 54 private JLog logger = JLogFactory.getLog(AllLifeCallbackJEnvCompAccess00.class); 55 56 59 @SuppressWarnings ("unused") 60 @Resource(name="jdbc/jdbc_1", mappedName="jdbc_1") 61 private DataSource ds; 62 63 66 @EJB (beanName="SLSBCallbackLoggerAccess") 67 private ItfCallbackLoggerAccess beanLogger; 68 69 73 @PostActivate 74 public void postActivate(final InvocationContext ic){ 75 this.intercept(ic, CallbackType.POST_ACTIVATE); 76 } 77 78 82 @PostConstruct 83 public void postConstruct(final InvocationContext ic){ 84 this.intercept(ic, CallbackType.POST_CONSTRUCT); 85 } 86 87 91 @PreDestroy 92 public void preDestroy(final InvocationContext ic){ 93 this.intercept(ic, CallbackType.PRE_DESTROY); 94 } 95 96 100 @PrePassivate 101 public void prePassivate(final InvocationContext ic){ 102 this.intercept(ic, CallbackType.PRE_PASSIVATE); 103 } 104 105 110 protected void intercept(final InvocationContext ic, final CallbackType type){ 111 try { 112 String beanClassName = ic.getTarget().getClass().getName(); 113 114 logger.debug("{0} - Testing access - Instance: {1}.", type.name(), beanClassName); 115 super.access00(); 116 beanLogger.insertCallbackLogger(beanClassName, type, AllLifeCallbackJEnvCompAccess00.class.getName()); 117 logger.debug("{0} - Access is ok - Instance: {1}.", type.name(), beanClassName); 118 119 ic.proceed(); 120 } catch (Exception e) { 121 throw new IllegalStateException (type.name() + " Exception. ", e); 122 } 123 } 124 } 125 | Popular Tags |