-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jakarta Namespace - Faces 3.0.0 Complete with ShowCase
- Loading branch information
Showing
25 changed files
with
1,203 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...e8/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceConfigurator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.guicedee.faces.implementations.JakartaFacesConfiguration |
1 change: 1 addition & 0 deletions
1
...rces/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceScanModuleInclusions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.guicedee.faces.implementations.JakartaFacesModuleInclusion |
12 changes: 12 additions & 0 deletions
12
...rta-faces/src/main/java/com/guicedee/faces/implementations/JakartaFacesConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.guicedee.faces.implementations; | ||
|
||
import com.guicedee.guicedinjection.GuiceConfig; | ||
import com.guicedee.guicedinjection.interfaces.IGuiceConfigurator; | ||
|
||
public class JakartaFacesConfiguration implements IGuiceConfigurator { | ||
|
||
@Override | ||
public GuiceConfig configure(GuiceConfig config) { | ||
return config.setPathScanning(true); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...a-faces/src/main/java/com/guicedee/faces/implementations/JakartaFacesModuleInclusion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.guicedee.faces.implementations; | ||
|
||
import com.guicedee.guicedinjection.GuiceConfig; | ||
import com.guicedee.guicedinjection.interfaces.IGuiceConfigurator; | ||
import com.guicedee.guicedinjection.interfaces.IGuiceScanJarInclusions; | ||
import com.guicedee.guicedinjection.interfaces.IGuiceScanModuleInclusions; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class JakartaFacesModuleInclusion implements IGuiceScanModuleInclusions<JakartaFacesModuleInclusion>, IGuiceScanJarInclusions<JakartaFacesModuleInclusion> { | ||
|
||
@Override | ||
public @NotNull Set<String> includeModules() { | ||
Set<String> moduleScanningAllowed = new HashSet<>(); | ||
moduleScanningAllowed.add("jakarta.faces"); | ||
return moduleScanningAllowed; | ||
} | ||
|
||
@Override | ||
public @NotNull Set<String> includeJars() { | ||
Set<String> moduleScanningAllowed = new HashSet<>(); | ||
moduleScanningAllowed.add("javax.faces-*"); | ||
return moduleScanningAllowed; | ||
} | ||
} |
113 changes: 113 additions & 0 deletions
113
...aces/src/main/java/com/sun/faces/config/configprovider/BaseWebConfigResourceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package com.sun.faces.config.configprovider; | ||
|
||
import static com.guicedee.guicedinjection.json.StaticStrings.STRING_FORWARD_SLASH; | ||
import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.JakartaFacesConfigFiles; | ||
import static com.sun.faces.util.Util.split; | ||
import static java.util.Arrays.binarySearch; | ||
import static java.util.logging.Level.WARNING; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.util.*; | ||
import java.util.logging.Logger; | ||
|
||
import com.sun.faces.config.WebConfiguration; | ||
import com.sun.faces.config.WebConfiguration.WebContextInitParameter; | ||
import com.sun.faces.spi.ConfigurationResourceProvider; | ||
import com.sun.faces.util.FacesLogger; | ||
|
||
import jakarta.faces.FacesException; | ||
import jakarta.servlet.ServletContext; | ||
import com.guicedee.guicedinjection.GuiceContext; | ||
import static com.sun.faces.facelets.util.Classpath.cleanURI; | ||
|
||
/** | ||
* | ||
*/ | ||
public abstract class BaseWebConfigResourceProvider implements ConfigurationResourceProvider { | ||
|
||
private static final Logger LOGGER = FacesLogger.CONFIG.getLogger(); | ||
|
||
// ------------------------------ Methods from ConfigurationResourceProvider | ||
|
||
@Override | ||
public Collection<URI> getResources(ServletContext context) { | ||
|
||
WebConfiguration webConfig = WebConfiguration.getInstance(context); | ||
String paths = webConfig.getOptionValue(getParameter()); | ||
Set<URI> urls = new LinkedHashSet<>(6); | ||
|
||
if (paths != null) { | ||
for (String token : split(context, paths.trim(), getSeparatorRegex())) { | ||
String path = token.trim(); | ||
if (!isExcluded(path) && path.length() != 0) { | ||
URI u = getContextURLForPath(context, path); | ||
if (u != null) { | ||
urls.add(u); | ||
} else { | ||
if (LOGGER.isLoggable(WARNING)) { | ||
LOGGER.log(WARNING, "jsf.config.web_resource_not_found", new Object[] { path, JakartaFacesConfigFiles.getQualifiedName() }); | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
return urls; | ||
} | ||
|
||
// ------------------------------------------------------- Protected Methods | ||
|
||
protected abstract WebContextInitParameter getParameter(); | ||
|
||
protected abstract String[] getExcludedResources(); | ||
|
||
protected abstract String getSeparatorRegex(); | ||
|
||
protected URI getContextURLForPath(ServletContext context, String path) | ||
{ | ||
List<URI> uris = new ArrayList<>(); | ||
if (path.startsWith(STRING_FORWARD_SLASH)) | ||
{ | ||
path = path.substring(1); | ||
} | ||
if (path.contains(STRING_FORWARD_SLASH)) | ||
{ | ||
path = path.substring(path.lastIndexOf(STRING_FORWARD_SLASH) + 1); | ||
} | ||
|
||
GuiceContext.instance() | ||
.getScanResult() | ||
.getResourcesWithLeafName(path) | ||
.forEach(a -> uris.add(cleanURI(a.getURI()))); | ||
if (!uris.isEmpty()) | ||
{ | ||
return uris.get(0); | ||
} | ||
return null; | ||
} | ||
|
||
|
||
protected boolean isExcluded(String path) { | ||
return binarySearch(getExcludedResources(), path) >= 0; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
jakarta-faces/src/main/java/com/sun/faces/config/configprovider/FacesLocationsScanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sun.faces.config.configprovider; | ||
|
||
import com.guicedee.guicedinjection.interfaces.IPathContentsScanner; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class FacesLocationsScanner | ||
implements IPathContentsScanner | ||
{ | ||
@Override | ||
public Set<String> searchFor() | ||
{ | ||
Set<String> strings = new HashSet<>(); | ||
strings.add("/"); | ||
strings.add(""); | ||
strings.add("META-INF"); | ||
strings.add("META-INF/resources"); | ||
strings.add("WEB-INF"); | ||
strings.add("WEB-INF/classes/META-INF"); | ||
return strings; | ||
} | ||
} |
173 changes: 173 additions & 0 deletions
173
...main/java/com/sun/faces/config/configprovider/MetaInfFaceletTaglibraryConfigProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
/* | ||
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package com.sun.faces.config.configprovider; | ||
|
||
import static com.sun.faces.util.Util.getCurrentLoader; | ||
import static java.lang.System.arraycopy; | ||
import static java.util.Collections.emptyList; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import jakarta.faces.FacesException; | ||
import jakarta.servlet.ServletContext; | ||
|
||
import com.sun.faces.facelets.util.Classpath; | ||
import com.sun.faces.spi.ConfigurationResourceProvider; | ||
|
||
/** | ||
* | ||
*/ | ||
public class MetaInfFaceletTaglibraryConfigProvider | ||
implements ConfigurationResourceProvider | ||
{ | ||
|
||
private static final String SUFFIX = ".taglib.xml"; | ||
private static final String WEB_INF_CLASSES = "/WEB-INF/classes/META-INF"; | ||
|
||
/** | ||
* Array of taglib.xml files included with Facelets 1.1.x. If they are on the classpath, we don't want to process them. | ||
*/ | ||
private static final String[] FACELET_CONFIG_FILES = { | ||
"META-INF/jsf-core.taglib.xml", | ||
"META-INF/jsf-html.taglib.xml", | ||
"META-INF/jsf-ui.taglib.xml", | ||
"META-INF/jstl-core.taglib.xml", | ||
"META-INF/jstl-fn.taglib.xml"}; | ||
|
||
private static final String[] BUILT_IN_TAGLIB_XML_FILES = {"META-INF/mojarra_ext.taglib.xml" | ||
|
||
}; | ||
|
||
// -------------------------------------------- Methods from ConfigProcessor | ||
|
||
@Override | ||
public Collection<URI> getResources(ServletContext context) | ||
{ | ||
try | ||
{ | ||
URL[] externalTaglibUrls = Classpath.search("META-INF/", SUFFIX); | ||
URL[] externalTaglibUrlsWebINF = Classpath.search("WEB-INF/", SUFFIX); | ||
URL[] builtInTaglibUrls = new URL[BUILT_IN_TAGLIB_XML_FILES.length]; | ||
ClassLoader runtimeClassLoader = getClass() | ||
.getClassLoader(); | ||
|
||
for (int i = 0; i < BUILT_IN_TAGLIB_XML_FILES.length; i++) | ||
{ | ||
builtInTaglibUrls[i] = runtimeClassLoader.getResource(BUILT_IN_TAGLIB_XML_FILES[i]); | ||
} | ||
|
||
URL[] urls = new URL[externalTaglibUrls.length + builtInTaglibUrls.length + externalTaglibUrlsWebINF.length]; | ||
arraycopy(externalTaglibUrls, 0, urls, 0, externalTaglibUrls.length); | ||
arraycopy(builtInTaglibUrls, 0, urls, externalTaglibUrls.length, builtInTaglibUrls.length); | ||
arraycopy(externalTaglibUrlsWebINF, 0, urls, externalTaglibUrls.length + builtInTaglibUrls.length, externalTaglibUrlsWebINF.length); | ||
// Perform some 'correctness' checking. If the user has | ||
// removed the FaceletViewHandler from their configuration, | ||
// but has left the jsf-facelets.jar in the classpath, we | ||
// need to ignore the default configuration resouces from | ||
// that JAR. | ||
List<URI> urlsList = pruneURLs(urls); | ||
|
||
// Special case for finding taglib files in WEB-INF/classes/META-INF | ||
Set<String> paths = context.getResourcePaths(WEB_INF_CLASSES); | ||
if (paths != null) | ||
{ | ||
for (String path : paths) | ||
{ | ||
if (path.endsWith(".taglib.xml")) | ||
{ | ||
try | ||
{ | ||
urlsList.add(new URI(context.getResource(path) | ||
.toExternalForm() | ||
.replaceAll(" ", "%20"))); | ||
} | ||
catch (URISyntaxException ex) | ||
{ | ||
ex.printStackTrace(); | ||
throw new FacesException(ex); | ||
} | ||
} | ||
} | ||
} | ||
java.util.logging.Logger.getLogger("FaceletTagLibraries").log(java.util.logging.Level.CONFIG,"Found the following tag libraries - " + urlsList); | ||
return urlsList; | ||
} | ||
catch (IOException ioe) | ||
{ | ||
throw new FacesException("Error searching classpath from facelet-taglib documents", ioe); | ||
} | ||
|
||
} | ||
|
||
// --------------------------------------------------------- Private Methods | ||
|
||
private List<URI> pruneURLs(URL[] urls) | ||
{ | ||
|
||
List<URI> ret = null; | ||
if (urls != null && urls.length > 0) | ||
{ | ||
for (URL url : urls) | ||
{ | ||
String u = url.toString(); | ||
boolean found = false; | ||
for (String excludeName : FACELET_CONFIG_FILES) | ||
{ | ||
if (u.contains(excludeName)) | ||
{ | ||
found = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!found) | ||
{ | ||
if (ret == null) | ||
{ | ||
ret = new ArrayList<>(); | ||
} | ||
|
||
try | ||
{ | ||
ret.add(new URI(url.toExternalForm() | ||
.replaceAll(" ", "%20"))); | ||
} | ||
catch (URISyntaxException ex) | ||
{ | ||
ex.printStackTrace(); | ||
throw new FacesException(ex); | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (ret == null) | ||
{ | ||
ret = emptyList(); | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
} |
Oops, something went wrong.