portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddew...@apache.org
Subject svn commit: r482851 - in /portals/pluto/trunk: maven-pluto-plugin/src/main/java/org/apache/pluto/maven/ pluto-util/src/main/java/org/apache/pluto/util/assemble/ pluto-util/src/main/java/org/apache/pluto/util/assemble/file/
Date Wed, 06 Dec 2006 00:46:17 GMT
Author: ddewolf
Date: Tue Dec  5 16:46:16 2006
New Revision: 482851

URL: http://svn.apache.org/viewvc?view=rev&rev=482851
Log:
PLUTO-268, allow custom servlet in asssembler.  Thank you David Hay

Modified:
    portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/AssembleMojo.java
    portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/AssemblerConfig.java
    portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/file/FileAssembler.java

Modified: portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/AssembleMojo.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/AssembleMojo.java?view=diff&rev=482851&r1=482850&r2=482851
==============================================================================
--- portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/AssembleMojo.java
(original)
+++ portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/AssembleMojo.java
Tue Dec  5 16:46:16 2006
@@ -15,13 +15,13 @@
  */
 package org.apache.pluto.maven;
 
+import java.io.File;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
 import org.apache.pluto.util.assemble.Assembler;
 import org.apache.pluto.util.assemble.AssemblerConfig;
 import org.apache.pluto.util.assemble.AssemblerFactory;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
-
-import java.io.File;
 
 /**
  * TODO: Document
@@ -58,8 +58,13 @@
      * @parameter expression="${project.build.directory}/pluto-resources/web.xml"
      */
     private File webXmlDestination = null;
-    
-    
+
+    /**
+     * The name of the dispatch servlet class to use
+     * @parameter
+     */
+    private String dispatchServletClass = null;
+
     // AbstractPlutoMojo Impl --------------------------------------------------
     
     protected void doExecute() throws Exception {
@@ -93,6 +98,7 @@
         config.setPortletDescriptor(portletXml);
         config.setWebappDescriptor(webXml);
         config.setDestination(webXmlDestination);
+        config.setDispatchServletClass(dispatchServletClass);
         return config;
     }
     

Modified: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/AssemblerConfig.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/AssemblerConfig.java?view=diff&rev=482851&r1=482850&r2=482851
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/AssemblerConfig.java
(original)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/AssemblerConfig.java
Tue Dec  5 16:46:16 2006
@@ -33,7 +33,9 @@
     
     /** The assemble destination, which points to the assembled WAR file. */
     private File destination = null;
-    
+
+    /** The class of the servlet that will handle portlet requests */
+    private String dispatchServletClass = null;
     
     // Public Methods ----------------------------------------------------------
     
@@ -61,5 +63,12 @@
         this.destination = destination;
         this.destination.getParentFile().mkdirs();
     }
-    
+
+    public String getDispatchServletClass() {
+        return dispatchServletClass;
+    }
+
+    public void setDispatchServletClass(String dispatchServletClass) {
+        this.dispatchServletClass = dispatchServletClass;
+    }
 }

Modified: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/file/FileAssembler.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/file/FileAssembler.java?view=diff&rev=482851&r1=482850&r2=482851
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/file/FileAssembler.java
(original)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/assemble/file/FileAssembler.java
Tue Dec  5 16:46:16 2006
@@ -15,33 +15,40 @@
  */
 package org.apache.pluto.util.assemble.file;
 
-import org.apache.pluto.util.assemble.Assembler;
-import org.apache.pluto.util.assemble.AssemblerConfig;
-import org.apache.pluto.util.UtilityException;
+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 java.io.FileInputStream;
+import java.io.FileOutputStream;
+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 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.castor.PortletAppDescriptorServiceImpl;
+import org.apache.pluto.util.UtilityException;
+import org.apache.pluto.util.assemble.Assembler;
+import org.apache.pluto.util.assemble.AssemblerConfig;
 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 javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.*;
-
 /**
  *
  * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
@@ -96,7 +103,8 @@
             		config.getWebappDescriptor());
             InputStream portletXmlIn = new FileInputStream(
             		config.getPortletDescriptor());
-            Document xmlDoc = updateWebappDescriptor(webXmlIn, portletXmlIn);
+            Document xmlDoc = updateWebappDescriptor(webXmlIn, portletXmlIn,
+                                                     config.getDispatchServletClass());
             webXmlIn.close();
             FileOutputStream webXmlOut = new FileOutputStream(
             		config.getDestination());
@@ -144,12 +152,21 @@
      * 
      * @param webXmlIn  input stream to the webapp descriptor.
      * @param portletXmlIn  input stream to the portlet app descriptor.
+     * @param dispatchServletClass The name of the servlet class to use for
+     *                         handling portlet requests
      * @return the updated webapp descriptor XML document.
      * @throws IOException
      */
     protected Document updateWebappDescriptor(InputStream webXmlIn,
-                                              InputStream portletXmlIn)
+                                              InputStream portletXmlIn,
+                                              String dispatchServletClass)
     throws IOException {
+
+        if (dispatchServletClass == null ||
+            dispatchServletClass.length() == 0 ||
+            dispatchServletClass.trim().length() == 0) {
+            dispatchServletClass = DISPATCH_SERVLET_CLASS;
+        }
     	
         Document webXmlDoc = parse(webXmlIn);
         Collection servletElements = new ArrayList();
@@ -173,7 +190,7 @@
             servlet.appendChild(servletName);
             
             Element servletClass = webXmlDoc.createElement("servlet-class");
-            servletClass.appendChild(webXmlDoc.createTextNode(DISPATCH_SERVLET_CLASS));
+            servletClass.appendChild(webXmlDoc.createTextNode(dispatchServletClass));
             servlet.appendChild(servletClass);
             
             Element initParam = webXmlDoc.createElement("init-param");



Mime
View raw message