portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/util FileSystemHelper.java
Date Thu, 22 Jul 2004 23:38:39 GMT
taylor      2004/07/22 16:38:39

  Modified:    portal/src/java/org/apache/jetspeed/tools/pamanager
                        ApplicationServerPAM.java
               commons/src/java/org/apache/jetspeed/container
                        JetspeedContainerServlet.java
               components/deploy-tool/src/java/org/apache/jetspeed/tools/deploy
                        JetspeedDeploy.java
                        JetspeedWebApplicationRewriter.java
               portal/src/webapp/WEB-INF/assembly jetspeed.groovy
  Added:       jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager
                        DeploymentRegistration.java
               jetspeed-api/src/java/org/apache/jetspeed/util
                        FileSystemHelper.java
  Removed:     commons/src/java/org/apache/jetspeed/util
                        FileSystemHelper.java
  Log:
  Optional Generic Deployment feature
  Using this method, deployment of a Portlet Application can be down at servlet init() time
  This requires infusing the Jetspeed servlet into a Portlet application with a separate command
line tool: see the deploy-tool component.
  Then the portlet application can be deployed to any application server, and when the servlet
is initialized,
  it attempts to register with Jetspeed 'on the fly'
  
  This current implementation does not yet support re-deployment properly.
  Im working on that next ...
  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.4       +76 -2     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/ApplicationServerPAM.java
  
  Index: ApplicationServerPAM.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/ApplicationServerPAM.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ApplicationServerPAM.java	13 Jul 2004 17:52:33 -0000	1.3
  +++ ApplicationServerPAM.java	22 Jul 2004 23:38:39 -0000	1.4
  @@ -15,13 +15,20 @@
    */
   package org.apache.jetspeed.tools.pamanager;
   
  +import java.io.IOException;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.jetspeed.components.persistence.store.PersistenceStore;
   import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
   import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
   import org.apache.jetspeed.container.window.PortletWindowAccessor;
  +import org.apache.jetspeed.exception.RegistryException;
  +import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
  +import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
   import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager;
   import org.apache.jetspeed.util.ArgUtil;
  +import org.apache.jetspeed.util.FileSystemHelper;
   import org.apache.jetspeed.util.descriptor.PortletApplicationWar;
   import org.picocontainer.Startable;
   
  @@ -35,7 +42,7 @@
    * @version $Id$
    */
   
  -public class ApplicationServerPAM extends FileSystemPAM implements Lifecycle, Startable
  +public class ApplicationServerPAM extends FileSystemPAM implements Lifecycle, Startable,
DeploymentRegistration
   {
       // Implementaion of deplyment interface
       public final static String PAM_PROPERTY_SERVER = "server";
  @@ -285,4 +292,71 @@
               throw new PortletApplicationException(e);
           }
       }
  +    
  +    public void registerPortletApplication(FileSystemHelper fileSystem, 
  +                                           String portletApplicationName)
  +    throws RegistryException
  +    {
  +        MutablePortletApplication pa = 
  +            registry.getPortletApplication(portletApplicationName);
  +        if (pa != null)
  +        {
  +            // get the deployment date
  +            System.out.println("PA " + portletApplicationName + " is already deployed.");
  +            return;
  +        }
  +        
  +        PortletApplicationWar paWar = null;
  +        try
  +        {
  +            paWar = new PortletApplicationWar(fileSystem,
  +                        portletApplicationName,
  +                        "/" + portletApplicationName);
  +        }
  +        catch (IOException e)
  +        {
  +            throw new RegistryException("Failed to create PA WAR", e);
  +        }
  +    
  +        MutablePortletApplication app;
  +        PersistenceStore store = registry.getPersistenceStore();
  +        String paName = paWar.getPortletApplicationName();
  +        
  +        try
  +        {
  +        app = paWar.createPortletApp();
  +        
  +        if (app == null)
  +        {
  +        String msg = "Error loading portlet.xml: ";
  +        log.error(msg);
  +        throw new RegistryException(msg);
  +        }
  +        
  +        
  +        app.setApplicationType(MutablePortletApplication.WEBAPP);
  +        
  +        // load the web.xml
  +        log.info("Loading web.xml into memory....");
  +        MutableWebApplication webapp = paWar.createWebApp();
  +        paWar.validate();
  +        app.setWebApplicationDefinition(webapp);
  +        
  +        // save it to the registry
  +        log.info("Saving the portlet.xml in the registry...");
  +        store.getTransaction().begin();
  +        registry.registerPortletApplication(app);
  +        log.info("Committing registry changes...");
  +        store.getTransaction().commit();
  +        }
  +        catch (Exception e)
  +        {
  +        String msg = "Unable to register portlet application, " + paName + ", through the
portlet registry: "
  +        + e.toString();
  +        log.error(msg, e);
  +        store.getTransaction().rollback();
  +        throw new RegistryException(msg, e);
  +    }
  +
  +}    
   }
  
  
  
  1.1                  jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/DeploymentRegistration.java
  
  Index: DeploymentRegistration.java
  ===================================================================
  /*
   * Copyright 2000-2001,2004 The Apache Software Foundation.
   * 
   * Licensed 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.jetspeed.tools.pamanager;
  
  import org.apache.jetspeed.exception.RegistryException;
  import org.apache.jetspeed.util.FileSystemHelper;
  
  
  /**
   * Jetspeed Deployment Registration
   *
   * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
   * @version $Id: DeploymentRegistration.java,v 1.1 2004/07/22 23:38:39 taylor Exp $
   */
  public interface DeploymentRegistration
  {
      void registerPortletApplication(
              FileSystemHelper fileSystem, 
              String portletApplicationName)
          throws RegistryException;    
  }
  
  
  
  1.10      +77 -72    jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
  
  Index: JetspeedContainerServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JetspeedContainerServlet.java	26 May 2004 17:24:18 -0000	1.9
  +++ JetspeedContainerServlet.java	22 Jul 2004 23:38:39 -0000	1.10
  @@ -15,11 +15,10 @@
    */
   package org.apache.jetspeed.container;
   
  +import java.io.File;
   import java.io.IOException;
   import java.io.PrintWriter;
   import java.io.StringWriter;
  -import java.net.URL;
  -import java.net.URLClassLoader;
   
   import javax.portlet.ActionRequest;
   import javax.portlet.ActionResponse;
  @@ -38,8 +37,12 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.factory.JetspeedPortletFactory;
  +import org.apache.jetspeed.services.JetspeedPortletServices;
  +import org.apache.jetspeed.services.PortletServices;
  +import org.apache.jetspeed.tools.pamanager.DeploymentRegistration;
  +import org.apache.jetspeed.util.DirectoryHelper;
  +import org.apache.jetspeed.util.FileSystemHelper;
   import org.apache.pluto.om.portlet.PortletDefinition;
  -// import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
   
   /**
    * Jetspeed Container entry point.
  @@ -53,22 +56,10 @@
       private final static Log console = LogFactory.getLog(CONSOLE_LOGGER);
   
       /**
  -     * In certain situations the init() method is called more than once,
  -     * somtimes even concurrently. This causes bad things to happen,
  -     * so we use this flag to prevent it.
  -     */
  -    private static boolean firstInit = true;
  -
  -    /**
        * Whether init succeeded or not.
        */
       private static Throwable initFailure = null;
   
  -    /**
  -     * Should initialization activities be performed during doGet()
  -     * execution?
  -     */
  -    private static boolean firstDoGet = true;
   
       private static String webappRoot;
   
  @@ -88,42 +79,29 @@
               log.info(INIT_START_MSG + " " + config.getServletContext().getRealPath("/"));
               super.init(config);
   
  -            if (!firstInit)
  -            {
  -                log.info("Double initialization of Jetspeed was attempted!");
  -                return;
  -            }
  -            // executing init will trigger some static initializers, so we have
  -            // only one chance.
  -            firstInit = false;
   
               try
  -            {
  +            {                
                   ServletContext context = config.getServletContext();
  -                /*
  -                                String propertiesFilename =
  -                                    ServletHelper.findInitParameter(context, config,
  -                                                      JETSPEED_PROPERTIES_KEY,
  -                                                      JETSPEED_PROPERTIES_DEFAULT);
  -                
  -                                String applicationRoot =
  -                                    ServletHelper.findInitParameter(context, config,
  -                                                  APPLICATION_ROOT_KEY,
  -                                                  APPLICATION_ROOT_DEFAULT);
  -                  */
  -                webappRoot = config.getServletContext().getRealPath("/");
  -                /*
  -                                if (applicationRoot == null || applicationRoot.equals(WEB_CONTEXT))
  -                                {
  -                                    applicationRoot = webappRoot;
  -                                }
  -                
  -                                Configuration properties = (Configuration)
  -                                    new PropertiesConfiguration(ServletHelper.getRealPath(config,
propertiesFilename));
  +                webappRoot = config.getServletContext().getRealPath("/");             
  
  +                String registerAtInit = config.getInitParameter("registerAtInit");
  +                if (null != registerAtInit)
  +                {
  +                    System.out.println("*** Registering at INIT: " + context.getServletContextName());
  +                    String portletApplication = config.getInitParameter("portletApplication");
  +                    if (null == portletApplication)
  +                    {
  +                        throw new ServletException("Portlet Application Name not supplied
in Init Parameters.");
  +                    }
  +                    
  +                    registerPortletApplication(context, portletApplication);
  +                    
  +                }
  +                else
  +                {
  +                    System.out.println("*** Not Registering at INIT: " + context.getServletContextName());
  +                }
                   
  -                                properties.setProperty(APPLICATION_ROOT_KEY, applicationRoot);
  -                                properties.setProperty(WEBAPP_ROOT_KEY, webappRoot);
  -                  */
               }
               catch (Exception e)
               {
  @@ -138,28 +116,64 @@
           }
       }
   
  -    /**
  -     * Initializes the services which need <code>RunData</code> to
  -     * initialize themselves (post startup).
  -     *
  -     * @param data The first <code>GET</code> request.
  -     */
  -    public synchronized final void init(HttpServletRequest request, HttpServletResponse
response)
  +    
  +    private void registerPortletApplication(ServletContext context, String portletApplicationName)
       {
  -        synchronized (JetspeedContainerServlet.class)
  +        System.out.println("*** Registering PA: " + portletApplicationName);
  +        //InputStream portletStream = null;
  +        //InputStream servletStream = null;
  +        
  +        try
           {
  -            if (firstDoGet)
  +            //portletStream = context.getResourceAsStream("WEB-INF/portlet.xml");
  +            //servletStream = context.getResourceAsStream("WEB-INF/web.xml");
  +                                   
  +            PortletServices services = JetspeedPortletServices.getSingleton();        
                
  +            DeploymentRegistration registrar =
  +                (DeploymentRegistration)services.getService("PAM"); 
  +            
  +            if (registrar != null)
               {
  -                // Mark that we're done.
  -                firstDoGet = false;
  +                System.out.println("registrar found: " + registrar);
  +                FileSystemHelper webapp = new DirectoryHelper(new File(context.getRealPath("/")));
  +                registrar.registerPortletApplication(webapp, portletApplicationName);
  +                System.out.println("done registering " + registrar);                
               }
  +            else
  +            {
  +                System.out.println("registry not yet available...");
  +            }            
  +        }
  +        catch (Exception e)
  +        {
  +            e.printStackTrace();
           }
  +        finally
  +        {
  +            //closeStream(portletStream);
  +            //closeStream(servletStream);
  +        }
  +        
       }
   
  +    /*
  +    private void closeStream(InputStream stream)
  +    {
  +        try
  +        {
  +            if (stream != null)
  +            {
  +                stream.close();
  +            }
  +        }
  +        catch (IOException e)
  +        {        
  +        }
  +    }
  +    */
       // -------------------------------------------------------------------
       // R E Q U E S T  P R O C E S S I N G
       // -------------------------------------------------------------------
  -    static private final String PHONEY_PORTLET_WINDOW = "<P>----------------------------------</P>";
   
       /**
        * The primary method invoked when the Jetspeed servlet is executed.
  @@ -171,7 +185,7 @@
        */
       public final void doGet(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
       {
  -    	String portletName = null;
  +        String portletName = null;
           try
           {
               // Check to make sure that we started up properly.
  @@ -180,17 +194,11 @@
                   throw initFailure;
               }
   
  -            // If this is the first invocation, perform some late initialization.
  -            if (firstDoGet)
  -            {
  -                init(request, response);
  -            }
  -
               // infuseClasspath();
   
               PortletDefinition portletDefinition = (PortletDefinition) request.getAttribute(ContainerConstants.PORTLET_ENTITY);
               Portlet portlet = JetspeedPortletFactory.getPortlet(this.getServletConfig(),
portletDefinition);
  -			portletName = portletDefinition.getName();
  +            portletName = portletDefinition.getName();
               Integer method = (Integer) request.getAttribute(ContainerConstants.METHOD_ID);
               if (method == ContainerConstants.METHOD_NOOP)
               {
  @@ -272,9 +280,6 @@
        */
       public final void destroy()
       {
  -        // Allow turbine to be started back up again.
  -        firstInit = true;
  -
           log.info("Done shutting down!");
       }
   
  @@ -314,4 +319,4 @@
   
       }
   
  -}
  +}
  \ No newline at end of file
  
  
  
  1.4       +20 -5     jakarta-jetspeed-2/components/deploy-tool/src/java/org/apache/jetspeed/tools/deploy/JetspeedDeploy.java
  
  Index: JetspeedDeploy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/deploy-tool/src/java/org/apache/jetspeed/tools/deploy/JetspeedDeploy.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JetspeedDeploy.java	22 Jul 2004 05:16:11 -0000	1.3
  +++ JetspeedDeploy.java	22 Jul 2004 23:38:39 -0000	1.4
  @@ -50,16 +50,17 @@
       }
   
       private final byte[] buffer = new byte[4096];
  -
  +    
       public JetspeedDeploy(String inputName, String outputName) throws Exception 
       {
           JarInputStream jin = null;
           JarOutputStream jout = null;
           try 
           {
  +            String portletApplicationName = getPortletApplicationName(outputName);
               jin = new JarInputStream(new FileInputStream(inputName));
               jout = new JarOutputStream(new FileOutputStream(outputName), jin.getManifest());
  -
  +            
               // copy over all of the files in the input war to the output
               // war except for web.xml and portlet.xml, which we parse for
               // use later
  @@ -94,7 +95,7 @@
                   throw new IllegalArgumentException("WEB-INF/portlet.xml");
               }
               
  -            JetspeedWebApplicationRewriter rewriter = new JetspeedWebApplicationRewriter(webXml,
true);
  +            JetspeedWebApplicationRewriter rewriter = new JetspeedWebApplicationRewriter(webXml,
portletApplicationName, true);
               rewriter.processWebXML();
               
               // mung the web.xml
  @@ -164,6 +165,20 @@
           }
       }
   
  +    private String getPortletApplicationName(String path)
  +    {
  +        File file = new File(path);
  +        String name = file.getName();
  +        String portletApplicationName = name;
  +        
  +        int index = name.lastIndexOf(".");
  +        if (index > -1)
  +        {
  +            portletApplicationName = name.substring(0, index); 
  +        }
  +        return portletApplicationName;
  +    }
  +    
       private class UncloseableInputStream extends InputStream {
           private final InputStream in;
   
  @@ -207,4 +222,4 @@
               return in.markSupported();
           }
       }
  -}
  +}
  \ No newline at end of file
  
  
  
  1.4       +143 -133  jakarta-jetspeed-2/components/deploy-tool/src/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter.java
  
  Index: JetspeedWebApplicationRewriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/deploy-tool/src/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JetspeedWebApplicationRewriter.java	21 Jul 2004 22:19:32 -0000	1.3
  +++ JetspeedWebApplicationRewriter.java	22 Jul 2004 23:38:39 -0000	1.4
  @@ -49,14 +49,16 @@
       protected static final String[] ELEMENTS_BEFORE_SERVLET_MAPPING = new String[]{"icon",
"display-name",
               "description", "distributable", "context-param", "filter", "filter-mapping",
"listener", "servlet",
               "servlet-mapping"};
  -	  
  +      
       private Document document;
  +    private String portletApplication;
       private boolean changed = false;
       private boolean registerAtInit = false;
       
  -    public JetspeedWebApplicationRewriter(Document doc, boolean registerAtInit)
  +    public JetspeedWebApplicationRewriter(Document doc, String portletApplication, boolean
registerAtInit)
       {
  -    		this.document = doc;
  +            this.document = doc;
  +            this.portletApplication = portletApplication;
               this.registerAtInit = registerAtInit;
       }
   
  @@ -65,68 +67,68 @@
               this.document = doc;
       }
       
  -	/**
  -	 * 
  -	 * <p>
  -	 * processWebXML
  -	 * </p>
  -	 * 
  -	 * Infuses this PortletApplicationWar's web.xml file with
  -	 * <code>servlet</code> and a <code>servlet-mapping</code> element
for
  -	 * the JetspeedContainer servlet. This is only done if the descriptor does
  -	 * not already contain these items.
  -	 * 
  -	 * @throws MetaDataException
  -	 *             if there is a problem infusing
  -	 */
  -	public void processWebXML()
  +    /**
  +     * 
  +     * <p>
  +     * processWebXML
  +     * </p>
  +     * 
  +     * Infuses this PortletApplicationWar's web.xml file with
  +     * <code>servlet</code> and a <code>servlet-mapping</code>
element for
  +     * the JetspeedContainer servlet. This is only done if the descriptor does
  +     * not already contain these items.
  +     * 
  +     * @throws MetaDataException
  +     *             if there is a problem infusing
  +     */
  +    public void processWebXML()
       throws Exception
  -	{
  -	    SAXBuilder builder = new SAXBuilder();
  -	    Writer webXmlWriter = null;
  -	    InputStream webXmlIn = null;
  -	
  -	    try
  -	    {
  -	        // Use the local dtd instead of remote dtd. This
  -	        // allows to deploy the application offline
  -	        builder.setEntityResolver(new EntityResolver()
  -	        {
  -	            public InputSource resolveEntity( java.lang.String publicId, java.lang.String
systemId )
  -	                    throws SAXException, java.io.IOException
  -	            {
  -	
  -	                if (systemId.equals("http://java.sun.com/dtd/web-app_2_3.dtd"))
  -	                {
  -	                    return new InputSource(getClass().getResourceAsStream("web-app_2_3.dtd"));
  -	                }
  -	                else return null;
  -	            }
  -	        });
  -	
  -	
  -	        Element root = document.getRootElement();
  -		
  -	        Object jetspeedServlet = XPath.selectSingleNode(document, JETSPEED_SERVLET_XPATH);
  -	        Object jetspeedServletMapping = XPath.selectSingleNode(document, JETSPEED_SERVLET_MAPPING_XPATH);
  -	        if (document.getRootElement().getChildren().size() == 0)
  -	        {
  -	            throw new Exception("Source web.xml has no content!!!");
  -	        }
  -		
  -	        if (jetspeedServlet == null)
  -	        {
  -	            Element jetspeedServletElement = new Element("servlet");
  -	            Element servletName = (Element) new Element("servlet-name").addContent("JetspeedContainer");
  -	            Element servletDspName = (Element) new Element("display-name").addContent("Jetspeed
Container");
  -	            Element servletDesc = (Element) new Element("description")
  -	                    .addContent("MVC Servlet for Jetspeed Portlet Applications");
  -	            Element servletClass = (Element) new Element("servlet-class")
  -	                    .addContent("org.apache.jetspeed.container.JetspeedContainerServlet");
  -	            jetspeedServletElement.addContent(servletName);
  -	            jetspeedServletElement.addContent(servletDspName);
  -	            jetspeedServletElement.addContent(servletDesc);
  -	            jetspeedServletElement.addContent(servletClass);
  +    {
  +        SAXBuilder builder = new SAXBuilder();
  +        Writer webXmlWriter = null;
  +        InputStream webXmlIn = null;
  +    
  +        try
  +        {
  +            // Use the local dtd instead of remote dtd. This
  +            // allows to deploy the application offline
  +            builder.setEntityResolver(new EntityResolver()
  +            {
  +                public InputSource resolveEntity( java.lang.String publicId, java.lang.String
systemId )
  +                        throws SAXException, java.io.IOException
  +                {
  +    
  +                    if (systemId.equals("http://java.sun.com/dtd/web-app_2_3.dtd"))
  +                    {
  +                        return new InputSource(getClass().getResourceAsStream("web-app_2_3.dtd"));
  +                    }
  +                    else return null;
  +                }
  +            });
  +    
  +    
  +            Element root = document.getRootElement();
  +        
  +            Object jetspeedServlet = XPath.selectSingleNode(document, JETSPEED_SERVLET_XPATH);
  +            Object jetspeedServletMapping = XPath.selectSingleNode(document, JETSPEED_SERVLET_MAPPING_XPATH);
  +            if (document.getRootElement().getChildren().size() == 0)
  +            {
  +                throw new Exception("Source web.xml has no content!!!");
  +            }
  +        
  +            if (jetspeedServlet == null)
  +            {
  +                Element jetspeedServletElement = new Element("servlet");
  +                Element servletName = (Element) new Element("servlet-name").addContent("JetspeedContainer");
  +                Element servletDspName = (Element) new Element("display-name").addContent("Jetspeed
Container");
  +                Element servletDesc = (Element) new Element("description")
  +                        .addContent("MVC Servlet for Jetspeed Portlet Applications");
  +                Element servletClass = (Element) new Element("servlet-class")
  +                        .addContent("org.apache.jetspeed.container.JetspeedContainerServlet");
  +                jetspeedServletElement.addContent(servletName);
  +                jetspeedServletElement.addContent(servletDspName);
  +                jetspeedServletElement.addContent(servletDesc);
  +                jetspeedServletElement.addContent(servletClass);
                   if (this.registerAtInit)
                   {
                       Element paramName = (Element) new Element("param-name").addContent("registerAtInit");
  @@ -134,82 +136,90 @@
                       Element initParam = new Element("init-param");
                       initParam.addContent(paramName);
                       initParam.addContent(paramValue);
  -                    jetspeedServletElement.addContent(initParam);                    
  +                    jetspeedServletElement.addContent(initParam);
  +                    
  +                    Element param2Name = (Element) new Element("param-name").addContent("portletApplication");
  +                    Element param2Value = (Element) new Element("param-value").addContent(portletApplication);

  +                    Element init2Param = new Element("init-param");
  +                    init2Param.addContent(param2Name);
  +                    init2Param.addContent(param2Value);
  +                    jetspeedServletElement.addContent(init2Param);                    
  +                    
                       Element loadOnStartup = (Element) new Element("load-on-startup").addContent("100");
                       jetspeedServletElement.addContent(loadOnStartup);
                   }
  -	            insertElementCorrectly(root, jetspeedServletElement, ELEMENTS_BEFORE_SERVLET);
  -	            changed = true;
  -	        }
  -	
  -	        if (jetspeedServletMapping == null)
  -	        {
  -	
  -	            Element jetspeedServletMappingElement = new Element("servlet-mapping");
  -	
  -	            Element servletMapName = (Element) new Element("servlet-name").addContent("JetspeedContainer");
  -	            Element servletUrlPattern = (Element) new Element("url-pattern").addContent("/container/*");
  -	
  -	            jetspeedServletMappingElement.addContent(servletMapName);
  -	            jetspeedServletMappingElement.addContent(servletUrlPattern);
  -	
  -	            insertElementCorrectly(root, jetspeedServletMappingElement, ELEMENTS_BEFORE_SERVLET_MAPPING);
  -	            changed = true;
  -	        }		
  -	    }
  -	    catch (Exception e)
  -	    {
  -	        throw new Exception("Unable to process web.xml for infusion " + e.toString(),
e);
  -	    }
  -	
  -	}
  -	
  +                insertElementCorrectly(root, jetspeedServletElement, ELEMENTS_BEFORE_SERVLET);
  +                changed = true;
  +            }
  +    
  +            if (jetspeedServletMapping == null)
  +            {
  +    
  +                Element jetspeedServletMappingElement = new Element("servlet-mapping");
  +    
  +                Element servletMapName = (Element) new Element("servlet-name").addContent("JetspeedContainer");
  +                Element servletUrlPattern = (Element) new Element("url-pattern").addContent("/container/*");
  +    
  +                jetspeedServletMappingElement.addContent(servletMapName);
  +                jetspeedServletMappingElement.addContent(servletUrlPattern);
  +    
  +                insertElementCorrectly(root, jetspeedServletMappingElement, ELEMENTS_BEFORE_SERVLET_MAPPING);
  +                changed = true;
  +            }        
  +        }
  +        catch (Exception e)
  +        {
  +            throw new Exception("Unable to process web.xml for infusion " + e.toString(),
e);
  +        }
  +    
  +    }
  +    
       public boolean isChanged()
       {
           return changed;
       }
       
  -	/**
  -	 * 
  -	 * <p>
  -	 * insertElementCorrectly
  -	 * </p>
  -	 * 
  -	 * @param root
  -	 *            JDom element representing the &lt; web-app &gt;
  -	 * @param toInsert
  -	 *            JDom element to insert into the web.xml hierarchy.
  -	 * @param elementsBefore
  -	 *            an array of web.xml elements that should be defined before the
  -	 *            element we want to insert. This order should be the order
  -	 *            defined by the web.xml's DTD type definition.
  -	 */
  -	protected void insertElementCorrectly( Element root, Element toInsert, String[] elementsBefore
)
  +    /**
  +     * 
  +     * <p>
  +     * insertElementCorrectly
  +     * </p>
  +     * 
  +     * @param root
  +     *            JDom element representing the &lt; web-app &gt;
  +     * @param toInsert
  +     *            JDom element to insert into the web.xml hierarchy.
  +     * @param elementsBefore
  +     *            an array of web.xml elements that should be defined before the
  +     *            element we want to insert. This order should be the order
  +     *            defined by the web.xml's DTD type definition.
  +     */
  +    protected void insertElementCorrectly( Element root, Element toInsert, String[] elementsBefore
)
       throws Exception
  -	{
  -	    List allChildren = root.getChildren();
  -	    List elementsBeforeList = Arrays.asList(elementsBefore);
  -	    toInsert.detach();
  -	    int insertAfter = 0;
  -	    for (int i = 0; i < allChildren.size(); i++)
  -	    {
  -	        Element element = (Element) allChildren.get(i);
  -	        if (elementsBeforeList.contains(element.getName()))
  -	        {
  -	            // determine the Content index of the element to insert after
  -	            insertAfter = root.indexOf(element);
  -	        }
  -	    }
  -	
  -	    try
  -	    {
  -	        root.addContent((insertAfter + 1), toInsert);
  -	    }
  -	    catch (ArrayIndexOutOfBoundsException e)
  -	    {
  -	        root.addContent(toInsert);
  -	    }
  -	}
  -	
  - 
  +    {
  +        List allChildren = root.getChildren();
  +        List elementsBeforeList = Arrays.asList(elementsBefore);
  +        toInsert.detach();
  +        int insertAfter = 0;
  +        for (int i = 0; i < allChildren.size(); i++)
  +        {
  +            Element element = (Element) allChildren.get(i);
  +            if (elementsBeforeList.contains(element.getName()))
  +            {
  +                // determine the Content index of the element to insert after
  +                insertAfter = root.indexOf(element);
  +            }
  +        }
  +    
  +        try
  +        {
  +            root.addContent((insertAfter + 1), toInsert);
  +        }
  +        catch (ArrayIndexOutOfBoundsException e)
  +        {
  +            root.addContent(toInsert);
  +        }
  +    }
  +    
  +    
   }
  
  
  
  1.1                  jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/util/FileSystemHelper.java
  
  Index: FileSystemHelper.java
  ===================================================================
  /*
   * Copyright 2000-2001,2004 The Apache Software Foundation.
   * 
   * Licensed 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.jetspeed.util;
  
  import java.io.File;
  import java.io.FileFilter;
  import java.io.IOException;
  
  /**
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   *
   * TODO To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Generation - Code and Comments
   */
  public interface FileSystemHelper
  {
      /**
       * 
       * <p>
       * copyFrom
       * </p>
       *
       * @param directory Directory to copy content from
       * @throws {@link java.io.IlleaglArgumentException} if the <code>directory.isDirectory</code>
       * returns <code>false</code>
       */
      void copyFrom(File directory) throws IOException;
      
      /**
       * 
       * <p>
       * copyFrom
       * </p>
       *
       * @param directory
       * @param fileFilter
       * @throws IOException
       */
      void copyFrom(File directory, FileFilter fileFilter) throws IOException;
      
      /**
       * 
       * <p>
       * remove
       * </p>
       * Removes the underlying directory structure from the root directory down.
       * 
       * @return <code>true</code> if the removal war successful, otherwise returns
       * <code>false</code>.
       */
      boolean remove();
      
      /**
       * 
       * <p>
       * getRootDirectory
       * </p>
       *
       * @return the root of the directory structure
       */
      File getRootDirectory();    
      
      /**
       * 
       * <p>
       * close
       * </p>
       *
       * Cleans up resources opened up specifically by this FileSystemHelper 
       *
       */
      void close() throws IOException;
      
      /**
       * 
       * <p>
       * getSourcePath
       * </p>
       * 
       * Returns the true location of this FileSystemHelper backing object on
       * the file system.  This IS NOT always as the path of the object returned
       * from the {@link getRootDirectory} method. 
       *
       * @return the true location of this FileSystemHelper backing object. 
       */
      String getSourcePath();
      
  }
  
  
  
  1.46      +2 -0      jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/jetspeed.groovy
  
  Index: jetspeed.groovy
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/jetspeed.groovy,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- jetspeed.groovy	9 Jul 2004 18:30:58 -0000	1.45
  +++ jetspeed.groovy	22 Jul 2004 23:38:39 -0000	1.46
  @@ -507,6 +507,8 @@
                             )
   )
   
  +services.addPortletService("PAM", container.getComponentInstance("PAM"))
  +
   portletApplicationListener = new DeployPortletAppEventListener(webAppDeployDirectory, 
                                      container.getComponentInstance("PAM"), 
                                      container.getComponentInstance(PortletRegistryComponent));
 
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message