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.PostActivate ; 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 PostActivateHandler extends AbstractAttributeHandler { 48 49 public PostActivateHandler() { 50 } 51 52 55 public Class <? extends Annotation > getAnnotationType() { 56 return PostActivate .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.addPostActivateDescriptor( 68 getPostActivateDescriptor(ainfo)); 69 70 } 71 72 return getDefaultProcessedResult(); 73 } 74 75 protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, 76 EjbInterceptorContext ejbInterceptorContext) 77 throws AnnotationProcessorException { 78 79 EjbInterceptor ejbInterceptor = ejbInterceptorContext.getDescriptor(); 80 ejbInterceptor.addPostActivateDescriptor( 81 getPostActivateDescriptor(ainfo)); 82 return getDefaultProcessedResult(); 83 } 84 85 private LifecycleCallbackDescriptor getPostActivateDescriptor( 86 AnnotationInfo ainfo) { 87 Method annotatedMethod = (Method ) ainfo.getAnnotatedElement(); 88 LifecycleCallbackDescriptor postActivate = 89 new LifecycleCallbackDescriptor(); 90 postActivate.setLifecycleCallbackClass(annotatedMethod.getDeclaringClass().getName()); 91 postActivate.setLifecycleCallbackMethod(annotatedMethod.getName()); 92 return postActivate; 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 |