1 23 package com.sun.enterprise.deployment.annotation.handlers; 24 25 import java.lang.annotation.Annotation ; 26 import java.lang.annotation.ElementType ; 27 import java.lang.reflect.AnnotatedElement ; 28 import java.lang.reflect.Method ; 29 30 import javax.ejb.PrePassivate ; 31 32 import com.sun.enterprise.deployment.EjbDescriptor; 33 import com.sun.enterprise.deployment.EjbInterceptor; 34 import com.sun.enterprise.deployment.EjbSessionDescriptor; 35 import com.sun.enterprise.deployment.LifecycleCallbackDescriptor; 36 37 import com.sun.enterprise.deployment.annotation.AnnotationInfo; 38 import com.sun.enterprise.deployment.annotation.AnnotationProcessorException; 39 import com.sun.enterprise.deployment.annotation.HandlerProcessingResult; 40 import com.sun.enterprise.deployment.annotation.context.EjbContext; 41 import com.sun.enterprise.deployment.annotation.context.EjbInterceptorContext; 42 43 47 public class PrePassivateHandler extends AbstractAttributeHandler { 48 49 public PrePassivateHandler() { 50 } 51 52 55 public Class <? extends Annotation > getAnnotationType() { 56 return PrePassivate .class; 57 } 58 59 protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, 60 EjbContext[] ejbContexts) throws AnnotationProcessorException { 61 62 for(EjbContext next : ejbContexts) { 63 64 EjbSessionDescriptor ejbSessionDescriptor = 65 (EjbSessionDescriptor) next.getDescriptor(); 66 67 ejbSessionDescriptor.addPrePassivateDescriptor( 68 getPrePassivateDescriptor(ainfo)); 69 70 } 71 72 return getDefaultProcessedResult(); 73 } 74 75 protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, 76 EjbInterceptorContext ejbInterceptorContext) 77 throws AnnotationProcessorException { 78 EjbInterceptor ejbInterceptor = ejbInterceptorContext.getDescriptor(); 79 ejbInterceptor.addPrePassivateDescriptor( 80 getPrePassivateDescriptor(ainfo)); 81 return getDefaultProcessedResult(); 82 } 83 84 private LifecycleCallbackDescriptor getPrePassivateDescriptor( 85 AnnotationInfo ainfo) { 86 Method annotatedMethod = (Method ) ainfo.getAnnotatedElement(); 87 LifecycleCallbackDescriptor prePassivate = 88 new LifecycleCallbackDescriptor(); 89 prePassivate.setLifecycleCallbackClass(annotatedMethod.getDeclaringClass().getName()); 90 prePassivate.setLifecycleCallbackMethod(annotatedMethod.getName()); 91 return prePassivate; 92 } 93 94 95 100 public Class <? extends Annotation >[] getTypeDependencies() { 101 return getEjbAnnotationTypes(); 102 } 103 104 protected boolean isDelegatee() { 105 return true; 106 } 107 } 108 | Popular Tags |