1 23 package com.sun.enterprise.deployment.annotation.handlers; 24 25 import java.lang.annotation.Annotation ; 26 import java.lang.annotation.ElementType ; 27 28 import com.sun.enterprise.deployment.annotation.AnnotatedElementHandler; 29 import com.sun.enterprise.deployment.annotation.AnnotationInfo; 30 import com.sun.enterprise.deployment.annotation.AnnotationProcessorException; 31 import com.sun.enterprise.deployment.annotation.HandlerProcessingResult; 32 import com.sun.enterprise.deployment.annotation.context.EjbBundleContext; 33 import com.sun.enterprise.deployment.annotation.context.EjbContext; 34 import com.sun.enterprise.deployment.annotation.context.EjbsContext; 35 import com.sun.enterprise.deployment.annotation.context.ResourceContainerContext; 36 import com.sun.enterprise.deployment.annotation.context.WebBundleContext; 37 import com.sun.enterprise.deployment.annotation.context.WebComponentContext; 38 import com.sun.enterprise.deployment.annotation.context.WebComponentsContext; 39 40 55 abstract class AbstractResourceHandler extends AbstractHandler { 56 61 protected abstract HandlerProcessingResult processAnnotation( 62 AnnotationInfo ainfo, 63 ResourceContainerContext[] rcContexts) 64 throws AnnotationProcessorException; 65 66 74 public HandlerProcessingResult processAnnotation(AnnotationInfo ainfo) 75 throws AnnotationProcessorException { 76 77 AnnotatedElementHandler aeHandler = ainfo.getProcessingContext().getHandler(); 78 if (aeHandler instanceof EjbBundleContext) { 79 EjbBundleContext ejbBundleContext = (EjbBundleContext)aeHandler; 80 aeHandler = ejbBundleContext.createContextForEjb(); 81 if (aeHandler == null) { 82 aeHandler = ejbBundleContext.createContextForEjbInterceptor(); 83 } 84 } 85 87 if (aeHandler == null) { 88 return getInvalidAnnotatedElementHandlerResult( 90 ainfo.getProcessingContext().getHandler(), ainfo); 91 } 92 ResourceContainerContext[] rcContexts = null; 93 if (aeHandler instanceof EjbsContext) { 94 EjbsContext ejbsContext = (EjbsContext)aeHandler; 95 rcContexts = (ResourceContainerContext[])ejbsContext.getEjbContexts(); 96 } else if (aeHandler instanceof WebComponentsContext) { 97 WebComponentsContext webCompsContext = (WebComponentsContext)aeHandler; 98 rcContexts = (ResourceContainerContext[])webCompsContext.getWebComponentContexts(); 99 } else if (aeHandler instanceof ResourceContainerContext) { 100 rcContexts = new ResourceContainerContext[] { 101 (ResourceContainerContext)aeHandler }; 102 } else { 103 return getInvalidAnnotatedElementHandlerResult(aeHandler, ainfo); 104 } 105 106 return processAnnotation(ainfo, rcContexts); 107 } 108 109 public Class <? extends Annotation >[] getTypeDependencies() { 110 return getEjbAnnotationTypes(); 111 } 112 } 113 | Popular Tags |