1 25 26 package org.objectweb.easybeans.tests.enhancer.interceptors.lifecycle.bean; 27 28 import javax.annotation.PostConstruct; 29 import javax.annotation.PreDestroy; 30 import javax.ejb.PostActivate ; 31 import javax.ejb.PrePassivate ; 32 import javax.interceptor.InvocationContext; 33 34 38 public class MyLifeCycleInterceptorStateful { 39 40 44 @PostConstruct 45 public void xxPostxxxConstruct(final InvocationContext invocationContext) { 46 Object o = invocationContext.getTarget(); 47 if (o instanceof StatefulBean) { 48 StatefulBean bean = (StatefulBean) o; 49 bean.calledPostConstruct(); 50 try { 51 invocationContext.proceed(); 52 } catch (Exception e) { 53 throw new RuntimeException ("Cannot proceed invocationContext", e); 54 } 55 56 } 57 } 58 59 63 @PreDestroy 64 public void theGreatDestroyMethod(final InvocationContext invocationContext) { 65 Object o = invocationContext.getTarget(); 66 if (o instanceof StatefulBean) { 67 StatefulBean bean = (StatefulBean) o; 68 bean.calledPreDestroy(); 69 try { 70 invocationContext.proceed(); 71 } catch (Exception e) { 72 throw new RuntimeException ("Cannot proceed invocationContext", e); 73 } 74 } 75 } 76 77 81 @PrePassivate 82 public void testingPrePassivate(final InvocationContext invocationContext) { 83 Object o = invocationContext.getTarget(); 84 if (o instanceof StatefulBean) { 85 StatefulBean bean = (StatefulBean) o; 86 bean.calledPrePassivate(); 87 try { 88 invocationContext.proceed(); 89 } catch (Exception e) { 90 throw new RuntimeException ("Cannot proceed invocationContext", e); 91 } 92 } 93 } 94 95 99 @PostActivate 100 public void activating(final InvocationContext invocationContext) { 101 Object o = invocationContext.getTarget(); 102 if (o instanceof StatefulBean) { 103 StatefulBean bean = (StatefulBean) o; 104 bean.calledPostActivate(); 105 try { 106 invocationContext.proceed(); 107 } catch (Exception e) { 108 throw new RuntimeException ("Cannot proceed invocationContext", e); 109 } 110 111 } 112 } 113 114 } 115 | Popular Tags |