1 25 26 package org.objectweb.jonas_ws.deployment.api; 27 28 import java.util.HashMap ; 29 import java.util.Iterator ; 30 import java.util.List ; 31 import java.util.Map ; 32 import java.util.Set ; 33 import java.util.Vector ; 34 35 import org.objectweb.jonas_lib.I18n; 36 import org.objectweb.jonas_lib.deployment.api.AbsDeploymentDesc; 37 38 import org.objectweb.jonas_ws.deployment.xml.JonasWebserviceDescription; 39 import org.objectweb.jonas_ws.deployment.xml.JonasWebservices; 40 import org.objectweb.jonas_ws.deployment.xml.WebserviceDescription; 41 import org.objectweb.jonas_ws.deployment.xml.Webservices; 42 43 import org.objectweb.util.monolog.api.BasicLevel; 44 import org.objectweb.util.monolog.api.Logger; 45 46 54 public class WSDeploymentDesc extends AbsDeploymentDesc { 55 56 57 private Vector services = new Vector (); 58 59 60 private String displayName; 61 62 63 private String warFile = null; 64 65 66 private Logger logger; 67 68 71 private static I18n i18n = I18n.getInstance(WSDeploymentDesc.class); 72 73 76 private String contextRoot = null; 77 78 89 public WSDeploymentDesc(ClassLoader jarCL, Logger log, Webservices ws, JonasWebservices jws) 90 throws WSDeploymentDescException { 91 this.logger = log; 92 93 displayName = ws.getDisplayName(); 95 96 if (jws != null) { 98 if (jws.getWar() != null) { 99 warFile = jws.getWar(); 100 } 101 String ctx = jws.getContextRoot(); 103 if (ctx != null && !"".equals(ctx)) { 104 contextRoot = ctx; 105 } 106 107 } 108 109 List wdl = ws.getWebserviceDescriptionList(); 111 Map links = associateWDAndJWD(ws, jws); 112 113 for (int i = 0; i < wdl.size(); i++) { 114 WebserviceDescription wd = (WebserviceDescription) wdl.get(i); 115 JonasWebserviceDescription jwd = (JonasWebserviceDescription) links.get(wd.getWebserviceDescriptionName()); 116 services.add(new ServiceDesc(jarCL, wd, jwd)); 117 } 118 119 Vector serviceNames = new Vector (); 123 124 for (int i = 0; i < services.size(); i++) { 125 String sn = ((ServiceDesc) services.get(i)).getName(); 126 127 if (serviceNames.contains(sn)) { 128 String err = getI18n().getMessage("WSDeploymentDesc.serviceNameNotUnique", sn); logger.log(BasicLevel.ERROR, err); 131 throw new WSDeploymentDescException(err); 132 } 133 134 serviceNames.add(sn); 135 } 136 137 Vector pcNames = new Vector (); 140 141 for (int i = 0; i < services.size(); i++) { 142 ServiceDesc s = (ServiceDesc) services.get(i); 143 List pcl = s.getPortComponents(); 144 145 for (int j = 0; j < pcl.size(); j++) { 146 PortComponentDesc pcd = (PortComponentDesc) pcl.get(j); 147 String pcn = pcd.getName(); 148 149 if (pcNames.contains(pcn)) { 150 String err = getI18n().getMessage("WSDeploymentDesc.portCompNameNotUnique", pcn); logger.log(BasicLevel.ERROR, err); 154 throw new WSDeploymentDescException(err); 155 } 156 157 pcNames.add(pcn); 158 } 159 } 160 161 Vector pcQNames = new Vector (); 164 165 for (int i = 0; i < services.size(); i++) { 166 List pcl = ((ServiceDesc) services.get(i)).getPortComponents(); 167 168 for (int j = 0; j < pcl.size(); j++) { 169 PortComponentDesc pc = (PortComponentDesc) pcl.get(j); 170 pcQNames.add(pc.getQName()); 171 } 172 } 173 174 for (int i = 0; i < services.size(); i++) { 176 WSDLFile wsdlf = ((ServiceDesc) services.get(i)).getWSDL(); 177 178 if (!wsdlf.hasPortsIncludedIn(pcQNames)) { 179 String err = getI18n().getMessage("WSDeploymentDesc.wsdlDeclareUnknownPort", wsdlf.getName()); logger.log(BasicLevel.ERROR, err); 181 throw new WSDeploymentDescException(err); 182 } 183 } 184 } 185 186 192 private Map associateWDAndJWD(Webservices ws, JonasWebservices jws) { 193 Map res = new HashMap (); 194 for (Iterator i = ws.getWebserviceDescriptionList().iterator(); i.hasNext();) { 196 WebserviceDescription wsd = (WebserviceDescription) i.next(); 197 res.put(wsd.getWebserviceDescriptionName(), null); 198 } 199 if (jws != null) { 201 202 Set keys = res.keySet(); 204 205 for (Iterator i = jws.getJonasWebserviceDescriptionList().iterator(); i.hasNext();) { 207 JonasWebserviceDescription jwsd = (JonasWebserviceDescription) i.next(); 208 String wsdName = jwsd.getWebserviceDescriptionName(); 209 210 if (keys.contains(wsdName)) { 211 res.put(wsdName, jwsd); 213 } else { 214 String err = "jonas-webservice-description '" + wsdName + "' is not linked to any webservice-description. It will be ignored."; logger.log(BasicLevel.WARN, err); 216 } 217 } 218 } 219 return res; 220 } 221 222 226 public List getServiceDescs() { 227 return services; 228 } 229 230 234 public String getDisplayName() { 235 return displayName; 236 } 237 238 241 public String getContextRoot() { 242 return contextRoot; 243 } 244 245 249 public String toString() { 250 StringBuffer sb = new StringBuffer (); 251 252 sb.append("\nWSDeploymentDesc :"); sb.append("\ngetDisplayName()=" + getDisplayName()); 255 for (Iterator i = getServiceDescs().iterator(); i.hasNext();) { 256 sb.append("\ngetServiceDesc()=" + ((ServiceDesc) i.next()).toString()); } 258 259 sb.append("\ngetWarFile()=" + getWarFile()); 261 return sb.toString(); 262 } 263 264 271 public String getWarFile() { 272 return warFile; 273 } 274 275 278 protected static I18n getI18n() { 279 return i18n; 280 } 281 } | Popular Tags |