1 24 25 package org.objectweb.jonas_ws.wsgen.ddmodifier; 26 27 import org.w3c.dom.Document ; 28 import org.w3c.dom.Element ; 29 import org.w3c.dom.Node ; 30 import org.w3c.dom.NodeList ; 31 32 35 public class WebServicesDDModifier extends DeploymentDescModifier { 36 37 40 public WebServicesDDModifier(Document doc) { 41 super(doc.getDocumentElement(), doc); 42 } 43 44 51 public void changeServletLink(String wsdName, String link, String replace) { 52 53 Element wsd = findWebserviceDesc(wsdName); 54 55 if (wsd != null) { 57 NodeList nl = wsd.getElementsByTagNameNS(J2EE_NS, "port-component"); 58 59 for (int i = 0; i < nl.getLength(); i++) { 60 Element e = (Element ) nl.item(i); 61 NodeList sib = e.getElementsByTagNameNS(J2EE_NS, "service-impl-bean"); 62 63 Node servletLink = ((Element ) sib.item(0)).getElementsByTagNameNS(J2EE_NS, "servlet-link").item(0); 64 65 if (servletLink.getFirstChild().getNodeValue().equals(link)) { 68 servletLink.getFirstChild().setNodeValue(replace); 69 } 70 } 71 } 72 } 73 74 82 private Element findWebserviceDesc(String name) { 83 NodeList nl = getElement().getElementsByTagNameNS(J2EE_NS, "webservice-description"); 84 Element wsd = null; 85 86 for (int i = 0; (i < nl.getLength()) && (wsd == null); i++) { 87 Element e = (Element ) nl.item(i); 88 89 NodeList names = e.getElementsByTagNameNS(J2EE_NS, "webservice-description-name"); 90 91 if (names.item(0).getFirstChild().getNodeValue().equals(name)) { 94 wsd = e; 95 } 96 } 97 98 return wsd; 99 } 100 101 } | Popular Tags |