1 23 24 29 30 package com.sun.enterprise.deployment.annotation.context; 31 32 import java.util.List ; 33 import java.util.ArrayList ; 34 35 import java.lang.annotation.ElementType ; 36 37 import com.sun.enterprise.deployment.EjbBundleDescriptor; 38 import com.sun.enterprise.deployment.EjbDescriptor; 39 import com.sun.enterprise.deployment.EjbInterceptor; 40 import com.sun.enterprise.deployment.annotation.AnnotatedElementHandler; 41 import com.sun.enterprise.deployment.types.ServiceReferenceContainer; 42 import com.sun.enterprise.deployment.types.HandlerChainContainer; 43 import com.sun.enterprise.deployment.WebServiceEndpoint; 44 import com.sun.enterprise.deployment.ServiceReferenceDescriptor; 45 46 53 public class EjbBundleContext extends ResourceContainerContextImpl { 54 55 56 public EjbBundleContext(EjbBundleDescriptor descriptor) { 57 super(descriptor); 58 } 59 60 public EjbBundleDescriptor getDescriptor() { 61 return (EjbBundleDescriptor)descriptor; 62 } 63 64 69 public AnnotatedElementHandler createContextForEjb() { 70 Class ejbClass = (Class )this.getProcessingContext().getProcessor( 71 ).getLastAnnotatedElement(ElementType.TYPE); 72 EjbDescriptor[] ejbDescs = null; 73 String ejbClassName = null; 74 if (ejbClass != null) { 75 ejbClassName = ejbClass.getName(); 76 ejbDescs = this.getDescriptor().getEjbByClassName(ejbClassName); 77 } 78 79 AnnotatedElementHandler aeHandler = null; 80 if (ejbDescs != null && ejbDescs.length > 1) { 81 aeHandler = new EjbsContext(ejbDescs, ejbClass); 82 } else if (ejbDescs != null && ejbDescs.length == 1) { 83 aeHandler = new EjbContext(ejbDescs[0], ejbClass); 84 } 85 86 if (aeHandler != null) { 87 this.getProcessingContext().pushHandler(aeHandler); 89 } 90 return aeHandler; 91 } 92 93 public HandlerChainContainer[] 94 getHandlerChainContainers(boolean serviceSideHandlerChain, Class declaringClass) { 95 if(serviceSideHandlerChain) { 96 EjbDescriptor[] ejbs = getDescriptor().getEjbByClassName(declaringClass.getName()); 97 List <WebServiceEndpoint> result = new ArrayList <WebServiceEndpoint>(); 98 for (EjbDescriptor ejb : ejbs) { 99 result.addAll(getDescriptor().getWebServices().getEndpointsImplementedBy(ejb)); 100 } 101 return(result.toArray(new HandlerChainContainer[0])); 102 } else { 103 List <ServiceReferenceDescriptor> result = new ArrayList <ServiceReferenceDescriptor>(); 104 result.addAll(getDescriptor().getServiceReferenceDescriptors()); 105 return(result.toArray(new HandlerChainContainer[0])); 106 } 107 } 108 109 public ServiceReferenceContainer[] getServiceRefContainers() { 110 ServiceReferenceContainer[] container = 111 new ServiceReferenceContainer[getDescriptor().getEjbs().size()]; 112 ServiceReferenceContainer[] ret = 113 (ServiceReferenceContainer[])getDescriptor().getEjbs().toArray(container); 114 return ret; 115 } 116 117 122 public AnnotatedElementHandler createContextForEjbInterceptor() { 123 Class interceptorClass = 124 (Class )this.getProcessingContext().getProcessor( 125 ).getLastAnnotatedElement(ElementType.TYPE); 126 EjbInterceptor ejbInterceptor = 127 this.getDescriptor().getInterceptorByClassName( 128 interceptorClass.getName()); 129 130 AnnotatedElementHandler aeHandler = null; 131 if (ejbInterceptor != null) { 132 aeHandler = new EjbInterceptorContext(ejbInterceptor); 133 this.getProcessingContext().pushHandler(aeHandler); 135 } 136 return aeHandler; 137 } 138 } 139 | Popular Tags |