You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by es...@apache.org on 2007/03/04 01:37:03 UTC

svn commit: r514293 - in /portals/pluto/trunk: pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/ pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/ pluto-descriptor-impl/src/main/resources/ pluto-de...

Author: esm
Date: Sat Mar  3 16:37:02 2007
New Revision: 514293

URL: http://svn.apache.org/viewvc?view=rev&rev=514293
Log:
[PLUTO-327]: Converted the assembler to use the pluto-descriptor-api

* Updated DistributableDD handling to be correct w.r.t. the Servlet DTD/XSD.
  ** Updated Castor mapping to reflect changes to DistributableDD
  ** Added Castor field handlers for Distributable and DistributableDD
* Updated the WebXmlRewritingAssembler to use the pluto-descriptor-api

Added:
    portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/DistributableDD.java   (with props)
    portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableCastorFieldHandler.java   (with props)
    portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableDDCastorFieldHandler.java   (with props)
    portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/castor.properties   (with props)
Modified:
    portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/WebAppDD.java
    portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/org/apache/pluto/descriptors/services/castor/castor-web-xml-mapping.xml
    portals/pluto/trunk/pluto-descriptor-impl/src/test/resources/castor.properties
    portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/WebXmlRewritingAssembler.java

Added: portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/DistributableDD.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/DistributableDD.java?view=auto&rev=514293
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/DistributableDD.java (added)
+++ portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/DistributableDD.java Sat Mar  3 16:37:02 2007
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.descriptors.servlet;
+
+/**
+ * Models the <distributable> web.xml element.
+ * 
+ * @author Elliot Metsger (emetsger@jhu.edu)
+ * @since Mar 3, 2007
+ * @version $Id$
+ */
+public class DistributableDD
+{
+    
+    private boolean distributable = false;
+    
+    public Boolean isDistributable()
+    {
+        return Boolean.valueOf(distributable);
+    }
+
+    public void setDistributable(boolean distributable)
+    {
+        this.distributable = distributable;
+    }
+
+}

Propchange: portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/DistributableDD.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/DistributableDD.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/WebAppDD.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/WebAppDD.java?view=diff&rev=514293&r1=514292&r2=514293
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/WebAppDD.java (original)
+++ portals/pluto/trunk/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/servlet/WebAppDD.java Sat Mar  3 16:37:02 2007
@@ -35,7 +35,6 @@
     private IconDD icon;
     private String displayName;
     private String description;
-    private boolean distributable;
     private List contextParams = new ArrayList();
     private List filters = new ArrayList();
     private List filterMappings = new ArrayList();
@@ -57,6 +56,10 @@
     // element is present with a version attribute,
     // the Castor mapping will update this field.
     private String servletVersion = "2.3";
+    // Default to false.  If a <web-app> 
+    // contains a <distributable/> element, then
+    // Castor will update this field to true.
+    private DistributableDD distributableDD = new DistributableDD();
 
     public WebAppDD() {
 
@@ -87,15 +90,19 @@
     }
 
     public boolean isDistributable() {
-        return distributable;
+        return distributableDD.isDistributable().booleanValue();
+    }
+    
+    public DistributableDD getDistributable() {
+        return distributableDD;
     }
 
     public void setDistributable() {
-        this.distributable = true;
+        this.distributableDD.setDistributable(true);
     }
 
     public void setDistributable(boolean distributable) {
-        this.distributable = distributable;
+        this.distributableDD.setDistributable(distributable);
     }
 
     /**

Added: portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableCastorFieldHandler.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableCastorFieldHandler.java?view=auto&rev=514293
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableCastorFieldHandler.java (added)
+++ portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableCastorFieldHandler.java Sat Mar  3 16:37:02 2007
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.descriptors.services.castor;
+
+import org.apache.pluto.descriptors.servlet.DistributableDD;
+import org.exolab.castor.mapping.AbstractFieldHandler;
+
+public class DistributableCastorFieldHandler extends AbstractFieldHandler
+{
+
+    public Object getValue(Object arg0) throws IllegalStateException
+    {
+        // we always return null, because the 
+        // distributable element has body.
+        return null;
+    }
+
+    public Object newInstance(Object arg0) throws IllegalStateException
+    {
+        // Do nothing.
+        return null;
+    }
+
+    public Object newInstance(Object arg0, Object[] arg1)
+            throws IllegalStateException
+    {
+        // Do nothing.
+        return null;
+    }
+
+    public void resetValue(Object arg0) throws IllegalStateException,
+            IllegalArgumentException
+    {
+        // Do nothing.
+    }
+
+    public void setValue(Object distributableDD, Object value)
+            throws IllegalStateException, IllegalArgumentException
+    {
+        if (! (distributableDD instanceof DistributableDD) )
+        {
+            throw new ClassCastException("Error: was expecting " + DistributableDD.class.getName() +
+                        " but got a " + distributableDD.getClass().getName() );
+        }
+        
+        if (! (value instanceof Boolean) )
+        {
+            throw new ClassCastException("Error: was expecting " + Boolean.class.getName() + 
+                        " but got a " + value.getClass().getName() );
+        }
+        
+        ((DistributableDD)distributableDD).setDistributable(((Boolean)value).booleanValue());
+    }
+
+}

Propchange: portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableCastorFieldHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableCastorFieldHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableDDCastorFieldHandler.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableDDCastorFieldHandler.java?view=auto&rev=514293
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableDDCastorFieldHandler.java (added)
+++ portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableDDCastorFieldHandler.java Sat Mar  3 16:37:02 2007
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.descriptors.services.castor;
+
+import org.apache.pluto.descriptors.servlet.DistributableDD;
+import org.apache.pluto.descriptors.servlet.WebAppDD;
+import org.exolab.castor.mapping.AbstractFieldHandler;
+
+public class DistributableDDCastorFieldHandler extends AbstractFieldHandler
+{
+
+    public Object getValue(Object webAppDD) throws IllegalStateException
+    {
+        if (! ( webAppDD instanceof WebAppDD ) )
+        {
+            throw new ClassCastException("Error: was expecting a " + WebAppDD.class.getName() +
+                    " but got a " + webAppDD.getClass().getName());
+        }
+        
+        DistributableDD distributableDD = ((WebAppDD)webAppDD).getDistributable();
+        Boolean distributable = distributableDD.isDistributable();
+        
+        // if the webapp is not distributable, return null so Castor won't emit a
+        // <distributable> element
+        if (Boolean.FALSE.equals(distributable))
+        {
+            return null;
+        }
+        
+        return distributableDD;        
+    }
+
+    public Object newInstance(Object arg0) throws IllegalStateException
+    {
+        // Do nothing.
+        return null;
+    }
+
+    public Object newInstance(Object arg0, Object[] arg1)
+            throws IllegalStateException
+    {
+        // Do nothing.
+        return null;
+    }
+
+    public void resetValue(Object arg0) throws IllegalStateException,
+            IllegalArgumentException
+    {
+        // Do nothing.
+    }
+
+    public void setValue(Object webAppDD, Object distributableDD)
+            throws IllegalStateException, IllegalArgumentException
+    {
+        if (! ( webAppDD instanceof WebAppDD ) )
+        {
+            throw new ClassCastException("Error: was expecting a " + WebAppDD.class.getName() +
+                    " but got a " + webAppDD.getClass().getName());
+        }
+        if (! ( distributableDD instanceof DistributableDD ) )
+        {
+            throw new ClassCastException("Error: was expecting a " + DistributableDD.class.getName() +
+                    " but got a " + distributableDD.getClass().getName());
+        }
+        
+        ((WebAppDD)webAppDD).setDistributable(((DistributableDD)distributableDD).isDistributable().booleanValue());
+    }
+
+}

Propchange: portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableDDCastorFieldHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/DistributableDDCastorFieldHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/castor.properties
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/castor.properties?view=auto&rev=514293
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/castor.properties (added)
+++ portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/castor.properties Sat Mar  3 16:37:02 2007
@@ -0,0 +1,32 @@
+# 
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at 
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed  under the  License is distributed on an "AS IS" BASIS,
+# WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+# implied.
+#  
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# Example properties indent the output, require validation
+# on input and turn debugging on.
+#
+
+# This castor.properties is used by the descriptor unit tests and impl.  
+# The pluto-portal has its own castor.properties file. 
+# See also: 
+#  pluto-portal/src/main/webapp/WEB-INF/classes/castor.properties
+#  Castor property file reference: http://castor.org/conf-lib.html
+
+org.exolab.castor.parser.validation=false
+org.exolab.castor.indent=true
+org.exolab.castor.debug=false
\ No newline at end of file

Propchange: portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/castor.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/org/apache/pluto/descriptors/services/castor/castor-web-xml-mapping.xml
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/org/apache/pluto/descriptors/services/castor/castor-web-xml-mapping.xml?view=diff&rev=514293&r1=514292&r2=514293
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/org/apache/pluto/descriptors/services/castor/castor-web-xml-mapping.xml (original)
+++ portals/pluto/trunk/pluto-descriptor-impl/src/main/resources/org/apache/pluto/descriptors/services/castor/castor-web-xml-mapping.xml Sat Mar  3 16:37:02 2007
@@ -68,7 +68,9 @@
       <bind-xml name="description" node="element"/>
     </field>
 
-    <field name="Distributable" get-method="isDistributable">
+    <field name="Distributable"
+           type="org.apache.pluto.descriptors.servlet.DistributableDD"
+           handler="org.apache.pluto.descriptors.services.castor.DistributableDDCastorFieldHandler">
       <bind-xml name="distributable" node="element"/>
     </field>
 
@@ -373,6 +375,13 @@
         </field>
     </class>
     
+    <class name="org.apache.pluto.descriptors.servlet.DistributableDD">
+         <field name="Distributable" 
+                type="java.lang.Boolean"
+                handler="org.apache.pluto.descriptors.services.castor.DistributableCastorFieldHandler">
+             <bind-xml name="distributable" node="element"/>
+         </field>
+    </class>        
 
 </mapping>
 

Modified: portals/pluto/trunk/pluto-descriptor-impl/src/test/resources/castor.properties
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-impl/src/test/resources/castor.properties?view=diff&rev=514293&r1=514292&r2=514293
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-impl/src/test/resources/castor.properties (original)
+++ portals/pluto/trunk/pluto-descriptor-impl/src/test/resources/castor.properties Sat Mar  3 16:37:02 2007
@@ -21,7 +21,7 @@
 # on input and turn debugging on.
 #
 
-# This castor.properties is used by the descriptor unit tests.  
+# This castor.properties is used by the descriptor unit tests and impl.  
 # The pluto-portal has its own castor.properties file. 
 # See also: 
 #  pluto-portal/src/main/webapp/WEB-INF/classes/castor.properties

Modified: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/WebXmlRewritingAssembler.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/WebXmlRewritingAssembler.java?view=diff&rev=514293&r1=514292&r2=514293
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/WebXmlRewritingAssembler.java (original)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/WebXmlRewritingAssembler.java Sat Mar  3 16:37:02 2007
@@ -19,73 +19,31 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Iterator;
-import java.util.Properties;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
 
+import org.apache.pluto.descriptors.common.InitParamDD;
 import org.apache.pluto.descriptors.portlet.PortletAppDD;
 import org.apache.pluto.descriptors.portlet.PortletDD;
 import org.apache.pluto.descriptors.services.PortletAppDescriptorService;
-import org.apache.pluto.descriptors.services.castor.EntityResolverImpl;
+import org.apache.pluto.descriptors.services.WebAppDescriptorService;
 import org.apache.pluto.descriptors.services.castor.PortletAppDescriptorServiceImpl;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
+import org.apache.pluto.descriptors.services.castor.WebAppDescriptorServiceImpl;
+import org.apache.pluto.descriptors.servlet.LoadOnStartupDD;
+import org.apache.pluto.descriptors.servlet.ServletDD;
+import org.apache.pluto.descriptors.servlet.ServletMappingDD;
+import org.apache.pluto.descriptors.servlet.WebAppDD;
 
 /**
  * @author Eric Dalquist <a href="mailto:eric.dalquist@doit.wisc.edu">eric.dalquist@doit.wisc.edu</a>
  * @version $Revision$
+ * @todo fix direct dependency on pluto-descriptor-impl
  */
-public abstract class WebXmlRewritingAssembler implements Assembler {
-    /** The XML output properties. */
-    private static final Properties PROPERTIES = new Properties();
-    
-    /** Element tagnames that may appear before servlet elements. */
-    private static final Collection BEFORE_SERVLET_DEF = new ArrayList();
-    
-    /** Element tagnames that may appear before servlet-mapping elements. */
-    private static final Collection BEFORE_MAPPING_DEF = new ArrayList();
-
-    static {
-        // Initialize xml output properties.
-        PROPERTIES.setProperty(OutputKeys.INDENT, "yes");
-        
-        // Initialize BEFORE_SERVLET_DEF collection.
-        BEFORE_SERVLET_DEF.add("icon");
-        BEFORE_SERVLET_DEF.add("display-name");
-        BEFORE_SERVLET_DEF.add("description");
-        BEFORE_SERVLET_DEF.add("distributable");
-        BEFORE_SERVLET_DEF.add("context-param");
-        BEFORE_SERVLET_DEF.add("filter");
-        BEFORE_SERVLET_DEF.add("filter-mapping");
-        BEFORE_SERVLET_DEF.add("listener");
-        
-        // initialize BEFORE_MAPPING_DEF collection.
-        BEFORE_MAPPING_DEF.addAll(BEFORE_SERVLET_DEF);
-        BEFORE_MAPPING_DEF.add("servlet");
-    }
-    
+public abstract class WebXmlRewritingAssembler implements Assembler {    
     
     /**
      * Updates the webapp descriptor by injecting portlet wrapper servlet
      * definitions and mappings.
      * 
-     * TODO: currently we rely specifically on the castor implementation.
-     * 
      * @param webXmlIn  input stream to the webapp descriptor, it will be closed before the web xml is written out.
      * @param portletXmlIn  input stream to the portlet app descriptor, it will be closed before the web xml is written out.
      * @param webXmlOut output stream to the webapp descriptor, it will be flushed and closed.
@@ -105,11 +63,8 @@
             dispatchServletClass = DISPATCH_SERVLET_CLASS;
         }
         
-        Document webXmlDoc = parse(webXmlIn);
-        webXmlIn.close();
-        
-        Collection servletElements = new ArrayList();
-        Collection mappingElements = new ArrayList();
+        WebAppDescriptorService descriptorSvc = new WebAppDescriptorServiceImpl();
+        WebAppDD webAppDDIn = descriptorSvc.read(webXmlIn);
 
         PortletAppDescriptorService portletAppDescriptorService =
                 new PortletAppDescriptorServiceImpl();
@@ -122,131 +77,30 @@
             // Read portlet definition.
             PortletDD portlet = (PortletDD) it.next();
             String name = portlet.getPortletName();
+
+            ServletDD servlet = new ServletDD();
+            servlet.setServletName(name);
+     
+            servlet.setServletClass(dispatchServletClass);
+
+            InitParamDD initParam = new InitParamDD();
+            initParam.setParamName("portlet-name");
+            initParam.setParamValue(name);
+            servlet.getInitParams().add(initParam);
             
-            // Create servlet definition element.
-            Element servlet = webXmlDoc.createElement("servlet");
-            Element servletName = webXmlDoc.createElement("servlet-name");
-            servletName.appendChild(webXmlDoc.createTextNode(name));
-            servlet.appendChild(servletName);
-            
-            Element servletClass = webXmlDoc.createElement("servlet-class");
-            servletClass.appendChild(webXmlDoc.createTextNode(dispatchServletClass));
-            servlet.appendChild(servletClass);
-            
-            Element initParam = webXmlDoc.createElement("init-param");
-            Element paramName = webXmlDoc.createElement("param-name");
-            paramName.appendChild(webXmlDoc.createTextNode("portlet-name"));
-            
-            Element paramValue = webXmlDoc.createElement("param-value");
-            paramValue.appendChild(webXmlDoc.createTextNode(name));
-            
-            initParam.appendChild(paramName);
-            initParam.appendChild(paramValue);
-            servlet.appendChild(initParam);
-            
-            Element load = webXmlDoc.createElement("load-on-startup");
-            load.appendChild(webXmlDoc.createTextNode("1"));
-            servlet.appendChild(load);
-            
-            // Create servlet mapping element.
-            Element mapping = webXmlDoc.createElement("servlet-mapping");
-            servletName = webXmlDoc.createElement("servlet-name");
-            servletName.appendChild(webXmlDoc.createTextNode(name));
-            Element uri = webXmlDoc.createElement("url-pattern");
-            uri.appendChild(webXmlDoc.createTextNode("/PlutoInvoker/"+name));
-            mapping.appendChild(servletName);
-            mapping.appendChild(uri);
-            
-            // Save servlet definition and servlet mapping.
-            servletElements.add(servlet);
-            mappingElements.add(mapping);
-        }
+            LoadOnStartupDD onStartup = new LoadOnStartupDD();
+            onStartup.setPriority(1);
+            servlet.setLoadOnStartup(onStartup);
 
-        Element webAppNode = webXmlDoc.getDocumentElement();
-        NodeList nodes = webAppNode.getChildNodes();
-        
-        // Find the first node that shouldn't be before the servlet and start
-        // appending. This is kind of ugly, but the hack works for now!
-        for (int i = 0; i < nodes.getLength(); i++) {
-            Node node = nodes.item(i);
-            if (node.getNodeType() == Node.ELEMENT_NODE) {
-                
-                if (!BEFORE_SERVLET_DEF.contains(node.getNodeName())) {
-                    for (Iterator it = servletElements.iterator();
-                            it.hasNext(); ) {
-                        Node servlet = (Node) it.next();
-                        webAppNode.insertBefore(servlet, node);
-                        it.remove();
-                    }
-                }
-                
-                if(!BEFORE_MAPPING_DEF.contains(node.getNodeName())) {
-                    for (Iterator it = mappingElements.iterator();
-                            it.hasNext(); ) {
-                        Node mapping = (Node) it.next();
-                        webAppNode.insertBefore(mapping, node);
-                        it.remove();
-                    }
-                }
-            }
-        }
+            ServletMappingDD servletMapping = new ServletMappingDD();
+            servletMapping.setServletName(name);
+            servletMapping.setUrlPattern("/PlutoInvoker/" + name);
 
-        // Now, in case there are not any nodes after the servlet def!
-        for (Iterator it = servletElements.iterator(); it.hasNext(); ) {
-            webAppNode.appendChild((Node)it.next());
-        }
-        for (Iterator it = mappingElements.iterator(); it.hasNext(); ) {
-            webAppNode.appendChild((Node)it.next());
+            webAppDDIn.getServlets().add(servlet);
+            webAppDDIn.getServletMappings().add(servletMapping);
+            
         }
         
-        // Write out the updated web.xml document.
-        this.save(webXmlDoc, webXmlOut);
-    }
-    
-    /**
-     * Saves the XML document to the specified output stream.
-     * @param xmlDoc  the XML document.
-     * @param out  the output stream.
-     * @throws IOException  if an error occurs.
-     */
-    protected void save(Document xmlDoc, OutputStream out)
-    throws IOException {
-        try {
-            TransformerFactory factory = TransformerFactory.newInstance();
-            Transformer transformer = factory.newTransformer();
-            transformer.setOutputProperties(PROPERTIES);
-            transformer.transform(new DOMSource(xmlDoc),
-                                  new StreamResult(out));
-        } catch (TransformerConfigurationException ex) {
-            ex.printStackTrace();
-            throw new IOException(ex.getMessage());
-        } catch (TransformerException ex) {
-            ex.printStackTrace();
-            throw new IOException(ex.getMessage());
-        } finally {
-            out.flush();
-            out.close();
-        }
-    }
-    
-    /**
-     * Parses an input stream of an XML file to an XML document.
-     * @param xmlIn  the input stream of an XML file.
-     * @return the XML document.
-     * @throws IOException  if an error occurs.
-     */
-    protected Document parse(InputStream xmlIn) throws IOException {
-        Document xmlDoc = null;
-        try {
-            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-            DocumentBuilder builder = factory.newDocumentBuilder();
-            builder.setEntityResolver(new EntityResolverImpl());
-            xmlDoc = builder.parse(xmlIn);
-        } catch (ParserConfigurationException ex) {
-            throw new IOException(ex.getMessage());
-        } catch (SAXException ex) {
-            throw new IOException(ex.getMessage());
-        }
-        return xmlDoc;
+        descriptorSvc.write(webAppDDIn, webXmlOut);
     }
 }