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.Remove ; 31 32 import com.sun.enterprise.deployment.EjbDescriptor; 33 import com.sun.enterprise.deployment.EjbSessionDescriptor; 34 import com.sun.enterprise.deployment.MethodDescriptor; 35 import com.sun.enterprise.deployment.EjbRemovalInfo; 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 42 46 public class RemoveHandler extends AbstractAttributeHandler { 47 48 public RemoveHandler() { 49 } 50 51 54 public Class <? extends Annotation > getAnnotationType() { 55 return Remove .class; 56 } 57 58 protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, 59 EjbContext[] ejbContexts) throws AnnotationProcessorException { 60 61 Remove remove = (Remove ) ainfo.getAnnotation(); 62 63 for(EjbContext next : ejbContexts) { 64 65 EjbSessionDescriptor sessionDescriptor = 66 (EjbSessionDescriptor) next.getDescriptor(); 67 68 Method m = (Method ) ainfo.getAnnotatedElement(); 69 MethodDescriptor removeMethod = 70 new MethodDescriptor(m, MethodDescriptor.EJB_BEAN); 71 72 EjbRemovalInfo removalInfo = 73 sessionDescriptor.getRemovalInfo(removeMethod); 74 75 if (removalInfo == null) { 76 removalInfo = new EjbRemovalInfo(); 79 removalInfo.setRemoveMethod(removeMethod); 80 removalInfo.setRetainIfException(remove.retainIfException()); 81 sessionDescriptor.addRemoveMethod(removalInfo); 82 } else { 83 if (! removalInfo.isRetainIfExceptionSet()) { 87 removalInfo.setRetainIfException( 88 remove.retainIfException()); 89 } 90 } 91 } 92 93 return getDefaultProcessedResult(); 94 } 95 96 101 public Class <? extends Annotation >[] getTypeDependencies() { 102 return getEjbAnnotationTypes(); 103 } 104 } 105 | Popular Tags |