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.TimerServiceTester; 39 40 46 public class AllLifeCallbackTimerServiceAccess00 extends TimerServiceTester { 47 48 51 private JLog logger = JLogFactory.getLog(AllLifeCallbackTimerServiceAccess00.class); 52 53 56 @EJB (beanName = "SLSBCallbackLoggerAccess") 57 private ItfCallbackLoggerAccess beanLogger; 58 59 63 @PostActivate 64 public void postActivate(final InvocationContext ic) { 65 this.intercept(ic, CallbackType.POST_ACTIVATE); 66 } 67 68 72 @PostConstruct 73 public void postConstruct(final InvocationContext ic) { 74 this.intercept(ic, CallbackType.POST_CONSTRUCT); 75 } 76 77 81 @PreDestroy 82 public void preDestroy(final InvocationContext ic) { 83 this.intercept(ic, CallbackType.PRE_DESTROY); 84 } 85 86 90 @PrePassivate 91 public void prePassivate(final InvocationContext ic) { 92 this.intercept(ic, CallbackType.PRE_PASSIVATE); 93 } 94 95 100 protected void intercept(final InvocationContext ic, final CallbackType type) { 101 try { 102 String beanClassName = ic.getTarget().getClass().getName(); 103 104 logger.debug("{0} - Testing access - Instance: {1}.", type.name(), beanClassName); 105 super.checkJNDI(); 106 beanLogger.insertCallbackLogger(beanClassName, type, 107 AllLifeCallbackTimerServiceAccess00.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 |