1 23 package com.sun.enterprise.deployment; 24 25 import java.util.Iterator ; 26 import java.util.Collection ; 27 import java.util.HashSet ; 28 29 import javax.enterprise.deploy.shared.ModuleType ; 30 import com.sun.enterprise.deployment.node.WebServicesDescriptorNode; 31 32 38 39 public class WebServicesDescriptor extends RootDeploymentDescriptor { 40 41 private BundleDescriptor bundleDesc; 43 44 private Collection <WebService> webServices; 45 48 public WebServicesDescriptor() { 49 webServices = new HashSet <WebService>(); 50 } 51 52 56 public String getDefaultSpecVersion() { 57 return WebServicesDescriptorNode.SPEC_VERSION; 58 } 59 60 public void setBundleDescriptor(BundleDescriptor module) { 61 bundleDesc = module; 62 } 63 64 public BundleDescriptor getBundleDescriptor() { 65 return bundleDesc; 66 } 67 68 public boolean hasWebServices() { 69 return !(webServices.isEmpty()); 70 } 71 72 public WebService getWebServiceByName(String webServiceName) { 73 for (WebService webService : webServices) { 74 if( webService.getName().equals(webServiceName) ) { 75 return webService; 76 } 77 } 78 return null; 79 } 80 81 public void addWebService(WebService descriptor) { 82 descriptor.setWebServicesDescriptor(this); 83 webServices.add(descriptor); 84 super.changed(); 85 } 86 87 public void removeWebService(WebService descriptor) { 88 descriptor.setWebServicesDescriptor(null); 89 webServices.remove(descriptor); 90 super.changed(); 91 } 92 93 public Collection <WebService> getWebServices() { 94 return new HashSet <WebService>(webServices); 95 } 96 97 101 public WebServiceEndpoint getEndpointByName(String endpointName) { 102 for(Iterator iter = getEndpoints().iterator(); iter.hasNext();) { 103 WebServiceEndpoint next = (WebServiceEndpoint) iter.next(); 104 if( next.getEndpointName().equals(endpointName) ) { 105 return next; 106 } 107 } 108 return null; 109 } 110 111 public boolean hasEndpointsImplementedBy(EjbDescriptor ejb) { 112 return !(getEndpointsImplementedBy(ejb).isEmpty()); 113 } 114 115 public Collection <WebServiceEndpoint> getEndpointsImplementedBy(EjbDescriptor ejb) { 116 Collection <WebServiceEndpoint> endpoints = new HashSet (); 117 if( ejb instanceof EjbSessionDescriptor ) { 118 for(WebServiceEndpoint next : getEndpoints()) { 119 if( next.implementedByEjbComponent(ejb) ) { 120 endpoints.add(next); 121 } 122 } 123 } 124 return endpoints; 125 } 126 127 public boolean hasEndpointsImplementedBy(WebComponentDescriptor desc) { 128 return !(getEndpointsImplementedBy(desc).isEmpty()); 129 } 130 131 public Collection <WebServiceEndpoint> getEndpointsImplementedBy(WebComponentDescriptor desc) { 132 Collection <WebServiceEndpoint> endpoints = new HashSet (); 133 for(WebServiceEndpoint next : getEndpoints()) { 134 if( next.implementedByWebComponent(desc) ) { 135 endpoints.add(next); 136 } 137 } 138 return endpoints; 139 } 140 141 public Collection <WebServiceEndpoint> getEndpoints() { 142 Collection allEndpoints = new HashSet (); 143 for(WebService webService : webServices) { 144 allEndpoints.addAll( webService.getEndpoints() ); 145 } 146 return allEndpoints; 147 } 148 149 public ModuleType getModuleType() { 150 if (bundleDesc!=null) { 151 return bundleDesc.getModuleType(); 152 } 153 return null; 154 } 155 156 157 public String getModuleID() { return ""; } 162 public ClassLoader getClassLoader() { return null; } 163 public boolean isApplication() {return false; } 164 165 168 public void print(StringBuffer toStringBuffer) { 169 super.print(toStringBuffer); 170 if (hasWebServices()) { 171 for (Iterator itr = getWebServices().iterator();itr.hasNext();) { 172 WebService aWebService = (WebService) itr.next(); 173 toStringBuffer.append("\n Web Service : "); 174 aWebService.print(toStringBuffer); 175 } 176 } 177 } 178 179 } 180 | Popular Tags |