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 import org.objectweb.easybeans.tests.common.resources.EMFactoryTester; 39 40 47 public class AllLifeCallbackEMFactoryAccess00 extends EMFactoryTester{ 48 49 52 private JLog logger = JLogFactory.getLog(AllLifeCallbackEMFactoryAccess00.class); 53 54 57 @EJB (beanName="SLSBCallbackLoggerAccess") 58 private ItfCallbackLoggerAccess beanLogger; 59 60 64 @PostActivate 65 public void postActivate(final InvocationContext ic){ 66 this.intercept(ic, CallbackType.POST_ACTIVATE); 67 } 68 69 73 @PostConstruct 74 public void postConstruct(final InvocationContext ic){ 75 this.intercept(ic, CallbackType.POST_CONSTRUCT); 76 } 77 78 82 @PreDestroy 83 public void preDestroy(final InvocationContext ic){ 84 this.intercept(ic, CallbackType.PRE_DESTROY); 85 } 86 87 91 @PrePassivate 92 public void prePassivate(final InvocationContext ic){ 93 this.intercept(ic, CallbackType.PRE_PASSIVATE); 94 } 95 96 101 protected void intercept(final InvocationContext ic, final CallbackType type){ 102 try { 103 String beanClassName = ic.getTarget().getClass().getName(); 104 105 logger.debug("{0} - Testing access - Instance: {1}.", type.name(), beanClassName); 106 super.access00(); 107 beanLogger.insertCallbackLogger(beanClassName, type, AllLifeCallbackEMFactoryAccess00.class.getName()); 108 logger.debug("{0} - Access is ok - Instance: {1}.", type.name(), beanClassName); 109 110 ic.proceed(); 111 } catch (Exception e) { 112 throw new IllegalStateException (type.name() + " Exception. ", e); 113 } 114 } 115 } 116 | Popular Tags |