Author: weaver
Date: Thu Nov  8 07:00:35 2007
New Revision: 593180

URL: http://svn.apache.org/viewvc?rev=593180&view=rev
Log:
JS2-799 Fixed support for running a portlet application from the root ("/") 
context.

Modified:
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java?rev=593180&r1=593179&r2=593180&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
 Thu Nov  8 07:00:35 2007
@@ -59,6 +59,7 @@
     private boolean started = false;
     private Timer   startTimer = null;
     private PortalSessionsManager psm;
+    private String contextPath;
 
     // -------------------------------------------------------------------
     // I N I T I A L I Z A T I O N
@@ -82,14 +83,26 @@
 
             started = false;
             startTimer = null;            
-            contextName = config.getInitParameter("contextName");
+            contextName = config.getInitParameter("contextName");            
+            contextPath = config.getInitParameter("contextPath");
 
             if (null == contextName || contextName.length() == 0)
             {
                 contextName = null; // just to make sure for the destroy method
                 
                 throw new ServletException(JCS + "Portlet Application 
contextName not supplied in Init Parameters.");
-            }            
+            }
+            
+            if (null == contextPath || contextPath.length() == 0)
+            {
+                contextPath = "/"+contextName;
+            }
+            else if(!contextPath.startsWith("/"))
+            {
+                throw new ServletException(JCS + "Portlet Application 
contextPath must start with a  \"/\"."); 
+            }
+            
+            
             String paDir = context.getRealPath("/");
             if ( paDir == null )
                 {
@@ -141,7 +154,7 @@
                       {
                         if (startTimer != null)
                         {
-                          if (attemptStart(context, contextName, paDir, 
paClassLoader)) {
+                          if (attemptStart(context, contextName, contextPath, 
paDir, paClassLoader)) {
                             startTimer.cancel();
                             startTimer = null;
                         } else {
@@ -156,7 +169,7 @@
                 10000);
     }
 
-    private boolean attemptStart(ServletContext context, String contextPath, 
String paDir, ClassLoader paClassLoader) 
+    private boolean attemptStart(ServletContext context, String contextName, 
String contextPath, String paDir, ClassLoader paClassLoader) 
     {
         try
         {
@@ -170,7 +183,7 @@
                 if (pam != null && pam.isStarted())
                 {
                     DirectoryHelper paDirHelper = new DirectoryHelper(new 
File(paDir));
-                    pam.startPortletApplication(contextPath, paDirHelper, 
paClassLoader);
+                    pam.startPortletApplication(contextName, contextPath, 
paDirHelper, paClassLoader);
                     started = true;
                     psm = 
(PortalSessionsManager)services.getService(PortalSessionsManager.SERVICE_NAME);
 

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java?rev=593180&r1=593179&r2=593180&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
 Thu Nov  8 07:00:35 2007
@@ -162,7 +162,7 @@
                throws RegistryException
        {
         checkStarted();
-        startPA(contextName, warStruct, paClassLoader, 
MutablePortletApplication.LOCAL);
+        startPA(contextName, "/"+contextName, warStruct, paClassLoader, 
MutablePortletApplication.LOCAL);
        }
 
     public void startInternalApplication(String contextName) throws 
RegistryException
@@ -178,7 +178,7 @@
             app.setApplicationType(MutablePortletApplication.INTERNAL);
             registry.updatePortletApplication(app);
         }
-        startPA(contextName, dir, contextClassLoader, 
MutablePortletApplication.INTERNAL);
+        startPA(contextName, "/"+contextName, dir, contextClassLoader, 
MutablePortletApplication.INTERNAL);
         // startInternal(contextName, warStruct, paClassLoader, true);        
     }
     
@@ -186,18 +186,25 @@
                ClassLoader paClassLoader)
                throws RegistryException
        {
+         startPortletApplication(contextName, "/"+contextName, warStruct, 
paClassLoader);
+       }
+       
+    public void startPortletApplication(String contextName, String 
contextPath, FileSystemHelper warStruct,
+            ClassLoader paClassLoader) throws RegistryException
+    {
         checkStarted();
         ClassLoader contextClassLoader = 
Thread.currentThread().getContextClassLoader();
         
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
         try
         {
-            startPA(contextName, warStruct, paClassLoader, 
MutablePortletApplication.WEBAPP);
+            startPA(contextName, contextPath, warStruct, paClassLoader, 
MutablePortletApplication.WEBAPP);
         }
         finally
         {
             Thread.currentThread().setContextClassLoader(contextClassLoader);
         }
-       }
+        
+    }    
 
        public void stopLocalPortletApplication(String contextName)
                throws RegistryException
@@ -412,14 +419,14 @@
                }
        }
 
-       protected void startPA(String contextName, FileSystemHelper warStruct,
+       protected void startPA(String contextName, String contextPath, 
FileSystemHelper warStruct,
                ClassLoader paClassLoader, int paType)
        throws RegistryException
        {
-           startPA(contextName, warStruct, paClassLoader, paType, 0);
+           startPA(contextName, contextPath, warStruct, paClassLoader, paType, 
0);
        }
        
-       protected void startPA(String contextName, FileSystemHelper warStruct,
+       protected void startPA(String contextName, String contextPath, 
FileSystemHelper warStruct,
                ClassLoader paClassLoader, int paType, long checksum)
        throws RegistryException
        {
@@ -428,7 +435,8 @@
                {
             boolean register = true;
             boolean monitored = checksum != 0;
-            paWar = new PortletApplicationWar(warStruct, contextName, "/" + 
contextName, checksum);
+            // paWar = new PortletApplicationWar(warStruct, contextName, "/" + 
contextName, checksum);
+            paWar = new PortletApplicationWar(warStruct, contextName, 
contextPath, checksum);
             try
             {
                 if (paClassLoader == null)
@@ -553,7 +561,7 @@
             DescriptorChangeMonitor changeMonitor = this.monitor;
             if (!monitored && changeMonitor != null)
             {
-                changeMonitor.monitor(contextName,paClassLoader, paType, 
warStruct.getRootDirectory(), checksum);
+                changeMonitor.monitor(contextName, contextPath, paClassLoader, 
paType, warStruct.getRootDirectory(), checksum);
             }
                }
                finally
@@ -732,6 +740,7 @@
         private static class DescriptorChangeMonitorInfo
         {
             private String contextName;
+            private String contextPath;
             private ClassLoader paClassLoader;
             private int  paType;
             private File paDir;
@@ -749,9 +758,10 @@
                 this.contextName = contextName;
             }
             
-            public DescriptorChangeMonitorInfo(String contextName, ClassLoader 
paClassLoader, int paType, File paDir, long checksum)
+            public DescriptorChangeMonitorInfo(String contextName, String 
contextPath, ClassLoader paClassLoader, int paType, File paDir, long checksum)
             {
                 this.contextName = contextName;
+                this.contextPath = contextPath;
                 this.paClassLoader = paClassLoader;
                 this.paType = paType;
                 this.paDir = paDir.isAbsolute() ? paDir : 
paDir.getAbsoluteFile();
@@ -822,6 +832,11 @@
             {
                 return obsolete;
             }
+
+            public String getContextPath()
+            {
+                return contextPath;
+            }
         }        
 
         private PortletApplicationManager pam;
@@ -872,9 +887,9 @@
             monitorInfos.clear();
         }
         
-        public synchronized void monitor(String contextName, ClassLoader 
paClassLoader, int paType, File paDir, long checksum)
+        public synchronized void monitor(String contextName, String 
contextPath, ClassLoader paClassLoader, int paType, File paDir, long checksum)
         {
-            monitorInfos.add(new DescriptorChangeMonitorInfo(contextName, 
paClassLoader, paType, paDir, checksum));
+            monitorInfos.add(new DescriptorChangeMonitorInfo(contextName, 
contextPath, paClassLoader, paType, paDir, checksum));
         }
         
         public synchronized void remove(String contextName)
@@ -919,7 +934,7 @@
                                 {
                                     try
                                     {
-                                        
pam.startPA(monitorInfo.getContextName(), new 
DirectoryHelper(monitorInfo.getPADir()),
+                                        
pam.startPA(monitorInfo.getContextName(), monitorInfo.getContextPath(), new 
DirectoryHelper(monitorInfo.getPADir()),
                                                 
monitorInfo.getPAClassLoader(), monitorInfo.getPortletApplicationType(), 
monitorInfo.getChecksum());
                                     }
                                     catch (Exception e)
@@ -938,5 +953,7 @@
                 }
             }
         }        
-    }    
+    }
+
+
 }

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java?rev=593180&r1=593179&r2=593180&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java
 Thu Nov  8 07:00:35 2007
@@ -31,6 +31,17 @@
   public static final String LOCAL_PA_PREFIX = "jetspeed-";
   
   public boolean isStarted();
+  /**
+   * Allows deployment to override the default of using the 
<code>contextName</code> as the
+   * context path.
+   * 
+   * @param contextName
+   * @param contextPath
+   * @param warStruct
+   * @param paClassLoader
+   * @throws RegistryException
+   */
+  void startPortletApplication(String contextName, String contextPath, 
FileSystemHelper warStruct, ClassLoader paClassLoader) throws RegistryException;
   void startPortletApplication(String contextName, FileSystemHelper warStruct, 
ClassLoader paClassLoader) throws RegistryException;
   void stopPortletApplication(String contextName) throws RegistryException;
   void startLocalPortletApplication(String contextName, FileSystemHelper 
warStruct, ClassLoader paClassLoader) throws RegistryException;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to