1 23 package com.sun.enterprise.deployment.annotation.context; 24 25 import java.util.ArrayList ; 26 import java.util.List ; 27 28 import java.lang.annotation.ElementType ; 29 import java.lang.reflect.AnnotatedElement ; 30 31 import com.sun.enterprise.deployment.WebBundleDescriptor; 32 import com.sun.enterprise.deployment.WebComponentDescriptor; 33 import com.sun.enterprise.deployment.annotation.AnnotatedElementHandler; 34 import com.sun.enterprise.deployment.types.HandlerChainContainer; 35 import com.sun.enterprise.deployment.WebServiceEndpoint; 36 import com.sun.enterprise.deployment.ServiceReferenceDescriptor; 37 38 45 public class WebBundleContext extends ResourceContainerContextImpl { 46 47 public WebBundleContext(WebBundleDescriptor webBundleDescriptor) { 48 super(webBundleDescriptor); 49 } 50 51 public WebBundleDescriptor getDescriptor() { 52 return (WebBundleDescriptor)descriptor; 53 } 54 55 60 public AnnotatedElementHandler createContextForWeb() { 61 AnnotatedElement anTypeElement = 62 this.getProcessingContext().getProcessor( 63 ).getLastAnnotatedElement(ElementType.TYPE); 64 WebComponentDescriptor[] webComps = null; 65 if (anTypeElement != null) { 66 String implClassName = ((Class )anTypeElement).getName(); 67 webComps = getDescriptor().getWebComponentByImplName(implClassName); 68 } 69 70 AnnotatedElementHandler aeHandler = null; 71 if (webComps != null && webComps.length > 1) { 72 aeHandler = new WebComponentsContext(webComps); 73 } else if (webComps != null && webComps.length == 1) { 74 aeHandler = new WebComponentContext(webComps[0]); 75 } 76 77 if (aeHandler != null) { 78 this.getProcessingContext().pushHandler(aeHandler); 80 } 81 return aeHandler; 82 } 83 84 public HandlerChainContainer[] 85 getHandlerChainContainers(boolean serviceSideHandlerChain, Class declaringClass) { 86 if(serviceSideHandlerChain) { 87 List <WebServiceEndpoint> result = new ArrayList <WebServiceEndpoint>(); 88 for (WebServiceEndpoint endpoint : getDescriptor().getWebServices().getEndpoints()) { 89 if (endpoint.getWebComponentImpl().getWebComponentImplementation().equals(declaringClass.getName())) { 90 result.add(endpoint); 91 } 92 } 93 return(result.toArray(new HandlerChainContainer[0])); 94 } else { 95 List <ServiceReferenceDescriptor> result = new ArrayList <ServiceReferenceDescriptor>(); 96 result.addAll(getDescriptor().getServiceReferenceDescriptors()); 97 return(result.toArray(new HandlerChainContainer[0])); 98 } 99 } 100 } 101 | Popular Tags |