Modified:
/prettyfaces/trunk/CHANGELOG.txt
/prettyfaces/trunk/core/src/main/java/com/ocpsoft/pretty/faces/el/resolver/FacesConfigBeanNameResolver.java
=======================================
--- /prettyfaces/trunk/CHANGELOG.txt Tue Nov 9 10:23:42 2010
+++ /prettyfaces/trunk/CHANGELOG.txt Wed Dec 8 23:04:32 2010
@@ -26,6 +26,7 @@
* Fixed EL method invocation in JSF 1.1 branch.
* Removed HttpSession accesses that could potentially create an unwanted
user session. (#62)
* Prevent downloading of web.xml DTDs during configuration
+* Fixed FacesConfigBeanNameResolver regarding space characters in URLs
------------------------------------
=======================================
---
/prettyfaces/trunk/core/src/main/java/com/ocpsoft/pretty/faces/el/resolver/FacesConfigBeanNameResolver.java
Tue Nov 9 10:23:42 2010
+++
/prettyfaces/trunk/core/src/main/java/com/ocpsoft/pretty/faces/el/resolver/FacesConfigBeanNameResolver.java
Wed Dec 8 23:04:32 2010
@@ -3,8 +3,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
@@ -77,12 +75,12 @@
List<FacesConfigEntry> facesConfigEntries = new
ArrayList<FacesConfigEntry>();
// get the list of faces configuration files to process
- Set<URI> facesConfigs = getFacesConfigFiles(servletContext,
classLoader);
+ Set<URL> facesConfigs = getFacesConfigFiles(servletContext,
classLoader);
// process all configuration files
- for (URI uri : facesConfigs)
- {
- processFacesConfig(uri, facesConfigEntries);
+ for (URL url : facesConfigs)
+ {
+ processFacesConfig(url, facesConfigEntries);
}
// Create bean name lookup map from all entries found
@@ -113,11 +111,11 @@
* The classloader used to find files in META-INF directories
* @return A set of URLs
*/
- private Set<URI> getFacesConfigFiles(ServletContext servletContext,
ClassLoader classLoader)
+ private Set<URL> getFacesConfigFiles(ServletContext servletContext,
ClassLoader classLoader)
{
// set of URLs to process
- Set<URI> result = new HashSet<URI>();
+ Set<URL> result = new HashSet<URL>();
try
{
@@ -126,7 +124,7 @@
URL defaultFacesConfig =
servletContext.getResource(WEB_INF_FACES_CONFIG_XML);
if (defaultFacesConfig != null)
{
- result.add(defaultFacesConfig.toURI());
+ result.add(defaultFacesConfig);
}
// get additional configuration files from init parameter
@@ -138,7 +136,7 @@
Enumeration<URL> resources =
classLoader.getResources(META_INF_FACES_CONFIG_XML);
while (resources.hasMoreElements())
{
- result.add(resources.nextElement().toURI());
+ result.add(resources.nextElement());
}
}
catch (IOException e)
@@ -152,12 +150,6 @@
// should not happen, because URLs are hard-coded
throw new IllegalArgumentException(e);
}
- catch (URISyntaxException e)
- {
- // should not happen, because URLs are hard-coded
- throw new IllegalArgumentException(e);
- }
-
return result;
}
@@ -170,7 +162,7 @@
* The ServletContext
* @return A collection of URLs (never null)
*/
- private Collection<URI> getConfigFilesFromInitParameter(ServletContext
servletContext)
+ private Collection<URL> getConfigFilesFromInitParameter(ServletContext
servletContext)
{
// read init parameter
@@ -186,7 +178,7 @@
String[] files = initParam.split(",");
// the result
- Set<URI> result = new HashSet<URI>();
+ Set<URL> result = new HashSet<URL>();
// process each single file
for (String file : files)
@@ -206,7 +198,7 @@
// add it to the result, if it exists
if (url != null)
{
- result.add(url.toURI());
+ result.add(url);
}
}
catch (MalformedURLException e)
@@ -215,10 +207,6 @@
// handle such a case
log.debug("Invalid entry in javax.faces.CONFIG_FILES init
parameter: " + file);
}
- catch (URISyntaxException e)
- {
- log.warn("Unable to create URI from URL", e);
- }
}
@@ -229,18 +217,18 @@
* Process a single <code>faces-config.xml</code> file and add all beans
* found to the supplied list of {@link FacesConfigEntry} objects.
*
- * @param uri
+ * @param url
* The faces-config.xml file
* @param facesConfigEntries
* list of entries to add the beans to
*/
- private void processFacesConfig(URI uri, List<FacesConfigEntry>
facesConfigEntries)
+ private void processFacesConfig(URL url, List<FacesConfigEntry>
facesConfigEntries)
{
// log name of current file
if (log.isTraceEnabled())
{
- log.trace("Loading bean names from: " + uri.toString());
+ log.trace("Loading bean names from: " + url.toString());
}
// setup digester
@@ -268,19 +256,19 @@
try
{
// open the file and let digester pares it
- stream = uri.toURL().openStream();
+ stream = url.openStream();
digester.parse(stream);
}
catch (IOException e)
{
// may be thrown when reading the file
- log.error("Failed to parse: " + uri.toString(), e);
+ log.error("Failed to parse: " + url.toString(), e);
}
catch (SAXException e)
{
// parsing errors
- log.error("Failed to parse: " + uri.toString(), e);
+ log.error("Failed to parse: " + url.toString(), e);
}
finally
{