Return-Path: Delivered-To: apmail-xml-axis-dev-archive@xml.apache.org Received: (qmail 13670 invoked by uid 500); 3 Dec 2001 03:49:33 -0000 Mailing-List: contact axis-dev-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-dev@xml.apache.org Received: (qmail 13661 invoked by uid 500); 3 Dec 2001 03:49:33 -0000 Delivered-To: apmail-xml-axis-cvs@apache.org Date: 3 Dec 2001 03:31:31 -0000 Message-ID: <20011203033131.17889.qmail@icarus.apache.org> From: gdaniels@apache.org To: xml-axis-cvs@apache.org Subject: cvs commit: xml-axis/java/src/org/apache/axis/utils resources.properties X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N gdaniels 01/12/02 19:31:31 Modified: java/src/org/apache/axis AxisEngine.java java/src/org/apache/axis/deployment/wsdd WSDDConstants.java WSDDDeployment.java WSDDDocument.java java/src/org/apache/axis/encoding SerializationContext.java java/src/org/apache/axis/utils resources.properties Added: java/src/org/apache/axis/deployment/wsdd WSDDUndeployment.java Log: Add WSDD undeployment functionality through the AdminClient. When a WSDD document is initialized from a DOM document, it now creates either a WSDDDeployment or a WSDDUndeployment depending on the top-level element name. A WSDDUndeployment initializes itself by looking for , , , and child elements, and remembering the type and "name" attribute value for each one (since name is the only thing undeployment needs to know about). When a WSDDDocument with an undeployment inside it is deployed, it removes the various components from the registry. Also added a convenience method in SerializationContext for writing an element with no content. Revision Changes Path 1.57 +10 -8 xml-axis/java/src/org/apache/axis/AxisEngine.java Index: AxisEngine.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisEngine.java,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- AxisEngine.java 2001/11/26 02:21:38 1.56 +++ AxisEngine.java 2001/12/03 03:31:31 1.57 @@ -314,7 +314,15 @@ static String [] booleanOptions = new String [] { PROP_DOMULTIREFS, PROP_SEND_XSI, PROP_XML_DECL }; - + + /** + * Deploy a WSDD document to this engine. This will either add or + * remove Handlers/Services/Transports/etc. depending on whether the + * WSDD is a or an + * + * @param doc the WSDD document to deploy. + * @throws DeploymentException if there is a problem. + */ public void deployWSDD(WSDDDocument doc) throws DeploymentException { myRegistry.deploy(doc); @@ -347,14 +355,8 @@ setAdminPassword((String)getOption(PROP_PASSWORD)); } } - - public void undeployWSDD(WSDDDocument doc) - throws DeploymentException - { - doc.undeploy(myRegistry); - } - /** + /** * Deploy a Handler into our handler registry */ public void deployHandler(String key, Handler handler) 1.12 +2 -0 xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java Index: WSDDConstants.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- WSDDConstants.java 2001/11/25 23:49:33 1.11 +++ WSDDConstants.java 2001/12/03 03:31:31 1.12 @@ -93,6 +93,8 @@ "documentation"); public static final QName DEPLOY_QNAME = new QName(WSDD_NS, "deployment"); + public static final QName UNDEPLOY_QNAME = new QName(WSDD_NS, + "undeployment"); public static final QName REQFLOW_QNAME = new QName(WSDD_NS, "requestFlow"); public static final QName RESPFLOW_QNAME = new QName(WSDD_NS, 1.15 +75 -2 xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDDeployment.java Index: WSDDDeployment.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDDeployment.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- WSDDDeployment.java 2001/11/26 00:58:35 1.14 +++ WSDDDeployment.java 2001/12/03 03:31:31 1.15 @@ -58,7 +58,9 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.apache.axis.Constants; -import org.apache.axis.encoding.SerializationContext; +import org.apache.axis.deployment.DeploymentRegistry; +import org.apache.axis.deployment.DeploymentException; +import org.apache.axis.encoding.*; import javax.xml.rpc.namespace.QName; import java.util.Vector; @@ -166,7 +168,78 @@ { return WSDDConstants.DEPLOY_QNAME; } - + + public void deployToRegistry(DeploymentRegistry registry) + throws DeploymentException + { + WSDDGlobalConfiguration global = getGlobalConfiguration(); + + if (global != null) { + registry.setGlobalConfiguration(global); + } + + WSDDHandler[] handlers = getHandlers(); + WSDDTransport[] transports = getTransports(); + WSDDService[] services = getServices(); + WSDDTypeMapping[] mappings = getTypeMappings(); + + for (int n = 0; n < handlers.length; n++) { + handlers[n].deployToRegistry(registry); + } + + for (int n = 0; n < transports.length; n++) { + transports[n].deployToRegistry(registry); + } + + for (int n = 0; n < services.length; n++) { + services[n].deployToRegistry(registry); + } + + for (int n = 0; n < mappings.length; n++) { + WSDDTypeMapping mapping = mappings[n]; + deployMappingToRegistry(mapping, registry); + } + } + + public static void deployMappingToRegistry(WSDDTypeMapping mapping, + DeploymentRegistry registry) + throws DeploymentException + { + TypeMappingRegistry tmr = + registry.getTypeMappingRegistry(mapping.getEncodingStyle()); + + if (tmr == null) { + tmr = new TypeMappingRegistry(); + tmr.setParent(SOAPTypeMappingRegistry.getSingleton()); + + registry.addTypeMappingRegistry(mapping.getEncodingStyle(), + tmr); + } + + Serializer ser = null; + DeserializerFactory deser = null; + + try { + ser = (Serializer) mapping.getSerializer().newInstance(); + deser = + (DeserializerFactory) mapping.getDeserializer() + .newInstance(); + + if (ser != null) { + tmr.addSerializer(mapping.getLanguageSpecificType(), + mapping.getQName(), ser); + } + + if (deser != null) { + tmr.addDeserializerFactory(mapping.getQName(), mapping + .getLanguageSpecificType(), deser); + } + } + catch (Exception e) { + throw new DeploymentException(e.getMessage()); + } + } + public void writeToContext(SerializationContext context) throws IOException { 1.14 +31 -86 xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDDocument.java Index: WSDDDocument.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDDocument.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- WSDDDocument.java 2001/11/14 19:59:45 1.13 +++ WSDDDocument.java 2001/12/03 03:31:31 1.14 @@ -76,12 +76,10 @@ public class WSDDDocument implements DeploymentDocument { - - /** XXX */ private Document doc; - /** XXX */ - private WSDDDeployment dep; + private WSDDDeployment deployment; + private WSDDUndeployment undeployment; /** * @@ -97,7 +95,12 @@ public WSDDDocument(Document doc) throws WSDDException { this.doc = doc; - dep = new WSDDDeployment(doc.getDocumentElement()); + Element docEl = doc.getDocumentElement(); + if ("undeployment".equals(docEl.getLocalName())) { + undeployment = new WSDDUndeployment(docEl); + } else { + deployment = new WSDDDeployment(docEl); + } } /** @@ -107,7 +110,11 @@ public WSDDDocument(Element e) throws WSDDException { doc = e.getOwnerDocument(); - dep = new WSDDDeployment(e); + if ("undeployment".equals(e.getLocalName())) { + undeployment = new WSDDUndeployment(e); + } else { + deployment = new WSDDDeployment(e); + } } /** @@ -116,9 +123,9 @@ */ public WSDDDeployment getDeployment() { - if (dep == null) - dep = new WSDDDeployment(); - return dep; + if (deployment == null) + deployment = new WSDDDeployment(); + return deployment; } public Document getDOMDocument() throws DeploymentException { @@ -126,7 +133,7 @@ SerializationContext context = new SerializationContext(writer, null); context.setPretty(true); try { - dep.writeToContext(context); + deployment.writeToContext(context); } catch (Exception e) { e.printStackTrace(); } @@ -152,45 +159,19 @@ { doc = document; - dep = null; + deployment = null; } /** * - * @param registry XXX - * @throws DeploymentException XXX */ public void deploy(DeploymentRegistry registry) throws DeploymentException { - getDeployment(); - - WSDDGlobalConfiguration global = dep.getGlobalConfiguration(); - - if (global != null) { - registry.setGlobalConfiguration(global); - } - - WSDDHandler[] handlers = dep.getHandlers(); - WSDDTransport[] transports = dep.getTransports(); - WSDDService[] services = dep.getServices(); - WSDDTypeMapping[] mappings = dep.getTypeMappings(); - - for (int n = 0; n < handlers.length; n++) { - handlers[n].deployToRegistry(registry); - } - - for (int n = 0; n < transports.length; n++) { - transports[n].deployToRegistry(registry); - } - - for (int n = 0; n < services.length; n++) { - services[n].deployToRegistry(registry); - } - - for (int n = 0; n < mappings.length; n++) { - WSDDTypeMapping mapping = mappings[n]; - deployMappingToRegistry(mapping, registry); + if (deployment != null) { + deployment.deployToRegistry(registry); + } else { + undeployment.undeployFromRegistry(registry); } } @@ -199,66 +180,30 @@ */ public void undeploy(DeploymentRegistry registry) throws DeploymentException { - WSDDHandler[] handlers = dep.getHandlers(); - WSDDTransport[] transports = dep.getTransports(); - WSDDService[] services = dep.getServices(); - WSDDTypeMapping[] mappings = dep.getTypeMappings(); + + if (deployment == null) + throw new DeploymentException(); + + WSDDHandler[] handlers = deployment.getHandlers(); + WSDDTransport[] transports = deployment.getTransports(); + WSDDService[] services = deployment.getServices(); + WSDDTypeMapping[] mappings = deployment.getTypeMappings(); QName qname = null; - + for (int n = 0; n < handlers.length; n++) { qname = handlers[n].getQName(); if (qname != null) registry.undeployHandler(qname); } - for (int n = 0; n < transports.length; n++) { qname = transports[n].getQName(); if (qname != null) registry.undeployTransport(qname); } - for (int n = 0; n < services.length; n++) { qname = services[n].getQName(); if (qname != null) registry.undeployService(qname); - } - } - - public static void deployMappingToRegistry(WSDDTypeMapping mapping, - DeploymentRegistry registry) - throws DeploymentException { - TypeMappingRegistry tmr = - registry.getTypeMappingRegistry(mapping.getEncodingStyle()); - - if (tmr == null) { - tmr = new TypeMappingRegistry(); - tmr.setParent(SOAPTypeMappingRegistry.getSingleton()); - - registry.addTypeMappingRegistry(mapping.getEncodingStyle(), - tmr); - } - - Serializer ser = null; - DeserializerFactory deser = null; - - try { - ser = (Serializer) mapping.getSerializer().newInstance(); - deser = - (DeserializerFactory) mapping.getDeserializer() - .newInstance(); - - if (ser != null) { - tmr.addSerializer(mapping.getLanguageSpecificType(), - mapping.getQName(), ser); - } - - if (deser != null) { - tmr.addDeserializerFactory(mapping.getQName(), mapping - .getLanguageSpecificType(), deser); - } - } - catch (Exception e) { - throw new DeploymentException(e.getMessage()); } } } 1.1 xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDUndeployment.java Index: WSDDUndeployment.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.axis.deployment.wsdd; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.apache.axis.Constants; import org.apache.axis.utils.XMLUtils; import org.apache.axis.utils.JavaUtils; import org.apache.axis.deployment.DeploymentRegistry; import org.apache.axis.deployment.DeploymentException; import org.apache.axis.encoding.*; import org.xml.sax.helpers.AttributesImpl; import javax.xml.rpc.namespace.QName; import java.util.Vector; import java.util.Iterator; import java.io.IOException; /** * WSDD deployment element * * @author James Snell */ public class WSDDUndeployment extends WSDDElement implements WSDDTypeMappingContainer { private Vector handlers = new Vector(); private Vector chains = new Vector(); private Vector services = new Vector(); private Vector transports = new Vector(); private Vector typeMappings = new Vector(); public void addHandler(QName handler) { handlers.add(handler); } public void addChain(QName chain) { chains.add(chain); } public void addTransport(QName transport) { transports.add(transport); } public void addService(QName service) { services.add(service); } public void addTypeMapping(WSDDTypeMapping typeMapping) throws WSDDException { typeMappings.add(typeMapping); } /** * Default constructor */ public WSDDUndeployment() { } private QName getQName(Element el) throws WSDDException { String attr = el.getAttribute("name"); if (attr == null || "".equals(attr)) throw new WSDDException(JavaUtils.getMessage("badNameAttr00")); return new QName("", attr); } /** * Constructor - build an undeployment from a DOM Element. * * @param e the DOM Element to initialize from * @throws WSDDException if there is a problem */ public WSDDUndeployment(Element e) throws WSDDException { super(e); Element [] elements = getChildElements(e, "handler"); int i; for (i = 0; i < elements.length; i++) { addHandler(getQName(elements[i])); } elements = getChildElements(e, "chain"); for (i = 0; i < elements.length; i++) { addChain(getQName(elements[i])); } elements = getChildElements(e, "transport"); for (i = 0; i < elements.length; i++) { addTransport(getQName(elements[i])); } elements = getChildElements(e, "service"); for (i = 0; i < elements.length; i++) { addService(getQName(elements[i])); } /* // How to deal with undeploying mappings? elements = getChildElements(e, "typeMapping"); for (i = 0; i < elements.length; i++) { WSDDTypeMapping mapping = new WSDDTypeMapping(elements[i]); addTypeMapping(mapping); } elements = getChildElements(e, "beanMapping"); for (i = 0; i < elements.length; i++) { WSDDBeanMapping mapping = new WSDDBeanMapping(elements[i]); addTypeMapping(mapping); } */ } protected QName getElementName() { return WSDDConstants.UNDEPLOY_QNAME; } public void undeployFromRegistry(DeploymentRegistry registry) throws DeploymentException { QName qname; for (int n = 0; n < handlers.size(); n++) { qname = (QName)handlers.get(n); registry.undeployHandler(qname); } for (int n = 0; n < chains.size(); n++) { qname = (QName)chains.get(n); registry.undeployHandler(qname); } for (int n = 0; n < transports.size(); n++) { qname = (QName)transports.get(n); registry.undeployTransport(qname); } for (int n = 0; n < services.size(); n++) { qname = (QName)services.get(n); registry.undeployService(qname); } } private void writeElement(SerializationContext context, QName elementQName, QName qname) throws IOException { AttributesImpl attrs = new org.xml.sax.helpers.AttributesImpl(); attrs.addAttribute("", "name", "name", "CDATA", context.qName2String(qname)); context.writeElement(elementQName, attrs); } public void writeToContext(SerializationContext context) throws IOException { context.registerPrefixForURI("", WSDDConstants.WSDD_NS); context.startElement(WSDDConstants.UNDEPLOY_QNAME, null); Iterator i = handlers.iterator(); QName qname; while (i.hasNext()) { qname = (QName)i.next(); writeElement(context, WSDDConstants.HANDLER_QNAME, qname); } i = chains.iterator(); while (i.hasNext()) { qname = (QName)i.next(); writeElement(context, WSDDConstants.CHAIN_QNAME, qname); } i = services.iterator(); while (i.hasNext()) { qname = (QName)i.next(); writeElement(context, WSDDConstants.SERVICE_QNAME, qname); } i = transports.iterator(); while (i.hasNext()) { qname = (QName)i.next(); writeElement(context, WSDDConstants.TRANSPORT_QNAME, qname); } i = typeMappings.iterator(); while (i.hasNext()) { WSDDTypeMapping mapping = (WSDDTypeMapping)i.next(); mapping.writeToContext(context); } context.endElement(); } /** * * @return XXX */ public WSDDTypeMapping[] getTypeMappings() { WSDDTypeMapping[] t = new WSDDTypeMapping[typeMappings.size()]; typeMappings.toArray(t); return t; } } 1.66 +15 -0 xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java Index: SerializationContext.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- SerializationContext.java 2001/12/01 03:39:48 1.65 +++ SerializationContext.java 2001/12/03 03:31:31 1.66 @@ -534,6 +534,21 @@ onlyXML=true; } + /** + * Convenience method for writing an element with no structure inside it. + * (this could be optimzed later to share logic with startElement()) + * + * @param qName the qualified name of the new element + * @param attributes any attributes which should be written on the element + * @exception IOException if there is any trouble + */ + public void writeElement(QName qName, Attributes attributes) + throws IOException + { + startElement(qName, attributes); + endElement(); + } + public void endElement() throws IOException { 1.19 +1 -0 xml-axis/java/src/org/apache/axis/utils/resources.properties Index: resources.properties =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- resources.properties 2001/11/30 21:55:19 1.18 +++ resources.properties 2001/12/03 03:31:31 1.19 @@ -32,6 +32,7 @@ # NOTE: in badMsgCtx00, do not translate "--messageContext", "--skeleton" badMsgCtx00=Error: --messageContext switch only valid with --skeleton +badNameAttr00=No ''name'' attribute was specified in an undeployment element badNamespace00=Bad envelope namespace: {0} badOffset00=Malformed offset attribute ''{0}''. badPosition00=Malformed position attribute ''{0}''.