You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2019/10/03 11:48:11 UTC
[myfaces] branch master updated: MYFACES-4302
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 11c328a MYFACES-4302
11c328a is described below
commit 11c328a9acc663015c0e0eec2a638ad48bf59f1e
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Thu Oct 3 13:48:01 2019 +0200
MYFACES-4302
---
.../config/DefaultFacesConfigResourceProvider.java | 24 +-
.../apache/myfaces/config/FacesConfigurator.java | 9 -
.../org/apache/myfaces/config/MyfacesConfig.java | 48 +-
.../annotation/DefaultAnnotationProvider.java | 120 +----
.../org/apache/myfaces/config/util/GAEUtils.java | 577 ---------------------
.../org/apache/myfaces/util/ContainerUtils.java | 70 +--
.../DefaultFaceletConfigResourceProvider.java | 28 +-
7 files changed, 28 insertions(+), 848 deletions(-)
diff --git a/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigResourceProvider.java b/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigResourceProvider.java
index 352d071..91cc254 100644
--- a/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigResourceProvider.java
+++ b/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigResourceProvider.java
@@ -30,8 +30,6 @@ import javax.faces.context.ExternalContext;
import org.apache.myfaces.util.lang.ClassUtils;
import org.apache.myfaces.spi.FacesConfigResourceProvider;
-import org.apache.myfaces.util.ContainerUtils;
-import org.apache.myfaces.config.util.GAEUtils;
import org.apache.myfaces.view.facelets.util.Classpath;
/**
@@ -72,25 +70,9 @@ public class DefaultFacesConfigResourceProvider extends FacesConfigResourceProvi
urlSet.add(resources.nextElement());
}
- String jarFilesToScanParam = MyfacesConfig.getCurrentInstance(context).getGaeJsfJarFiles();
- jarFilesToScanParam = jarFilesToScanParam != null ? jarFilesToScanParam.trim() : null;
- if (ContainerUtils.isRunningOnGoogleAppEngine(context) &&
- jarFilesToScanParam != null &&
- jarFilesToScanParam.length() > 0)
- {
- Collection<URL> urlsGAE = GAEUtils.searchInWebLib(context, cl,
- jarFilesToScanParam, META_INF_PREFIX, FACES_CONFIG_SUFFIX);
- if (urlsGAE != null)
- {
- urlSet.addAll(urlsGAE);
- }
- }
- else
- {
- //Scan files inside META-INF ending with .faces-config.xml
- URL[] urls = Classpath.search(cl, META_INF_PREFIX, FACES_CONFIG_SUFFIX);
- Collections.addAll(urlSet, urls);
- }
+ //Scan files inside META-INF ending with .faces-config.xml
+ URL[] urls = Classpath.search(cl, META_INF_PREFIX, FACES_CONFIG_SUFFIX);
+ Collections.addAll(urlSet, urls);
return urlSet;
}
diff --git a/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java b/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
index 776a325..3c4b25a 100755
--- a/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
+++ b/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
@@ -136,7 +136,6 @@ import org.apache.myfaces.spi.InjectionProviderException;
import org.apache.myfaces.spi.InjectionProviderFactory;
import org.apache.myfaces.spi.ResourceLibraryContractsProvider;
import org.apache.myfaces.spi.ResourceLibraryContractsProviderFactory;
-import org.apache.myfaces.util.ContainerUtils;
import org.apache.myfaces.util.ExternalSpecifications;
import org.apache.myfaces.util.NavigationUtils;
import org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl;
@@ -374,14 +373,6 @@ public class FacesConfigurator
public void update()
{
- //Google App Engine does not allow to get last modified time of a file;
- //and when an application is running on GAE there is no way to update faces config xml file.
- //thus, no need to check if the config file is modified.
- if (ContainerUtils.isRunningOnGoogleAppEngine(_externalContext))
- {
- return;
- }
-
long refreshPeriod = (MyfacesConfig.getCurrentInstance(_externalContext).getConfigRefreshPeriod()) * 1000;
if (refreshPeriod > 0)
{
diff --git a/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java b/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java
index 9406e33..0e3300a 100755
--- a/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java
+++ b/impl/src/main/java/org/apache/myfaces/config/MyfacesConfig.java
@@ -249,35 +249,7 @@ public class MyfacesConfig
group="EL", tags="performance ")
public final static String SUPPORT_JSP = "org.apache.myfaces.SUPPORT_JSP";
private final static boolean SUPPORT_JSP_DEFAULT = true;
-
- /**
- * When the application runs inside Google Application Engine container (GAE),
- * indicate which jar files should be scanned for files (faces-config, facelets taglib
- * or annotations). It accept simple wildcard patterns like myfavoritejsflib-*.jar or
- * myfavoritejsflib-1.1.?.jar. By default, all the classpath is scanned for files
- * annotations (so it adds an small delay on startup).
- */
- @JSFWebConfigParam(since = "2.1.8, 2.0.14", expectedValues="none, myfavoritejsflib-*.jar",
- tags="performance, GAE")
- public static final String GAE_JSF_JAR_FILES = "org.apache.myfaces.GAE_JSF_JAR_FILES";
- private final static String GAE_JSF_JAR_FILES_DEFAULT = null;
-
- /**
- * When the application runs inside Google Application Engine container (GAE),
- * indicate which jar files should be scanned for annotations. This param overrides
- * org.apache.myfaces.GAE_JSF_JAR_FILES behavior that tries to find faces-config.xml or
- * files ending with .faces-config.xml in /META-INF folder and if that so, try to
- * find JSF annotations in the whole jar file. It accept simple wildcard patterns
- * like myfavoritejsflib-*.jar or myfavoritejsflib-1.1.?.jar.
- * By default, all the classpath is scanned for annotations (so it adds an small
- * delay on startup).
- */
- @JSFWebConfigParam(since = "2.1.8, 2.0.14", expectedValues="none, myfavoritejsflib-*.jar",
- tags="performance, GAE")
- public static final String GAE_JSF_ANNOTATIONS_JAR_FILES =
- "org.apache.myfaces.GAE_JSF_ANNOTATIONS_JAR_FILES";
- private final static String GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT = null;
-
+
/**
* If this param is set to true, a check will be done in Restore View Phase to check
* if the viewId exists or not and if it does not exists, a 404 response will be thrown.
@@ -855,8 +827,6 @@ public class MyfacesConfig
private boolean viewUniqueIdsCacheEnabled = VIEW_UNIQUE_IDS_CACHE_ENABLED_DEFAULT;
private int componentUniqueIdsCacheSize = COMPONENT_UNIQUE_IDS_CACHE_SIZE_DEFAULT;
private boolean supportJSP = SUPPORT_JSP_DEFAULT;
- private String gaeJsfJarFiles = GAE_JSF_JAR_FILES_DEFAULT;
- private String gaeJsfAnnotationsJarFiles = GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT;
private boolean strictJsf2ViewNotFound = STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT;
private boolean earlyFlushEnabled = EARLY_FLUSH_ENABLED_DEFAULT;
private boolean strictJsf2FaceletsCompatibility = STRICT_JSF_2_FACELETS_COMPATIBILITY_DEFAULT;
@@ -1055,12 +1025,6 @@ public class MyfacesConfig
cfg.supportJSP = getBoolean(extCtx, SUPPORT_JSP,
SUPPORT_JSP_DEFAULT);
-
- cfg.gaeJsfJarFiles = getString(extCtx, GAE_JSF_JAR_FILES,
- GAE_JSF_JAR_FILES_DEFAULT);
-
- cfg.gaeJsfAnnotationsJarFiles = getString(extCtx, GAE_JSF_ANNOTATIONS_JAR_FILES,
- GAE_JSF_ANNOTATIONS_JAR_FILES_DEFAULT);
cfg.strictJsf2ViewNotFound = getBoolean(extCtx, STRICT_JSF_2_VIEW_NOT_FOUND,
STRICT_JSF_2_VIEW_NOT_FOUND_DEFAULT);
@@ -1503,16 +1467,6 @@ public class MyfacesConfig
return supportJSP;
}
- public String getGaeJsfJarFiles()
- {
- return gaeJsfJarFiles;
- }
-
- public String getGaeJsfAnnotationsJarFiles()
- {
- return gaeJsfAnnotationsJarFiles;
- }
-
public boolean isStrictJsf2ViewNotFound()
{
return strictJsf2ViewNotFound;
diff --git a/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java b/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
index b4d5059..2da85bc 100644
--- a/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
+++ b/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
@@ -55,10 +55,6 @@ import org.apache.myfaces.config.MyfacesConfig;
import org.apache.myfaces.util.lang.ClassUtils;
import org.apache.myfaces.spi.AnnotationProvider;
import org.apache.myfaces.spi.AnnotationProviderFactory;
-import org.apache.myfaces.util.ContainerUtils;
-import org.apache.myfaces.config.util.GAEUtils;
-import org.apache.myfaces.config.util.JarUtils;
-import org.apache.myfaces.util.lang.StringUtils;
import org.apache.myfaces.view.facelets.util.Classpath;
/**
@@ -172,29 +168,15 @@ public class DefaultAnnotationProvider extends AnnotationProvider
}
//2. Scan for annotations on classpath
- String jarAnnotationFilesToScanParam = MyfacesConfig.getCurrentInstance(ctx).getGaeJsfAnnotationsJarFiles();
- jarAnnotationFilesToScanParam = jarAnnotationFilesToScanParam != null ?
- jarAnnotationFilesToScanParam.trim() : null;
- if (ContainerUtils.isRunningOnGoogleAppEngine(ctx) &&
- jarAnnotationFilesToScanParam != null &&
- jarAnnotationFilesToScanParam.length() > 0)
+ try
{
- // Skip call AnnotationProvider.getBaseUrls(ctx), and instead use the value of the config parameter
- // to find which classes needs to be scanned for annotations
- classes = getGAEAnnotatedMetaInfClasses(ctx, jarAnnotationFilesToScanParam);
+ AnnotationProvider provider
+ = AnnotationProviderFactory.getAnnotationProviderFactory(ctx).getAnnotationProvider(ctx);
+ classes = getAnnotatedMetaInfClasses(ctx, provider.getBaseUrls(ctx));
}
- else
+ catch (IOException e)
{
- try
- {
- AnnotationProvider provider
- = AnnotationProviderFactory.getAnnotationProviderFactory(ctx).getAnnotationProvider(ctx);
- classes = getAnnotatedMetaInfClasses(ctx, provider.getBaseUrls(ctx));
- }
- catch (IOException e)
- {
- throw new FacesException(e);
- }
+ throw new FacesException(e);
}
for (Class<?> clazz : classes)
@@ -209,49 +191,22 @@ public class DefaultAnnotationProvider extends AnnotationProvider
public Set<URL> getBaseUrls(ExternalContext context) throws IOException
{
ClassLoader cl = ClassUtils.getCurrentLoader(this);
-
- String jarFilesToScanParam = MyfacesConfig.getCurrentInstance(context).getGaeJsfJarFiles();
- jarFilesToScanParam = jarFilesToScanParam != null ? jarFilesToScanParam.trim() : null;
- if (ContainerUtils.isRunningOnGoogleAppEngine(context) &&
- jarFilesToScanParam != null &&
- jarFilesToScanParam.length() > 0)
+
+ Set<URL> urlSet = new HashSet<>();
+
+ //This usually happens when maven-jetty-plugin is used
+ //Scan jars looking for paths including META-INF/faces-config.xml
+ Enumeration<URL> resources = cl.getResources(FACES_CONFIG_IMPLICIT);
+ while (resources.hasMoreElements())
{
- Set<URL> urlSet = new HashSet<>();
-
- //This usually happens when maven-jetty-plugin is used
- //Scan jars looking for paths including META-INF/faces-config.xml
- Enumeration<URL> resources = cl.getResources(FACES_CONFIG_IMPLICIT);
- while (resources.hasMoreElements())
- {
- urlSet.add(resources.nextElement());
- }
-
- Collection<URL> urlsGAE = GAEUtils.searchInWebLib(
- context, cl, jarFilesToScanParam, META_INF_PREFIX, FACES_CONFIG_SUFFIX);
- if (urlsGAE != null)
- {
- urlSet.addAll(urlsGAE);
- }
- return urlSet;
+ urlSet.add(resources.nextElement());
}
- else
- {
- Set<URL> urlSet = new HashSet<URL>();
- //This usually happens when maven-jetty-plugin is used
- //Scan jars looking for paths including META-INF/faces-config.xml
- Enumeration<URL> resources = cl.getResources(FACES_CONFIG_IMPLICIT);
- while (resources.hasMoreElements())
- {
- urlSet.add(resources.nextElement());
- }
+ //Scan files inside META-INF ending with .faces-config.xml
+ URL[] urls = Classpath.search(cl, META_INF_PREFIX, FACES_CONFIG_SUFFIX);
+ Collections.addAll(urlSet, urls);
- //Scan files inside META-INF ending with .faces-config.xml
- URL[] urls = Classpath.search(cl, META_INF_PREFIX, FACES_CONFIG_SUFFIX);
- Collections.addAll(urlSet, urls);
-
- return urlSet;
- }
+ return urlSet;
}
protected Collection<Class<?>> getAnnotatedMetaInfClasses(ExternalContext ctx, Set<URL> urls)
@@ -278,45 +233,6 @@ public class DefaultAnnotationProvider extends AnnotationProvider
}
return Collections.emptyList();
}
-
- protected Collection<Class<?>> getGAEAnnotatedMetaInfClasses(ExternalContext context, String filter)
- {
- if (!filter.equals("none"))
- {
- String[] jarFilesToScan = StringUtils.trim(StringUtils.splitLongString(filter, ','));
- Set<String> paths = context.getResourcePaths(WEB_LIB_PREFIX);
- if (paths != null)
- {
- List<Class<?>> list = new ArrayList<Class<?>>();
- for (Object pathObject : paths)
- {
- String path = (String) pathObject;
- if (path.endsWith(".jar") && GAEUtils.wildcardMatch(path, jarFilesToScan, GAEUtils.WEB_LIB_PREFIX))
- {
- // GAE does not use WAR format, so the app is just uncompressed in a directory
- // What we need here is just take the path of the file, and open the file as a
- // jar file. Then, if the jar should be scanned, try to find the required file.
- try
- {
- URL jarUrl = new URL("jar:" + context.getResource(path).toExternalForm() + "!/");
- JarFile jarFile = JarUtils.getJarFile(jarUrl);
- if (jarFile != null)
- {
- archiveClasses(jarFile, list);
- }
- }
- catch(IOException e)
- {
- log.log(Level.SEVERE,
- "IOException when reading jar file for annotations using filter: "+filter, e);
- }
- }
- }
- return list;
- }
- }
- return Collections.emptyList();
- }
protected Collection<Class<?>> getAnnotatedMyfacesImplClasses(ExternalContext ctx, URL url)
{
diff --git a/impl/src/main/java/org/apache/myfaces/config/util/GAEUtils.java b/impl/src/main/java/org/apache/myfaces/config/util/GAEUtils.java
deleted file mode 100644
index de87a13..0000000
--- a/impl/src/main/java/org/apache/myfaces/config/util/GAEUtils.java
+++ /dev/null
@@ -1,577 +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.config.util;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Set;
-import java.util.Stack;
-import java.util.TreeSet;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import javax.faces.context.ExternalContext;
-import org.apache.myfaces.util.lang.Assert;
-import org.apache.myfaces.util.lang.StringUtils;
-
-/**
- * Utility methods to use in Google Application Engine (GAE)
- *
- * @author Leonardo Uribe
- */
-public class GAEUtils
-{
-
- public static final String WEB_LIB_PREFIX = "/WEB-INF/lib/";
-
-
- /**
- * Look in all jars located inside /WEB-INF/lib/ folder for files that has
- * some specified prefix and suffix. It is a simplification that can be done
- * in GAE, because no JSF libraries are outside /WEB-INF/lib
- *
- * @param context
- * @param classloader
- * @param prefix
- * @param suffix
- * @return
- * @throws IOException
- */
- public static Collection<URL> searchInWebLib(
- ExternalContext context, ClassLoader classloader, String filter,
- String prefix, String suffix) throws IOException
- {
- if (!filter.equals("none"))
- {
- String[] jarFilesToScan = StringUtils.trim(StringUtils.splitLongString(filter, ','));
- Set<URL> urlSet = null;
- Set<String> paths = context.getResourcePaths(WEB_LIB_PREFIX);
- if (paths != null)
- {
- for (Object pathObject : paths)
- {
- String path = (String) pathObject;
- if (path.endsWith(".jar") && wildcardMatch(path, jarFilesToScan, WEB_LIB_PREFIX))
- {
- // GAE does not use WAR format, so the app is just uncompressed in a directory
- // What we need here is just take the path of the file, and open the file as a
- // jar file. Then, if the jar should be scanned, try to find the required file.
- URL jarUrl = new URL("jar:" + context.getResource(path).toExternalForm() + "!/");
- JarFile jarFile = JarUtils.getJarFile(jarUrl);
-
- Enumeration<JarEntry> entries = jarFile.entries();
- while (entries.hasMoreElements())
- {
- JarEntry entry = entries.nextElement();
- if (entry.isDirectory())
- {
- continue; // This is a directory
- }
- String name = entry.getName();
- if (!name.startsWith(prefix))
- {
- continue; // Attribute files
- }
- if (name.endsWith(suffix))
- {
- // Get it from classloader, because no URL can be
- // derived from JarEntry
- Enumeration<URL> alternateFacesConfigs = classloader.getResources(name);
- while (alternateFacesConfigs.hasMoreElements())
- {
- if (urlSet == null)
- {
- urlSet = new TreeSet<URL>();
- }
- urlSet.add(alternateFacesConfigs.nextElement());
- }
- }
- }
- }
- }
- }
- return urlSet;
- }
- return null;
- }
-
- public static boolean wildcardMatch(String filename, String[] wildcardMatchers, String prefix)
- {
- for (String matcher : wildcardMatchers)
- {
- if (wildcardMatch(filename, prefix + matcher))
- {
- return true;
- }
- }
- return false;
- }
-
- // NOTE: CODE TAKEN FROM COMMONS-IO AND REFACTORED TO USE INSIDE GAE
- //-----------------------------------------------------------------------
- /**
- * Checks a filename to see if it matches the specified wildcard matcher,
- * always testing case-sensitive. <p> The wildcard matcher uses the
- * characters '?' and '*' to represent a single or multiple (zero or more)
- * wildcard characters. This is the same as often found on Dos/Unix command
- * lines. The check is case-sensitive always.
- * <pre>
- * wildcardMatch("c.txt", "*.txt") --> true
- * wildcardMatch("c.txt", "*.jpg") --> false
- * wildcardMatch("a/b/c.txt", "a/b/*") --> true
- * wildcardMatch("c.txt", "*.???") --> true
- * wildcardMatch("c.txt", "*.????") --> false
- * </pre> N.B. the sequence "*?" does not work properly at present in match
- * strings.
- *
- * @param filename the filename to match on
- * @param wildcardMatcher the wildcard string to match against
- * @return true if the filename matches the wilcard string
- * @see IOCase#SENSITIVE
- */
- static boolean wildcardMatch(String filename, String wildcardMatcher)
- {
- return wildcardMatch(filename, wildcardMatcher, IOCase.SENSITIVE);
- }
-
- /**
- * Checks a filename to see if it matches the specified wildcard matcher
- * using the case rules of the system. <p> The wildcard matcher uses the
- * characters '?' and '*' to represent a single or multiple (zero or more)
- * wildcard characters. This is the same as often found on Dos/Unix command
- * lines. The check is case-sensitive on Unix and case-insensitive on
- * Windows.
- * <pre>
- * wildcardMatch("c.txt", "*.txt") --> true
- * wildcardMatch("c.txt", "*.jpg") --> false
- * wildcardMatch("a/b/c.txt", "a/b/*") --> true
- * wildcardMatch("c.txt", "*.???") --> true
- * wildcardMatch("c.txt", "*.????") --> false
- * </pre> N.B. the sequence "*?" does not work properly at present in match
- * strings.
- *
- * @param filename the filename to match on
- * @param wildcardMatcher the wildcard string to match against
- * @return true if the filename matches the wilcard string
- * @see IOCase#SYSTEM
- */
- static boolean wildcardMatchOnSystem(String filename, String wildcardMatcher)
- {
- //return wildcardMatch(filename, wildcardMatcher, IOCase.SYSTEM);
- return wildcardMatch(filename, wildcardMatcher, IOCase.SENSITIVE);
- }
-
- /**
- * Checks a filename to see if it matches the specified wildcard matcher
- * allowing control over case-sensitivity. <p> The wildcard matcher uses the
- * characters '?' and '*' to represent a single or multiple (zero or more)
- * wildcard characters. N.B. the sequence "*?" does not work properly at
- * present in match strings.
- *
- * @param filename the filename to match on
- * @param wildcardMatcher the wildcard string to match against
- * @param caseSensitivity what case sensitivity rule to use, null means
- * case-sensitive
- * @return true if the filename matches the wilcard string
- * @since 1.3
- */
- static boolean wildcardMatch(String filename, String wildcardMatcher, IOCase caseSensitivity)
- {
- if (filename == null && wildcardMatcher == null)
- {
- return true;
- }
- if (filename == null || wildcardMatcher == null)
- {
- return false;
- }
- if (caseSensitivity == null)
- {
- caseSensitivity = IOCase.SENSITIVE;
- }
- String[] wcs = splitOnTokens(wildcardMatcher);
- boolean anyChars = false;
- int textIdx = 0;
- int wcsIdx = 0;
- Stack<int[]> backtrack = new Stack<int[]>();
-
- // loop around a backtrack stack, to handle complex * matching
- do
- {
- if (backtrack.size() > 0)
- {
- int[] array = backtrack.pop();
- wcsIdx = array[0];
- textIdx = array[1];
- anyChars = true;
- }
-
- // loop whilst tokens and text left to process
- while (wcsIdx < wcs.length)
- {
-
- if (wcs[wcsIdx].equals("?"))
- {
- // ? so move to next text char
- textIdx++;
- if (textIdx > filename.length())
- {
- break;
- }
- anyChars = false;
-
- }
- else if (wcs[wcsIdx].equals("*"))
- {
- // set any chars status
- anyChars = true;
- if (wcsIdx == wcs.length - 1)
- {
- textIdx = filename.length();
- }
-
- }
- else
- {
- // matching text token
- if (anyChars)
- {
- // any chars then try to locate text token
- textIdx = caseSensitivity.checkIndexOf(filename, textIdx, wcs[wcsIdx]);
- if (textIdx == -1)
- {
- // token not found
- break;
- }
- int repeat = caseSensitivity.checkIndexOf(filename, textIdx + 1, wcs[wcsIdx]);
- if (repeat >= 0)
- {
- backtrack.push(new int[]
- {
- wcsIdx, repeat
- });
- }
- }
- else
- {
- // matching from current position
- if (!caseSensitivity.checkRegionMatches(filename, textIdx, wcs[wcsIdx]))
- {
- // couldnt match token
- break;
- }
- }
-
- // matched text token, move text index to end of matched token
- textIdx += wcs[wcsIdx].length();
- anyChars = false;
- }
-
- wcsIdx++;
- }
-
- // full match
- if (wcsIdx == wcs.length && textIdx == filename.length())
- {
- return true;
- }
-
- } while (backtrack.size() > 0);
-
- return false;
- }
-
- /**
- * Splits a string into a number of tokens. The text is split by '?' and
- * '*'. Where multiple '*' occur consecutively they are collapsed into a
- * single '*'.
- *
- * @param text the text to split
- * @return the array of tokens, never null
- */
- static String[] splitOnTokens(String text)
- {
- // used by wildcardMatch
- // package level so a unit test may run on this
-
- if (text.indexOf('?') == -1 && text.indexOf('*') == -1)
- {
- return new String[]
- {
- text
- };
- }
-
- char[] array = text.toCharArray();
- ArrayList<String> list = new ArrayList<String>();
- StringBuilder buffer = new StringBuilder();
- for (int i = 0; i < array.length; i++)
- {
- if (array[i] == '?' || array[i] == '*')
- {
- if (buffer.length() != 0)
- {
- list.add(buffer.toString());
- buffer.setLength(0);
- }
- if (array[i] == '?')
- {
- list.add("?");
- }
- else if (list.isEmpty()
- || i > 0 && list.get(list.size() - 1).equals("*") == false)
- {
- list.add("*");
- }
- }
- else
- {
- buffer.append(array[i]);
- }
- }
- if (buffer.length() != 0)
- {
- list.add(buffer.toString());
- }
-
- return list.toArray(new String[list.size()]);
- }
-
- final static class IOCase implements Serializable
- {
-
- /**
- * The constant for case sensitive regardless of operating system.
- */
- public static final IOCase SENSITIVE = new IOCase("Sensitive", true);
- /**
- * The constant for case insensitive regardless of operating system.
- */
- public static final IOCase INSENSITIVE = new IOCase("Insensitive", false);
-
- /**
- * Serialization version.
- */
- private static final long serialVersionUID = -6343169151696340687L;
- /**
- * The enumeration name.
- */
- private final String name;
- /**
- * The sensitivity flag.
- */
- private final transient boolean sensitive;
-
- //-----------------------------------------------------------------------
- /**
- * Factory method to create an IOCase from a name.
- *
- * @param name the name to find
- * @return the IOCase object
- * @throws IllegalArgumentException if the name is invalid
- */
- public static IOCase forName(String name)
- {
- if (IOCase.SENSITIVE.name.equals(name))
- {
- return IOCase.SENSITIVE;
- }
- if (IOCase.INSENSITIVE.name.equals(name))
- {
- return IOCase.INSENSITIVE;
- }
-
- throw new IllegalArgumentException("Invalid IOCase name: " + name);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Private constructor.
- *
- * @param name the name
- * @param sensitive the sensitivity
- */
- private IOCase(String name, boolean sensitive)
- {
- this.name = name;
- this.sensitive = sensitive;
- }
-
- /**
- * Replaces the enumeration from the stream with a real one. This
- * ensures that the correct flag is set for SYSTEM.
- *
- * @return the resolved object
- */
- private Object readResolve()
- {
- return forName(name);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Gets the name of the constant.
- *
- * @return the name of the constant
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Does the object represent case sensitive comparison.
- *
- * @return true if case sensitive
- */
- public boolean isCaseSensitive()
- {
- return sensitive;
- }
-
- //-----------------------------------------------------------------------
- /**
- * Compares two strings using the case-sensitivity rule. <p> This method
- * mimics {@link String#compareTo} but takes case-sensitivity into
- * account.
- *
- * @param str1 the first string to compare, not null
- * @param str2 the second string to compare, not null
- * @return true if equal using the case rules
- * @throws NullPointerException if either string is null
- */
- public int checkCompareTo(String str1, String str2)
- {
- Assert.notNull(str1, "str1");
- Assert.notNull(str2, "str2");
-
- return sensitive ? str1.compareTo(str2) : str1.compareToIgnoreCase(str2);
- }
-
- /**
- * Compares two strings using the case-sensitivity rule. <p> This method
- * mimics {@link String#equals} but takes case-sensitivity into account.
- *
- * @param str1 the first string to compare, not null
- * @param str2 the second string to compare, not null
- * @return true if equal using the case rules
- * @throws NullPointerException if either string is null
- */
- public boolean checkEquals(String str1, String str2)
- {
- if (str1 == null || str2 == null)
- {
- throw new NullPointerException("The strings must not be null");
- }
- return sensitive ? str1.equals(str2) : str1.equalsIgnoreCase(str2);
- }
-
- /**
- * Checks if one string starts with another using the case-sensitivity
- * rule. <p> This method mimics {@link String#startsWith(String)} but
- * takes case-sensitivity into account.
- *
- * @param str the string to check, not null
- * @param start the start to compare against, not null
- * @return true if equal using the case rules
- * @throws NullPointerException if either string is null
- */
- public boolean checkStartsWith(String str, String start)
- {
- return str.regionMatches(!sensitive, 0, start, 0, start.length());
- }
-
- /**
- * Checks if one string ends with another using the case-sensitivity
- * rule. <p> This method mimics {@link String#endsWith} but takes
- * case-sensitivity into account.
- *
- * @param str the string to check, not null
- * @param end the end to compare against, not null
- * @return true if equal using the case rules
- * @throws NullPointerException if either string is null
- */
- public boolean checkEndsWith(String str, String end)
- {
- int endLen = end.length();
- return str.regionMatches(!sensitive, str.length() - endLen, end, 0, endLen);
- }
-
- /**
- * Checks if one string contains another starting at a specific index
- * using the case-sensitivity rule. <p> This method mimics parts of {@link String#indexOf(String, int)}
- * but takes case-sensitivity into account.
- *
- * @param str the string to check, not null
- * @param strStartIndex the index to start at in str
- * @param search the start to search for, not null
- * @return the first index of the search String, -1 if no match or {@code null}
- * string input
- * @throws NullPointerException if either string is null
- * @since 2.0
- */
- public int checkIndexOf(String str, int strStartIndex, String search)
- {
- int endIndex = str.length() - search.length();
- if (endIndex >= strStartIndex)
- {
- for (int i = strStartIndex; i <= endIndex; i++)
- {
- if (checkRegionMatches(str, i, search))
- {
- return i;
- }
- }
- }
- return -1;
- }
-
- /**
- * Checks if one string contains another at a specific index using the
- * case-sensitivity rule. <p> This method mimics parts of {@link
- * String#regionMatches(boolean, int, String, int, int)}
- * but takes case-sensitivity into account.
- *
- * @param str the string to check, not null
- * @param strStartIndex the index to start at in str
- * @param search the start to search for, not null
- * @return true if equal using the case rules
- * @throws NullPointerException if either string is null
- */
- public boolean checkRegionMatches(String str, int strStartIndex, String search)
- {
- return str.regionMatches(!sensitive, strStartIndex, search, 0, search.length());
- }
-
- //-----------------------------------------------------------------------
- /**
- * Gets a string describing the sensitivity.
- *
- * @return a string describing the sensitivity
- */
- @Override
- public String toString()
- {
- return name;
- }
- }
-}
diff --git a/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java b/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java
index 6dda120..8a4466b 100644
--- a/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java
@@ -19,10 +19,8 @@
package org.apache.myfaces.util;
import org.apache.myfaces.util.lang.ClassUtils;
-import javax.faces.context.ExternalContext;
import javax.servlet.ServletContext;
-
/**
* Utilities for determining the current container and for the unified
* expression language.
@@ -31,11 +29,6 @@ import javax.servlet.ServletContext;
public class ContainerUtils
{
/**
- * Used for determining whether Myfaces is running on Google App Engine.
- */
- private static final String GAE_SERVER_INFO_BEGINNING = "Google App Engine";
-
- /**
* 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,
@@ -43,12 +36,6 @@ public class ContainerUtils
*/
public static boolean isJsp21(ServletContext context)
{
- //if running on GAE, treat like it is JSP 2.0
- if(isRunningOnGoogleAppEngine(context))
- {
- return false;
- }
-
try
{
// simply check if the class JspApplicationContext is available
@@ -62,60 +49,5 @@ public class ContainerUtils
return false;
}
-
- private static Boolean runningOnGoogleAppEngine = null;
-
- /**Returns true if running on Google App Engine (both production and development environment).
- * <p>If this method returns true, then
- * <ul>
- * <li>MyFaces is initialized as in JSP 2.0 or less environment.</li>
- * <li>Last modification check of faces config is not done during update.</li>
- * </ul>
- */
- public static boolean isRunningOnGoogleAppEngine(
- ServletContext servletContext)
- {
- if (runningOnGoogleAppEngine != null)
- {
- return runningOnGoogleAppEngine;
- }
- else
- {
- return isServerGoogleAppEngine(servletContext.getServerInfo());
- }
- }
-
- /**
- * @see ContainerUtils#isRunningOnGoogleAppEngine(ServletContext)
- */
- public static boolean isRunningOnGoogleAppEngine(
- ExternalContext externalContext)
- {
-
- if (runningOnGoogleAppEngine != null)
- {
- return runningOnGoogleAppEngine;
- }
- else
- {
- String serverInfo = ExternalContextUtils.getServerInfo(externalContext);
-
- return isServerGoogleAppEngine(serverInfo);
- }
- }
-
- private static boolean isServerGoogleAppEngine(String serverInfo)
- {
- //for GAE, server info can be "Google App Engine/x.x.x" or "Google App Engine Development/x.x.x"
- if (serverInfo != null && serverInfo.startsWith(GAE_SERVER_INFO_BEGINNING))
- {
- runningOnGoogleAppEngine = Boolean.TRUE;
- }
- else
- {
- runningOnGoogleAppEngine = Boolean.FALSE;
- }
-
- return runningOnGoogleAppEngine;
- }
+
}
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/DefaultFaceletConfigResourceProvider.java b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/DefaultFaceletConfigResourceProvider.java
index 5d42a5a..448361f 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/DefaultFaceletConfigResourceProvider.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/DefaultFaceletConfigResourceProvider.java
@@ -26,12 +26,9 @@ import java.util.Collections;
import java.util.List;
import javax.faces.context.ExternalContext;
-import org.apache.myfaces.config.MyfacesConfig;
import org.apache.myfaces.util.lang.ClassUtils;
import org.apache.myfaces.spi.FaceletConfigResourceProvider;
-import org.apache.myfaces.util.ContainerUtils;
-import org.apache.myfaces.config.util.GAEUtils;
import org.apache.myfaces.view.facelets.util.Classpath;
/**
@@ -55,26 +52,11 @@ public class DefaultFaceletConfigResourceProvider extends FaceletConfigResourceP
ExternalContext context) throws IOException
{
List<URL> urlSet = new ArrayList<>();
-
- String jarFilesToScanParam = MyfacesConfig.getCurrentInstance(context).getGaeJsfJarFiles();
- jarFilesToScanParam = jarFilesToScanParam != null ? jarFilesToScanParam.trim() : null;
- if (ContainerUtils.isRunningOnGoogleAppEngine(context) &&
- jarFilesToScanParam != null &&
- jarFilesToScanParam.length() > 0)
- {
- Collection<URL> urlsGAE = GAEUtils.searchInWebLib(context, ClassUtils.getCurrentLoader(this),
- jarFilesToScanParam, META_INF_PREFIX, FACELET_TAGLIB_SUFFIX);
- if (urlsGAE != null)
- {
- urlSet.addAll(urlsGAE);
- }
- }
- else
- {
- //Scan files inside META-INF ending with .faces-config.xml
- URL[] urls = Classpath.search(ClassUtils.getCurrentLoader(this), META_INF_PREFIX, FACELET_TAGLIB_SUFFIX);
- Collections.addAll(urlSet, urls);
- }
+
+ //Scan files inside META-INF ending with .faces-config.xml
+ URL[] urls = Classpath.search(ClassUtils.getCurrentLoader(this), META_INF_PREFIX, FACELET_TAGLIB_SUFFIX);
+ Collections.addAll(urlSet, urls);
+
return urlSet;
}