myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: removed JSP2.0 support
Date Fri, 04 Oct 2019 09:00:10 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new c8bf1ce  removed JSP2.0 support
c8bf1ce is described below

commit c8bf1ced6fcbd0bf5268004c73db8928520767ec
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Fri Oct 4 11:00:02 2019 +0200

    removed JSP2.0 support
---
 .../org/apache/myfaces/util/ContainerUtils.java    |  53 -------
 .../myfaces/webapp/FacesInitializerFactory.java    |  19 +--
 .../myfaces/webapp/Jsp20FacesInitializer.java      | 169 ---------------------
 ...esInitializer.java => JspFacesInitializer.java} |   4 +-
 ...lizerTest.java => JspFacesInitializerTest.java} |   6 +-
 5 files changed, 13 insertions(+), 238 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java b/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java
deleted file mode 100644
index 8a4466b..0000000
--- a/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.myfaces.util;
-
-import org.apache.myfaces.util.lang.ClassUtils;
-import javax.servlet.ServletContext;
-
-/**
- * Utilities for determining the current container and for the unified
- * expression language.
- * 
- */
-public class ContainerUtils
-{
-    /**
-     * Determines whether we're running in a Servlet 2.5/JSP 2.1 environment.
-     * 
-     * @return <code>true</code> if we're running in a JSP 2.1 environment,
-     *         <code>false</code> otherwise
-     */
-    public static boolean isJsp21(ServletContext context)
-    {
-        try 
-        {
-            // simply check if the class JspApplicationContext is available
-            ClassUtils.classForName("javax.servlet.jsp.JspApplicationContext");
-            return true;
-        } 
-        catch (ClassNotFoundException ex) 
-        {
-            // expected exception in a JSP 2.0 (or less) environment
-        }
-        
-        return false;
-    }
-  
-}
diff --git a/impl/src/main/java/org/apache/myfaces/webapp/FacesInitializerFactory.java b/impl/src/main/java/org/apache/myfaces/webapp/FacesInitializerFactory.java
index ae86a6f..367cbae 100644
--- a/impl/src/main/java/org/apache/myfaces/webapp/FacesInitializerFactory.java
+++ b/impl/src/main/java/org/apache/myfaces/webapp/FacesInitializerFactory.java
@@ -23,7 +23,7 @@ import javax.servlet.ServletContext;
 
 import org.apache.myfaces.config.MyfacesConfig;
 import org.apache.myfaces.util.lang.ClassUtils;
-import org.apache.myfaces.util.ContainerUtils;
+import org.apache.myfaces.util.lang.StringUtils;
 
 /**
  * Simple Factory to get a FacesInitializer implementation either from a web.xml
@@ -89,18 +89,15 @@ public class FacesInitializerFactory
     {
         // No MyfacesConfig available yet, we must read the parameter directly:
         String initParameter = context.getInitParameter(MyfacesConfig.SUPPORT_JSP);
-        if (Boolean.FALSE.toString().equals(initParameter))
+        if (StringUtils.isBlank(initParameter) || Boolean.TRUE.toString().equals(initParameter))
         {
-            return new FaceletsInitilializer();
-        } 
-        else if (ContainerUtils.isJsp21(context)) 
-        {
-            return new Jsp21FacesInitializer();
-        } 
-        else 
-        {
-            return new Jsp20FacesInitializer();
+            if (ClassUtils.simpleClassForName("javax.servlet.jsp.JspApplicationContext",
false) != null)
+            {
+                return new JspFacesInitializer();
+            }
         }
+
+        return new FaceletsInitilializer();
     }
     
 }
diff --git a/impl/src/main/java/org/apache/myfaces/webapp/Jsp20FacesInitializer.java b/impl/src/main/java/org/apache/myfaces/webapp/Jsp20FacesInitializer.java
deleted file mode 100644
index 89d1e1b..0000000
--- a/impl/src/main/java/org/apache/myfaces/webapp/Jsp20FacesInitializer.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * 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.myfaces.webapp;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.el.ELContext;
-import javax.el.ExpressionFactory;
-import javax.el.MethodExpression;
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-import javax.faces.context.ExternalContext;
-import javax.servlet.ServletContext;
-
-/**
- * Initializes MyFaces in a JSP 2.0 (or less) environment.
- * 
- */
-public class Jsp20FacesInitializer extends AbstractFacesInitializer
-{
-    private static final Logger log = Logger.getLogger(Jsp20FacesInitializer.class.getName());
-
-    /**
-     * The ExpressionFactory implementation of the EL-RI.
-     */
-    private static final String EL_RI_EXPRESSION_FACTORY_IMPL = "com.sun.el.ExpressionFactoryImpl";
-
-    /**
-     * Jasper's ExpressionFactory implementation.
-     */
-    private static final String JASPER_EL_EXPRESSION_FACTORY_IMPL = "org.apache.el.ExpressionFactoryImpl";
-
-    /**
-     * All known ExpressionFactory implementations.
-     */
-    private static final String[] KNOWN_EXPRESSION_FACTORIES =
-            new String[] { EL_RI_EXPRESSION_FACTORY_IMPL, JASPER_EL_EXPRESSION_FACTORY_IMPL
};
-
-    @Override
-    protected void initContainerIntegration(ServletContext servletContext, ExternalContext
externalContext)
-    {
-        if (log.isLoggable(Level.INFO))
-        {
-            log.info("This application isn't running in a JSP 2.1 container.");
-        }
-
-        // It's possible to run MyFaces in a JSP 2.0 Container, but the user has to provide
-        // the ExpressionFactory implementation to use as there is no JspApplicationContext
-        // we could ask for. Having said that, though, the user only has to provide it, if
-        // there is no known ExpressionFactory available (i.e. if neither
-        // "com.sun.el.ExpressionFactoryImpl" nor "org.apache.el.ExpressionFactoryImpl"
-        // are available).
-        ExpressionFactory expressionFactory = getUserDefinedExpressionFactory(externalContext);
-
-        if (expressionFactory == null)
-        {
-            if (log.isLoggable(Level.INFO))
-            {
-                log.info("Either you haven't specified the ExpressionFactory implementation,
or an " 
-                        + "error occured while instantiating the implementation you've specified.
"
-                        + "However, attempting to load a known implementation.");
-            }
-
-            expressionFactory = findExpressionFactory(KNOWN_EXPRESSION_FACTORIES);
-            if (expressionFactory == null)
-            { // if we still haven't got a valid implementation
-                if (log.isLoggable(Level.SEVERE))
-                {
-                    log.severe("No valid ExpressionFactory implementation is available "
-                            + "but that's required as this application isn't running in a
JSP 2.1 container.");
-                }
-
-                // use a dummy implementation that reports the error again
-                expressionFactory = new ErrorExpressionFactory();
-            }
-        }
-
-        if (log.isLoggable(Level.FINE))
-        {
-            log.fine("The following ExpressionFactory implementation will " + "be used: '"
+ expressionFactory + "'.");
-        }
-
-        buildConfiguration(servletContext, externalContext, expressionFactory);
-    }
-
-    /**
-     * Attempts to find a valid ExpressionFactory implementation. Each of the given
-     * "ExpressionFactory implementation candidates" will be tried to instantiate. If an
attempt succeeded, the
-     * ExpressionFactory implementation will be returned (i.e. the first valid ExpressionFactory
implementation will be
-     * returned) and if no attempt succeeds, <code>null</code> will be returned.
-     * 
-     * @param expressionFactoryClassNames
-     *            "ExpresionFactory implementation candidates"
-     * 
-     * @return the newly created ExpressionFactory implementation, or <code>null</code>,
if there is no valid
-     *         implementation
-     */
-    private static ExpressionFactory findExpressionFactory(String[] expressionFactoryClassNames)
-    {
-        for (String expressionFactoryClassName : expressionFactoryClassNames)
-        {
-            ExpressionFactory expressionFactory = loadExpressionFactory(expressionFactoryClassName);
-            if (expressionFactory != null)
-            {
-                return expressionFactory;
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Dummy implementation informing the user that there is no valid ExpressionFactory implementation
available. This
-     * class makes it easier for the user to understand why the application crashes. Otherwise
he would have to deal
-     * with NullPointerExceptions.
-     * 
-     */
-    private class ErrorExpressionFactory extends ExpressionFactory
-    {
-
-        @Override
-        public Object coerceToType(Object obj, Class<?> targetType)
-        {
-            throw new FacesException("No valid ExpressionFactory implementation is available
"
-                    + "but that's required as this application isn't running in a JSP 2.1
container.");
-        }
-
-        @Override
-        public MethodExpression createMethodExpression(ELContext context, String expression,
-                                                       Class<?> expectedReturnType,
Class<?>[] expectedParamTypes)
-        {
-            throw new FacesException("No valid ExpressionFactory implementation is available
"
-                    + "but that's required as this application isn't running in a JSP 2.1
container.");
-        }
-
-        @Override
-        public ValueExpression createValueExpression(Object instance, Class<?> expectedType)
-        {
-            throw new FacesException("No valid ExpressionFactory implementation is available
"
-                    + "but that's required as this application isn't running in a JSP 2.1
container.");
-        }
-
-        @Override
-        public ValueExpression createValueExpression(ELContext context, String expression,
Class<?> expectedType)
-        {
-            throw new FacesException("No valid ExpressionFactory implementation is available
"
-                    + "but that's required as this application isn't running in a JSP 2.1
container.");
-        }
-
-    }
-
-}
diff --git a/impl/src/main/java/org/apache/myfaces/webapp/Jsp21FacesInitializer.java b/impl/src/main/java/org/apache/myfaces/webapp/JspFacesInitializer.java
similarity index 97%
rename from impl/src/main/java/org/apache/myfaces/webapp/Jsp21FacesInitializer.java
rename to impl/src/main/java/org/apache/myfaces/webapp/JspFacesInitializer.java
index bed1e73..116c74f 100644
--- a/impl/src/main/java/org/apache/myfaces/webapp/Jsp21FacesInitializer.java
+++ b/impl/src/main/java/org/apache/myfaces/webapp/JspFacesInitializer.java
@@ -44,9 +44,9 @@ import org.apache.myfaces.util.lang.ClassUtils;
  * Initializes MyFaces in a JSP 2.1 environment.
  *
  */
-public class Jsp21FacesInitializer extends AbstractFacesInitializer
+public class JspFacesInitializer extends AbstractFacesInitializer
 {
-    private static final Logger log = Logger.getLogger(Jsp21FacesInitializer.class.getName());
+    private static final Logger log = Logger.getLogger(JspFacesInitializer.class.getName());
     
     /**
      * Cached instance of the JspFactory to use.
diff --git a/impl/src/test/java/org/apache/myfaces/webapp/Jsp21FacesInitializerTest.java b/impl/src/test/java/org/apache/myfaces/webapp/JspFacesInitializerTest.java
similarity index 95%
rename from impl/src/test/java/org/apache/myfaces/webapp/Jsp21FacesInitializerTest.java
rename to impl/src/test/java/org/apache/myfaces/webapp/JspFacesInitializerTest.java
index 0c1de42..5d79c6d 100644
--- a/impl/src/test/java/org/apache/myfaces/webapp/Jsp21FacesInitializerTest.java
+++ b/impl/src/test/java/org/apache/myfaces/webapp/JspFacesInitializerTest.java
@@ -41,10 +41,10 @@ import org.easymock.classextension.IMocksControl;
  * @author Mathias Broekelmann (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class Jsp21FacesInitializerTest extends AbstractJsfTestCase
+public class JspFacesInitializerTest extends AbstractJsfTestCase
 {
 
-    public Jsp21FacesInitializerTest(String name)
+    public JspFacesInitializerTest(String name)
     {
         super(name);
     }
@@ -57,7 +57,7 @@ public class Jsp21FacesInitializerTest extends AbstractJsfTestCase
     {
         // TODO adapt this test case for MyFaces 2.0, because currently it checks nothing!
         
-        Jsp21FacesInitializer initializer = new Jsp21FacesInitializer();
+        JspFacesInitializer initializer = new JspFacesInitializer();
         IMocksControl control = EasyMock.createControl();
         
         JspFactory jspFactory = control.createMock(JspFactory.class);


Mime
View raw message