1 23 package com.sun.enterprise.deployment.annotation.handlers; 24 25 import java.lang.annotation.ElementType ; 26 import java.util.logging.Level ; 27 28 import com.sun.enterprise.deployment.EjbDescriptor; 29 import com.sun.enterprise.deployment.WebComponentDescriptor; 30 import com.sun.enterprise.deployment.annotation.AnnotatedElementHandler; 31 import com.sun.enterprise.deployment.annotation.AnnotationInfo; 32 import com.sun.enterprise.deployment.annotation.AnnotationProcessorException; 33 import com.sun.enterprise.deployment.annotation.HandlerProcessingResult; 34 import com.sun.enterprise.deployment.annotation.context.ComponentContext; 35 import com.sun.enterprise.deployment.annotation.context.EjbBundleContext; 36 import com.sun.enterprise.deployment.annotation.context.EjbContext; 37 import com.sun.enterprise.deployment.annotation.context.EjbsContext; 38 import com.sun.enterprise.deployment.annotation.context.WebBundleContext; 39 import com.sun.enterprise.deployment.annotation.context.WebComponentContext; 40 import com.sun.enterprise.deployment.annotation.context.WebComponentsContext; 41 42 63 abstract class AbstractCommonAttributeHandler extends AbstractHandler { 64 70 protected abstract HandlerProcessingResult processAnnotation( 71 AnnotationInfo ainfo, EjbContext[] ejbContexts) 72 throws AnnotationProcessorException; 73 74 80 protected abstract HandlerProcessingResult processAnnotation( 81 AnnotationInfo ainfo, WebComponentContext[] webCompContexts) 82 throws AnnotationProcessorException; 83 84 90 protected abstract HandlerProcessingResult processAnnotation( 91 AnnotationInfo ainfo, WebBundleContext webBundleContext) 92 throws AnnotationProcessorException; 93 94 102 public HandlerProcessingResult processAnnotation(AnnotationInfo ainfo) 103 throws AnnotationProcessorException { 104 105 AnnotatedElementHandler aeHandler = ainfo.getProcessingContext().getHandler(); 106 if (aeHandler instanceof EjbBundleContext) { 107 EjbBundleContext ejbBundleContext = (EjbBundleContext)aeHandler; 108 aeHandler = ejbBundleContext.createContextForEjb(); 109 } else if (aeHandler instanceof WebBundleContext) { 110 WebBundleContext webBundleContext = (WebBundleContext)aeHandler; 111 aeHandler = webBundleContext.createContextForWeb(); 112 if (aeHandler == null) { 113 aeHandler = ainfo.getProcessingContext().getHandler(); 115 } 116 } 117 118 if (aeHandler == null) { 119 return getInvalidAnnotatedElementHandlerResult( 121 ainfo.getProcessingContext().getHandler(), ainfo); 122 } 123 124 if (!supportTypeInheritance() && 125 ElementType.TYPE.equals(ainfo.getElementType()) && 126 aeHandler instanceof ComponentContext) { 127 ComponentContext context = (ComponentContext)aeHandler; 128 Class clazz = (Class )ainfo.getAnnotatedElement(); 129 if (!clazz.getName().equals(context.getComponentClassName())) { 130 if (logger.isLoggable(Level.WARNING)) { 131 log(Level.WARNING, ainfo, 132 localStrings.getLocalString( 133 "enterprise.deployment.annotation.handlers.typeinhernotsupp", 134 "The annotation symbol inheritance is not supported.")); 135 } 136 return getDefaultProcessedResult(); 137 } 138 } 139 140 HandlerProcessingResult procResult = null; 141 if (aeHandler instanceof EjbContext) { 142 procResult = processAnnotation(ainfo, new EjbContext[] { (EjbContext)aeHandler }); 143 } else if (aeHandler instanceof EjbsContext) { 144 EjbsContext ejbsContext = (EjbsContext)aeHandler; 145 procResult = processAnnotation(ainfo, ejbsContext.getEjbContexts()); 146 } else if (aeHandler instanceof WebComponentContext) { 147 procResult = processAnnotation(ainfo, 148 new WebComponentContext[] { (WebComponentContext)aeHandler }); 149 } else if (aeHandler instanceof WebComponentsContext) { 150 WebComponentsContext webCompsContext = (WebComponentsContext)aeHandler; 151 procResult = processAnnotation(ainfo, webCompsContext.getWebComponentContexts()); 152 } else if (aeHandler instanceof WebBundleContext) { 153 WebBundleContext webBundleContext = (WebBundleContext)aeHandler; 154 procResult = processAnnotation(ainfo, webBundleContext); 155 } else { 156 return getInvalidAnnotatedElementHandlerResult(aeHandler, ainfo); 157 } 158 159 return procResult; 160 } 161 162 166 protected boolean supportTypeInheritance() { 167 return false; 168 } 169 } 170 | Popular Tags |