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/06/02 21:24:52 UTC

svn commit: r543772 - in /portals/pluto/trunk: maven-pluto-plugin/src/main/java/org/apache/pluto/maven/ pluto-taglib/src/main/java/org/apache/pluto/tags/el/ pluto-util/src/main/java/org/apache/pluto/util/install/ pluto-util/src/main/java/org/apache/plu...

Author: esm
Date: Sat Jun  2 12:24:51 2007
New Revision: 543772

URL: http://svn.apache.org/viewvc?view=rev&rev=543772
Log:
[PLUTO-375], [PLUTO-376]: Pluto 1.2.x now works Tomcat 6.0.x (tested with Tomcat 6.0.13).  The pluto maven plugin was updated to support installation into Tomcat 6, and the JSP 2.1 Expression Evaluator was implemented thanks to a patch from Benjamin Gould.

Added:
    portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat6/
    portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat6/Tomcat6FileSystemInstaller.java
Modified:
    portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/InstallationDependency.java
    portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java
    portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/PortalInstallerFactory.java
    portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/jetty/Jetty5FileSystemInstaller.java
    portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat5/Tomcat5FileSystemInstaller.java

Modified: portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/InstallationDependency.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/InstallationDependency.java?view=diff&rev=543772&r1=543771&r2=543772
==============================================================================
--- portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/InstallationDependency.java (original)
+++ portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/InstallationDependency.java Sat Jun  2 12:24:51 2007
@@ -74,6 +74,9 @@
             new InstallationDependency("org.codehaus.castor", "castor", 
                     VERSION_PROPERTIES.getProperty("castor.version"));
 
+    public static final InstallationDependency  COMMONS_LOGGING_API =
+            new InstallationDependency("commons-logging", "commons-logging-api",
+                    VERSION_PROPERTIES.getProperty("commons-logging.version"));
 
     private static final List ENDORSED = new ArrayList();
     private static final List SHARED = new ArrayList();
@@ -85,6 +88,7 @@
         SHARED.add(CONTAINER);
         SHARED.add(TAGLIB);
         SHARED.add(CASTOR);
+        SHARED.add(COMMONS_LOGGING_API);
     }
 
 

Modified: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java?view=diff&rev=543772&r1=543771&r2=543772
==============================================================================
--- portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java (original)
+++ portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java Sat Jun  2 12:24:51 2007
@@ -18,11 +18,78 @@
 
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.PageContext;
+import javax.servlet.ServletContext;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
 class JSP21ExpressionEvaluatorProxy extends ExpressionEvaluatorProxy {
 
-    public String evaluate(String value, PageContext pageContext) throws JspException {
-        throw new RuntimeException("JSP 2.1 Not yet supported.  Fall back to JSP 2.0");
+    public static Method jspApplicationContextGetter;
+
+    public static Method expressionFactoryGetter;
+
+    public static Method elContextGetter;
+
+    public static Method valueExpressionGetter;
+
+    public static Method evalMethod;
+
+    private static boolean initialized;
+
+    private static Object jspFactory;
+
+    static {
+        try {
+            jspFactory = Class.forName("javax.servlet.jsp.JspFactory")
+                .getMethod("getDefaultFactory", new Class[0]).invoke(null, null);
+            jspApplicationContextGetter = 
+                jspFactory.getClass().getMethod("getJspApplicationContext",
+                    new Class[] { ServletContext.class });
+            expressionFactoryGetter = 
+                Class.forName("javax.servlet.jsp.JspApplicationContext")
+                    .getMethod("getExpressionFactory", new Class[0]);
+            elContextGetter = 
+                PageContext.class.getMethod("getELContext", new Class[0]);
+            valueExpressionGetter = 
+                Class.forName("javax.el.ExpressionFactory").getMethod(
+                    "createValueExpression", new Class[] 
+                    { Class.forName("javax.el.ELContext"), String.class, Class.class });
+            evalMethod = Class.forName("javax.el.ValueExpression").getMethod(
+                    "getValue", new Class[] { Class.forName("javax.el.ELContext") });
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to find JSP2.1 methods.", e);
+        }
+    }
+
+    public String evaluate(String value, PageContext pageContext)
+            throws JspException {
+        try {
+            Object jspApplicationContext = jspApplicationContextGetter.invoke(
+                    jspFactory,
+                    new Object[] { pageContext.getServletContext() });
+
+            Object expressionFactory = expressionFactoryGetter.invoke(
+                    jspApplicationContext, null);
+
+            Object elContext = elContextGetter.invoke(pageContext, null);
+
+            Object valueExpression = valueExpressionGetter.invoke(
+                    expressionFactory, new Object[] { elContext, value,
+                            Object.class });
+
+            Object evaluated = evalMethod.invoke(valueExpression,
+                    new Object[] { elContext });
+
+            if (evaluated != null) {
+                value = evaluated.toString();
+            }
+        } catch (IllegalAccessException e) {
+            throw new JspException(e);
+        } catch (InvocationTargetException e) {
+            throw new JspException(e);
+        }
+        return value;
     }
 
 }
+

Modified: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/PortalInstallerFactory.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/PortalInstallerFactory.java?view=diff&rev=543772&r1=543771&r2=543772
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/PortalInstallerFactory.java (original)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/PortalInstallerFactory.java Sat Jun  2 12:24:51 2007
@@ -16,13 +16,14 @@
  */
 package org.apache.pluto.util.install;
 
-import org.apache.pluto.util.install.file.tomcat5.Tomcat5FileSystemInstaller;
-import org.apache.pluto.util.install.file.jetty.Jetty5FileSystemInstaller;
-
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Iterator;
 
+import org.apache.pluto.util.install.file.jetty.Jetty5FileSystemInstaller;
+import org.apache.pluto.util.install.file.tomcat5.Tomcat5FileSystemInstaller;
+import org.apache.pluto.util.install.file.tomcat6.Tomcat6FileSystemInstaller;
+
 /**
  *
  *
@@ -32,6 +33,7 @@
     private static final ArrayList HANDLERS = new ArrayList();
 
     static {
+        HANDLERS.add(new Tomcat6FileSystemInstaller());
         HANDLERS.add(new Tomcat5FileSystemInstaller());
         HANDLERS.add(new Jetty5FileSystemInstaller());
     }

Modified: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/jetty/Jetty5FileSystemInstaller.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/jetty/Jetty5FileSystemInstaller.java?view=diff&rev=543772&r1=543771&r2=543772
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/jetty/Jetty5FileSystemInstaller.java (original)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/jetty/Jetty5FileSystemInstaller.java Sat Jun  2 12:24:51 2007
@@ -34,6 +34,17 @@
 
     protected File getSharedDir(InstallationConfig config) {
         File installationDirectory = config.getInstallationDirectory();
+        // Jetty 5.1 provides commons-logging.  Should be a nicer way
+        // for installers to indicate what dependencies are provided by the
+        // servlet container.
+        if ( new File(config.getInstallationDirectory(), "ext/commons-logging.jar").exists()) {
+            for (Iterator iter = config.getSharedDependencies().iterator(); iter.hasNext();) {
+                File dep = (File) iter.next();
+                if (dep.getPath().contains("commons-logging-api")) {
+                    iter.remove();
+                }
+            }
+        }
         return new File(installationDirectory, "ext");
     }
 

Modified: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat5/Tomcat5FileSystemInstaller.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat5/Tomcat5FileSystemInstaller.java?view=diff&rev=543772&r1=543771&r2=543772
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat5/Tomcat5FileSystemInstaller.java (original)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat5/Tomcat5FileSystemInstaller.java Sat Jun  2 12:24:51 2007
@@ -16,15 +16,16 @@
  */
 package org.apache.pluto.util.install.file.tomcat5;
 
-import org.apache.pluto.util.install.InstallationConfig;
-import org.apache.pluto.util.install.file.FileSystemInstaller;
-
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
+import org.apache.pluto.util.install.InstallationConfig;
+import org.apache.pluto.util.install.file.FileSystemInstaller;
+
 public class Tomcat5FileSystemInstaller extends FileSystemInstaller {
 
 //
@@ -51,7 +52,10 @@
     throws IOException {
 
         File contextConfigurationDirectory = getConfigurationDir(config);
-
+        if (! contextConfigurationDirectory.exists()) {
+            contextConfigurationDirectory.mkdirs();
+        }
+            
         Iterator it = config.getPortletApplications().entrySet().iterator();
         while(it.hasNext()) {
             Map.Entry entry = (Map.Entry)it.next();
@@ -86,6 +90,17 @@
 
     protected File getSharedDir(InstallationConfig config) {
         File installationDirectory = config.getInstallationDirectory();
+        // Tomcat 5 provides commons-logging-api.  Should be a nicer way
+        // for installers to indicate what dependencies are provided by the
+        // servlet container.
+        if ( new File(config.getInstallationDirectory(), "bin/commons-logging-api.jar").exists()) {
+            for (Iterator iter = config.getSharedDependencies().iterator(); iter.hasNext();) {
+                File dep = (File) iter.next();
+                if (dep.getPath().contains("commons-logging-api")) {
+                    iter.remove();
+                }
+            }
+        }
         return new File(installationDirectory, "shared/lib");
     }
 

Added: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat6/Tomcat6FileSystemInstaller.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat6/Tomcat6FileSystemInstaller.java?view=auto&rev=543772
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat6/Tomcat6FileSystemInstaller.java (added)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/install/file/tomcat6/Tomcat6FileSystemInstaller.java Sat Jun  2 12:24:51 2007
@@ -0,0 +1,35 @@
+package org.apache.pluto.util.install.file.tomcat6;
+
+import java.io.File;
+
+import org.apache.pluto.util.install.InstallationConfig;
+import org.apache.pluto.util.install.file.tomcat5.Tomcat5FileSystemInstaller;
+
+public class Tomcat6FileSystemInstaller extends Tomcat5FileSystemInstaller
+{
+
+    public boolean isValidInstallationDirectory( File installDir )
+    {
+        // Tomcat 6 - by default - does away with the classloader
+        // directories <tomcat>/server, <tomcat>/common, and <tomcat>/shared.  
+        // Everything by default is installed under <tomcat>/lib.
+        File libDir = new File( installDir, "lib" );
+        File serverConf = new File( installDir, "conf/server.xml" );
+        File catalinaProps = new File( installDir, "conf/catalina.properties" );
+        
+        return libDir.exists() && serverConf.exists() && catalinaProps.exists();
+    }
+    
+    protected File getEndorsedDir( InstallationConfig config )
+    {
+        // Tomcat 6 uses <tomcat>/endorsed
+        return new File( config.getInstallationDirectory(), "endorsed" );
+    }
+
+    protected File getSharedDir( InstallationConfig config )
+    {
+        // Tomcat 6, by default, uses <tomcat>/lib
+        return new File( config.getInstallationDirectory(), "lib" );
+    }
+
+}