Use Set<URI> instead of Set<URL>
http://java.net/jira/browse/JAVASERVERFACES-14430
SECTION: Modified Files
----------------------------
M jsf-ri/src/main/java/com/sun/faces/spi/AnnotationProvider.java
- this is the heart of the change.
- public abstract Map<Class<? extends Annotation>,Set<Class<?>>>
getAnnotatedClasses(Set<URL> urls);
+ public abstract Map<Class<? extends Annotation>,Set<Class<?>>>
getAnnotatedClasses(Set<URI> urls);
M
jsf-ri/src/main/java/com/sun/faces/spi/ConfigurationResourceProvider.ja
va
- Another big top-level change, that impacts the SPI.
- public Collection<URL> getResources(ServletContext context);
+ public Collection<URI> getResources(ServletContext context);
M
jsf-ri/src/main/java/com/sun/faces/config/processor/FacesConfigExtensio
nProcessor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/BehaviorConfigProce
ssor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/LifecycleConfigProc
essor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/NavigationConfigPro
cessor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/ComponentConfigProc
essor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/ManagedBeanConfigPr
ocessor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/ApplicationConfigPr
ocessor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/ValidatorConfigProc
essor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/FaceletTaglibConfig
Processor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/ConverterConfigProc
essor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/FactoryConfigProces
sor.java
M
jsf-ri/src/main/java/com/sun/faces/config/processor/RenderKitConfigProc
essor.java
M
jsf-ri/src/main/java/com/sun/faces/config/configprovider/BaseWebConfigR
esourceProvider.java
M
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MojarraFacesCo
nfigResourceProvider.java
M
jsf-ri/src/main/java/com/sun/faces/config/configprovider/WebFacesConfig
ResourceProvider.java
M
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MetaInfFacelet
TaglibraryConfigProvider.java
M
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MetaInfFacesCo
nfigResourceProvider.java
M
jsf-ri/src/main/java/com/sun/faces/config/AnnotationScanner.java
M
jsf-ri/src/main/java/com/sun/faces/config/ConfigureListener.java
M jsf-ri/src/main/java/com/sun/faces/config/DocumentInfo.java
M
jsf-ri/src/main/java/com/sun/faces/config/JavaClassScanningAnnotationSc
anner.java
M jsf-ri/test/com/sun/faces/renderkit/TestRenderKit.java
- Fallout from the change.
M jsf-ri/src/main/java/com/sun/faces/config/ConfigManager.java
- More fallout, in URITask (formerly URLTask), in the call() method,
account for the fact that third party implementors of the
ConfigurationResourceProvider SPI, such as
glassfish31-1HEAD/web/weld-integration may still implement
- public Collection<URL> getResources(ServletContext context);
Thanks to the compromises of generics we can safely accomodate this
change.
SECTION: Diffs
----------------------------
Index: jsf-ri/test/com/sun/faces/renderkit/TestRenderKit.java
===================================================================
--- jsf-ri/test/com/sun/faces/renderkit/TestRenderKit.java
(revision 8748)
+++ jsf-ri/test/com/sun/faces/renderkit/TestRenderKit.java
(working copy)
@@ -74,6 +74,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringWriter;
+import java.net.URI;
import java.util.Iterator;
import java.net.URL;
@@ -493,8 +494,8 @@
}
configProcessors[0].process(servletContext, new DocumentInfo[]
{
- new
DocumentInfo(defaultDoc, runtime),
- new
DocumentInfo(renderKitDoc, renderkit) });
+ new
DocumentInfo(defaultDoc, new URI(runtime.toExternalForm())),
+ new
DocumentInfo(renderKitDoc, new URI(renderkit.toExternalForm())) });
RenderKitFactory rkf = (RenderKitFactory)
FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
RenderKit rk = rkf.getRenderKit(getFacesContext(),
RenderKitFactory.HTML_BASIC_RENDER_KIT);
Index: jsf-ri/src/main/java/com/sun/faces/spi/AnnotationProvider.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/spi/AnnotationProvider.java
(revision 8748)
+++ jsf-ri/src/main/java/com/sun/faces/spi/AnnotationProvider.java
(working copy)
@@ -42,9 +42,9 @@
import javax.servlet.ServletContext;
import java.lang.annotation.Annotation;
+import java.net.URI;
import java.util.Set;
import java.util.Map;
-import java.net.URL;
/**
* <p>
@@ -128,6 +128,6 @@
* @return a <code>Map</code> of classes mapped to a specific
annotation type.
* If no annotations are present, this method returns an empty
<code>Map</code>.
*/
- public abstract Map<Class<? extends Annotation>,Set<Class<?>>>
getAnnotatedClasses(Set<URL> urls);
+ public abstract Map<Class<? extends Annotation>,Set<Class<?>>>
getAnnotatedClasses(Set<URI> urls);
} // END AnnotationProvider
Index:
jsf-ri/src/main/java/com/sun/faces/spi/ConfigurationResourceProvider.ja
va
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/spi/ConfigurationResourceProvider.ja
va (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/spi/ConfigurationResourceProvider.ja
va (working copy)
@@ -40,9 +40,9 @@
package com.sun.faces.spi;
+import java.net.URI;
import javax.servlet.ServletContext;
-import java.net.URL;
import java.util.Collection;
/**
@@ -61,6 +61,6 @@
* @return a List zero or more <code>URL</code> instances
representing
* application configuration resources
*/
- public Collection<URL> getResources(ServletContext context);
+ public Collection<URI> getResources(ServletContext context);
}
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/FacesConfigExtensio
nProcessor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/FacesConfigExtensio
nProcessor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/FacesConfigExtensio
nProcessor.java (working copy)
@@ -106,7 +106,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing faces-config-extension
elements for document: ''{0}''",
- documentInfos[i].getSourceURL()));
+ documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace = document.getDocumentElement()
@@ -155,7 +155,7 @@
LOGGER.log(Level.WARNING,
MessageFormat.format(
"Processing
faces-config-extension elements for document: ''{0}'', encountered
unexpected configuration ''{1}'', ignoring and continuing",
- info.getSourceURL(),
getNodeText(childOfInterset)));
+ info.getSourceURI(),
getNodeText(childOfInterset)));
}
}
@@ -174,7 +174,7 @@
LOGGER.log(Level.WARNING,
MessageFormat.format(
"Processing faces-config-extension
elements for document: ''{0}'', encountered <facelets-processing>
elemnet without expected children",
- info.getSourceURL()));
+ info.getSourceURI()));
}
}
}
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/BehaviorConfigProce
ssor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/BehaviorConfigProce
ssor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/BehaviorConfigProce
ssor.java (working copy)
@@ -101,7 +101,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing behavior elements for
document: ''{0}''",
- documentInfos[i].getSourceURL()));
+ documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace = document.getDocumentElement()
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/LifecycleConfigProc
essor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/LifecycleConfigProc
essor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/LifecycleConfigProc
essor.java (working copy)
@@ -95,7 +95,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing lifecycle elements for
document: ''{0}''",
- documentInfos[i].getSourceURL()));
+ documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace =
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/NavigationConfigPro
cessor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/NavigationConfigPro
cessor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/NavigationConfigPro
cessor.java (working copy)
@@ -152,7 +152,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing navigation-rule elements
for document: ''{0}''",
- documentInfo.getSourceURL()));
+ documentInfo.getSourceURI()));
}
Document document = documentInfo.getDocument();
String namespace = document.getDocumentElement()
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/ComponentConfigProc
essor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/ComponentConfigProc
essor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/ComponentConfigProc
essor.java (working copy)
@@ -103,7 +103,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing component elements for
document: ''{0}''",
- documentInfos[i].getSourceURL()));
+ documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace = document.getDocumentElement()
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/ManagedBeanConfigPr
ocessor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/ManagedBeanConfigPr
ocessor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/ManagedBeanConfigPr
ocessor.java (working copy)
@@ -250,7 +250,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing managed-bean elements for
document: ''{0}''",
- documentInfos[i].getSourceURL()));
+ documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace =
document.getDocumentElement().getNamespaceURI();
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/ApplicationConfigPr
ocessor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/ApplicationConfigPr
ocessor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/ApplicationConfigPr
ocessor.java (working copy)
@@ -259,7 +259,7 @@
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE,
MessageFormat.format("Processing
application elements for document: ''{0}''",
-
documentInfos[i].getSourceURL()));
+
documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace =
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/ValidatorConfigProc
essor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/ValidatorConfigProc
essor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/ValidatorConfigProc
essor.java (working copy)
@@ -105,7 +105,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing validator elements for
document: ''{0}''",
- documentInfos[i].getSourceURL()));
+ documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace =
document.getDocumentElement().getNamespaceURI();
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/FaceletTaglibConfig
Processor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/FaceletTaglibConfig
Processor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/FaceletTaglibConfig
Processor.java (working copy)
@@ -248,7 +248,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing facelet-taglibrary
document: ''{0}''",
- documentInfos[i].getSourceURL()));
+ documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace =
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/ConverterConfigProc
essor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/ConverterConfigProc
essor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/ConverterConfigProc
essor.java (working copy)
@@ -112,7 +112,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing converter elements for
document: ''{0}''",
- documentInfos[i].getSourceURL()));
+ documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace = document.getDocumentElement()
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/FactoryConfigProces
sor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/FactoryConfigProces
sor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/FactoryConfigProces
sor.java (working copy)
@@ -188,7 +188,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing factory elements for
document: ''{0}''",
- documentInfos[i].getSourceURL()));
+ documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace = document.getDocumentElement()
Index:
jsf-ri/src/main/java/com/sun/faces/config/processor/RenderKitConfigProc
essor.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/processor/RenderKitConfigProc
essor.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/processor/RenderKitConfigProc
essor.java (working copy)
@@ -147,7 +147,7 @@
LOGGER.log(Level.FINE,
MessageFormat.format(
"Processing render-kit elements for
document: ''{0}''",
- documentInfos[i].getSourceURL()));
+ documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace = document.getDocumentElement()
Index: jsf-ri/src/main/java/com/sun/faces/config/ConfigManager.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/config/ConfigManager.java
(revision 8748)
+++ jsf-ri/src/main/java/com/sun/faces/config/ConfigManager.java
(working copy)
@@ -111,6 +111,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.lang.annotation.Annotation;
+import java.net.URI;
+import java.util.Iterator;
import org.w3c.dom.*;
import org.xml.sax.SAXParseException;
@@ -607,11 +609,11 @@
ExecutorService
executor,
boolean validating) {
- List<FutureTask<Collection<URL>>> urlTasks =
- new
ArrayList<FutureTask<Collection<URL>>>(providers.size());
+ List<FutureTask<Collection<URI>>> urlTasks =
+ new
ArrayList<FutureTask<Collection<URI>>>(providers.size());
for (ConfigurationResourceProvider p : providers) {
- FutureTask<Collection<URL>> t =
- new FutureTask<Collection<URL>>(new URLTask(p, sc));
+ FutureTask<Collection<URI>> t =
+ new FutureTask<Collection<URI>>(new URITask(p, sc));
urlTasks.add(t);
if (executor != null) {
executor.execute(t);
@@ -623,10 +625,11 @@
List<FutureTask<DocumentInfo>> docTasks =
new ArrayList<FutureTask<DocumentInfo>>(providers.size()
<< 1);
- for (FutureTask<Collection<URL>> t : urlTasks) {
+ int i = 0, j = 0;
+ for (FutureTask<Collection<URI>> t : urlTasks) {
try {
- Collection<URL> l = t.get();
- for (URL u : l) {
+ Collection<URI> l = t.get();
+ for (URI u : l) {
FutureTask<DocumentInfo> d =
new FutureTask<DocumentInfo>(new
ParseTask(validating, u));
docTasks.add(d);
@@ -635,11 +638,13 @@
} else {
d.run();
}
+ j++;
}
} catch (InterruptedException ignored) {
} catch (Exception e) {
throw new ConfigurationException(e);
}
+ i++;
}
List<DocumentInfo> docs = new
ArrayList<DocumentInfo>(docTasks.size());
@@ -714,17 +719,17 @@
this.documentInfos = documentInfos;
}
- private Set<URL> getAnnotationScanURLs() {
- Set<URL> urls = new HashSet<URL>(documentInfos.length);
+ private Set<URI> getAnnotationScanURLs() {
+ Set<URI> urls = new HashSet<URI>(documentInfos.length);
Set<String> jarNames = new
HashSet<String>(documentInfos.length);
for (DocumentInfo docInfo : documentInfos) {
- Matcher m =
JAR_PATTERN.matcher(docInfo.getSourceURL().toString());
+ Matcher m =
JAR_PATTERN.matcher(docInfo.getSourceURI().toString());
if (m.matches()) {
String jarName = m.group(2);
if (!jarNames.contains(jarName)) {
FacesConfigInfo configInfo = new
FacesConfigInfo(docInfo);
if (!configInfo.isMetadataComplete()) {
- urls.add(docInfo.getSourceURL());
+ urls.add(docInfo.getSourceURI());
jarNames.add(jarName);
}
}
@@ -768,11 +773,11 @@
if (t != null) {
t.startTiming();
}
- Set<URL> scanUrls = urlGetter.getAnnotationScanURLs();
+ Set<URI> scanUris = urlGetter.getAnnotationScanURLs();
//AnnotationScanner scanner = new AnnotationScanner(sc);
Map<Class<? extends Annotation>,Set<Class<?>>>
annotatedClasses =
- provider.getAnnotatedClasses(scanUrls);
+ provider.getAnnotatedClasses(scanUris);
if (t != null) {
t.stopTiming();
@@ -798,7 +803,7 @@
"http://java.sun.com/xml/ns/javaee";
private static final String EMPTY_FACES_CONFIG =
"com/sun/faces/empty-faces-config.xml";
- private URL documentURL;
+ private URI documentURI;
private DocumentBuilderFactory factory;
private boolean validating;
@@ -811,13 +816,13 @@
* </p>
*
* @param validating whether or not we're validating
- * @param documentURL a URL to the configuration resource to
be parsed
+ * @param documentURI a URL to the configuration resource to
be parsed
* @throws Exception general error
*/
- public ParseTask(boolean validating, URL documentURL)
+ public ParseTask(boolean validating, URI documentURI)
throws Exception {
- this.documentURL = documentURL;
+ this.documentURI = documentURI;
this.factory = DbfFactory.getFactory();
this.validating = validating;
@@ -843,14 +848,14 @@
if (timer != null) {
timer.stopTiming();
- timer.logResult("Parse " +
documentURL.toExternalForm());
+ timer.logResult("Parse " +
documentURI.toURL().toExternalForm());
}
- return new DocumentInfo(d, documentURL);
+ return new DocumentInfo(d, documentURI);
} catch (Exception e) {
throw new ConfigurationException(MessageFormat.format(
"Unable to parse document ''{0}'': {1}",
- documentURL.toExternalForm(),
+ documentURI.toURL().toExternalForm(),
e.getMessage()), e);
}
}
@@ -860,7 +865,7 @@
/**
- * @return <code>Document</code> based on
<code>documentURL</code>.
+ * @return <code>Document</code> based on
<code>documentURI</code>.
* @throws Exception if an error occurs during the process of
building a
* <code>Document</code>
*/
@@ -868,8 +873,9 @@
Document returnDoc;
DocumentBuilder db = getNonValidatingBuilder();
+ URL documentURL = documentURI.toURL();
InputSource is = new
InputSource(getInputStream(documentURL));
- is.setSystemId(documentURL.toExternalForm());
+ is.setSystemId(documentURI.toURL().toExternalForm());
Document doc = null;
try {
@@ -1073,7 +1079,7 @@
* processing.
* </p>
*/
- private static class URLTask implements Callable<Collection<URL>>
{
+ private static class URITask implements Callable<Collection<URI>>
{
private ConfigurationResourceProvider provider;
private ServletContext sc;
@@ -1083,12 +1089,12 @@
/**
- * Constructs a new <code>URLTask</code> instance.
+ * Constructs a new <code>URITask</code> instance.
* @param provider the
<code>ConfigurationResourceProvider</code> from
* which zero or more <code>URL</code>s will be returned
* @param sc the <code>ServletContext</code> of the current
application
*/
- public URLTask(ConfigurationResourceProvider provider,
+ public URITask(ConfigurationResourceProvider provider,
ServletContext sc) {
this.provider = provider;
this.sc = sc;
@@ -1103,11 +1109,29 @@
* @throws Exception if an Exception is thrown by the
underlying
* <code>ConfigurationResourceProvider</code>
*/
- public Collection<URL> call() throws Exception {
- return provider.getResources(sc);
+ public Collection<URI> call() throws Exception {
+ Collection untypedCollection = provider.getResources(sc);
+ Iterator untypedCollectionIterator =
untypedCollection.iterator();
+ Collection<URI> result = Collections.emptyList();
+ if (untypedCollectionIterator.hasNext()) {
+ Object cur = untypedCollectionIterator.next();
+ // account for older versions of the provider that
return Collection<URL>.
+ if (cur instanceof URL) {
+ result = new
ArrayList<URI>(untypedCollection.size());
+ result.add(new URI(((URL)cur).toExternalForm()));
+ while (untypedCollectionIterator.hasNext()) {
+ cur = untypedCollectionIterator.next();
+ result.add(new
URI(((URL)cur).toExternalForm()));
+ }
+ } else {
+ result = (Collection<URI>) untypedCollection;
+ }
+ }
+
+ return result;
}
- } // END URLTask
+ } // END URITask
}
Index:
jsf-ri/src/main/java/com/sun/faces/config/configprovider/BaseWebConfigR
esourceProvider.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/configprovider/BaseWebConfigR
esourceProvider.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/configprovider/BaseWebConfigR
esourceProvider.java (working copy)
@@ -58,6 +58,8 @@
import com.sun.faces.util.Util;
import com.sun.faces.util.FacesLogger;
import com.sun.faces.spi.ConfigurationResourceProvider;
+import java.net.URI;
+import java.net.URISyntaxException;
/**
*
@@ -72,16 +74,16 @@
// ------------------------------ Methods from
ConfigurationResourceProvider
- public Collection<URL> getResources(ServletContext context) {
+ public Collection<URI> getResources(ServletContext context) {
WebConfiguration webConfig =
WebConfiguration.getInstance(context);
String paths = webConfig.getOptionValue(getParameter());
- Set<URL> urls = new LinkedHashSet<URL>(6);
+ Set<URI> urls = new LinkedHashSet<URI>(6);
if (paths != null) {
for (String token : Util.split(context, paths.trim(),
getSeparatorRegex())) {
String path = token.trim();
if (!isExcluded(path) && path.length() != 0) {
- URL u = getContextURLForPath(context, path);
+ URI u = getContextURLForPath(context, path);
if (u != null) {
urls.add(u);
} else {
@@ -111,13 +113,20 @@
protected abstract String getSeparatorRegex();
- protected URL getContextURLForPath(ServletContext context, String
path) {
+ protected URI getContextURLForPath(ServletContext context, String
path) {
+ URI result = null;
try {
- return context.getResource(path);
+ URL url = context.getResource(path);
+ if (null != url) {
+ result = new URI(url.toExternalForm());
+ }
} catch (MalformedURLException mue) {
throw new FacesException(mue);
+ } catch (URISyntaxException use) {
+ throw new FacesException(use);
}
+ return result;
}
Index:
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MojarraFacesCo
nfigResourceProvider.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MojarraFacesCo
nfigResourceProvider.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MojarraFacesCo
nfigResourceProvider.java (working copy)
@@ -42,10 +42,12 @@
import com.sun.faces.spi.ConfigurationResourceProvider;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import javax.faces.FacesException;
import javax.servlet.ServletContext;
@@ -65,14 +67,18 @@
/**
* @see
ConfigurationResourceProvider#getResources(javax.servlet.ServletContext
)
*/
- public Collection<URL> getResources(ServletContext context) {
+ public Collection<URI> getResources(ServletContext context) {
- List<URL> list = new ArrayList<URL>(1);
+ List<URI> list = new ArrayList<URI>(1);
// Don't use Util.getCurrentLoader(). This config resource
should
// be available from the same classloader that loaded this
instance.
// Doing so allows us to be more OSGi friendly.
ClassLoader loader = this.getClass().getClassLoader();
- list.add(loader.getResource(JSF_RI_CONFIG));
+ try {
+ list.add(new
URI(loader.getResource(JSF_RI_CONFIG).toExternalForm()));
+ } catch (URISyntaxException ex) {
+ throw new FacesException(ex);
+ }
return list;
}
Index:
jsf-ri/src/main/java/com/sun/faces/config/configprovider/WebFacesConfig
ResourceProvider.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/configprovider/WebFacesConfig
ResourceProvider.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/configprovider/WebFacesConfig
ResourceProvider.java (working copy)
@@ -40,6 +40,7 @@
package com.sun.faces.config.configprovider;
+import java.net.URI;
import java.net.URL;
import java.util.Collection;
@@ -71,12 +72,12 @@
/**
* @see
com.sun.faces.spi.ConfigurationResourceProvider#getResources(javax.serv
let.ServletContext)
*/
- public Collection<URL> getResources(ServletContext context) {
+ public Collection<URI> getResources(ServletContext context) {
- Collection<URL> urls = super.getResources(context);
+ Collection<URI> urls = super.getResources(context);
// Step 5, parse "/WEB-INF/faces-config.xml" if it exists
- URL webFacesConfig = getContextURLForPath(context,
WEB_INF_RESOURCE);
+ URI webFacesConfig = getContextURLForPath(context,
WEB_INF_RESOURCE);
if (webFacesConfig != null) {
urls.add(webFacesConfig);
}
Index:
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MetaInfFacelet
TaglibraryConfigProvider.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MetaInfFacelet
TaglibraryConfigProvider.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MetaInfFacelet
TaglibraryConfigProvider.java (working copy)
@@ -40,6 +40,7 @@
package com.sun.faces.config.configprovider;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collection;
import java.util.List;
@@ -47,6 +48,8 @@
import java.util.Collections;
import java.util.Set;
import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.servlet.ServletContext;
import javax.faces.FacesException;
@@ -54,6 +57,7 @@
import com.sun.faces.facelets.util.Classpath;
import com.sun.faces.util.Util;
import com.sun.faces.spi.ConfigurationResourceProvider;
+import java.net.URI;
/**
*
@@ -81,7 +85,7 @@
// -------------------------------------------- Methods from
ConfigProcessor
- public Collection<URL> getResources(ServletContext context) {
+ public Collection<URI> getResources(ServletContext context) {
try {
URL[] urls = Classpath.search(Util.getCurrentLoader(this),
@@ -92,7 +96,7 @@
// but has left the jsf-facelets.jar in the classpath, we
// need to ignore the default configuration resouces from
// that JAR.
- List<URL> urlsList = pruneURLs(urls);
+ List<URI> urlsList = pruneURLs(urls);
// special case for finding taglib files in
WEB-INF/classes/META-INF
Set paths = context.getResourcePaths(WEB_INF_CLASSES);
@@ -100,7 +104,11 @@
for (Object path : paths) {
String p = path.toString();
if (p.endsWith(".taglib.xml")) {
- urlsList.add(context.getResource(p));
+ try {
+ urlsList.add(new
URI(context.getResource(p).toExternalForm()));
+ } catch (URISyntaxException ex) {
+ throw new FacesException(ex);
+ }
}
}
}
@@ -115,9 +123,9 @@
// ---------------------------------------------------------
Private Methods
- private List<URL> pruneURLs(URL[] urls) {
+ private List<URI> pruneURLs(URL[] urls) {
- List<URL> ret = null;
+ List<URI> ret = null;
if (urls != null && urls.length > 0) {
for (URL url : urls) {
String u = url.toString();
@@ -130,9 +138,13 @@
}
if (!found) {
if (ret == null) {
- ret = new ArrayList<URL>();
+ ret = new ArrayList<URI>();
}
- ret.add(url);
+ try {
+ ret.add(new URI(url.toExternalForm()));
+ } catch (URISyntaxException ex) {
+ throw new FacesException(ex);
+ }
}
}
}
Index:
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MetaInfFacesCo
nfigResourceProvider.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MetaInfFacesCo
nfigResourceProvider.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/configprovider/MetaInfFacesCo
nfigResourceProvider.java (working copy)
@@ -44,10 +44,7 @@
import com.sun.faces.config.WebConfiguration;
import com.sun.faces.facelets.util.Classpath;
import com.sun.faces.spi.ConfigurationResourceProvider;
-import java.net.MalformedURLException;
import java.net.URISyntaxException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.faces.FacesException;
import javax.servlet.ServletContext;
@@ -63,7 +60,6 @@
import java.util.Collection;
import java.util.Set;
import java.util.HashSet;
-import java.util.Arrays;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
@@ -96,7 +92,7 @@
/**
* @see
com.sun.faces.spi.ConfigurationResourceProvider#getResources(javax.serv
let.ServletContext)
*/
- public Collection<URL> getResources(ServletContext context) {
+ public Collection<URI> getResources(ServletContext context) {
WebConfiguration webConfig =
WebConfiguration.getInstance(context);
String duplicateJarPattern =
webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.Dupli
cateJARPattern);
@@ -148,16 +144,7 @@
// Then load the unsorted resources
result.addAll(unsortedResourceList);
- List<URL> urlResult = new ArrayList<URL>(sortedJarMap.size() +
unsortedResourceList
- .size());
- for (URI uri : result) {
- try {
- urlResult.add(uri.toURL());
- } catch (MalformedURLException ex) {
- throw new FacesException(ex);
- }
- }
- return urlResult;
+ return result;
}
Index: jsf-ri/src/main/java/com/sun/faces/config/AnnotationScanner.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/config/AnnotationScanner.java
(revision 8748)
+++ jsf-ri/src/main/java/com/sun/faces/config/AnnotationScanner.java
(working copy)
@@ -58,7 +58,7 @@
import javax.faces.validator.FacesValidator;
import javax.servlet.ServletContext;
import java.lang.annotation.Annotation;
-import java.net.URL;
+import java.net.URI;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -144,7 +144,7 @@
* If no annotations are present, or the application is
considered
* <code>metadata-complete</code> <code>null</code> will be
returned.
*/
- public Map<Class<? extends Annotation>,Set<Class<?>>>
getAnnotatedClasses(Set<URL> urls) {
+ public Map<Class<? extends Annotation>,Set<Class<?>>>
getAnnotatedClasses(Set<URI> uris) {
Set<String> classList = new HashSet<String>();
Index: jsf-ri/src/main/java/com/sun/faces/config/ConfigureListener.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/config/ConfigureListener.java
(revision 8748)
+++ jsf-ri/src/main/java/com/sun/faces/config/ConfigureListener.java
(working copy)
@@ -73,7 +73,6 @@
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
-import javax.el.CompositeELResolver;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.faces.FactoryFinder;
@@ -106,6 +105,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
+import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.text.MessageFormat;
@@ -471,11 +471,11 @@
private void initConfigMonitoring(ServletContext context) {
//noinspection unchecked
- Collection<URL> webURLs =
- (Collection<URL>)
context.getAttribute("com.sun.faces.webresources");
- if (isDevModeEnabled() && webURLs != null &&
!webURLs.isEmpty()) {
+ Collection<URI> webURIs =
+ (Collection<URI>)
context.getAttribute("com.sun.faces.webresources");
+ if (isDevModeEnabled() && webURIs != null &&
!webURIs.isEmpty()) {
webResourcePool = new ScheduledThreadPoolExecutor(1, new
MojarraThreadFactory("WebResourceMonitor"));
- webResourcePool.scheduleAtFixedRate(new
WebConfigResourceMonitor(context, webURLs),
+ webResourcePool.scheduleAtFixedRate(new
WebConfigResourceMonitor(context, webURIs),
2000,
2000,
TimeUnit.MILLISECONDS);
@@ -972,21 +972,21 @@
// --------------------------------------------------------
Constructors
- public WebConfigResourceMonitor(ServletContext sc,
Collection<URL> urls) {
+ public WebConfigResourceMonitor(ServletContext sc,
Collection<URI> uris) {
- assert (urls != null);
+ assert (uris != null);
this.sc = sc;
- for (URL url : urls) {
+ for (URI uri : uris) {
if (monitors == null) {
- monitors = new ArrayList<Monitor>(urls.size());
+ monitors = new ArrayList<Monitor>(uris.size());
}
try {
- Monitor m = new Monitor(url);
+ Monitor m = new Monitor(uri);
monitors.add(m);
} catch (IOException ioe) {
if (LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.severe("Unable to setup resource
monitor for "
- + url.toExternalForm()
+ + uri.toString()
+ ". Resource will not be
monitored for changes.");
}
if (LOGGER.isLoggable(Level.FINE)) {
@@ -1020,7 +1020,7 @@
} catch (IOException ioe) {
if (LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.severe("Unable to access url "
- + m.url.toExternalForm()
+ + m.uri.toString()
+ ". Monitoring for this
resource will no longer occur.");
}
if (LOGGER.isLoggable(Level.FINE)) {
@@ -1043,20 +1043,20 @@
private class Monitor {
- private URL url;
+ private URI uri;
private long timestamp = -1;
// ----------------------------------------------------
Constructors
- Monitor(URL url) throws IOException {
+ Monitor(URI uri) throws IOException {
- this.url = url;
+ this.uri = uri;
this.timestamp = getLastModified();
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.log(Level.INFO,
"Monitoring {0} for modifications",
- url.toExternalForm());
+ uri.toURL().toExternalForm());
}
}
@@ -1072,7 +1072,7 @@
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.log(Level.INFO,
"{0} changed!",
- url.toExternalForm());
+ uri.toURL().toExternalForm());
}
return true;
}
@@ -1088,7 +1088,7 @@
InputStream in = null;
try {
- URLConnection conn = url.openConnection();
+ URLConnection conn = uri.toURL().openConnection();
conn.connect();
in = conn.getInputStream();
return conn.getLastModified();
Index: jsf-ri/src/main/java/com/sun/faces/config/DocumentInfo.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/config/DocumentInfo.java
(revision 8748)
+++ jsf-ri/src/main/java/com/sun/faces/config/DocumentInfo.java
(working copy)
@@ -40,6 +40,7 @@
package com.sun.faces.config;
+import java.net.URI;
import org.w3c.dom.Document;
import java.net.URL;
@@ -51,16 +52,16 @@
public class DocumentInfo {
private Document document;
- private URL sourceURL;
+ private URI sourceURI;
// ------------------------------------------------------------
Constructors
- public DocumentInfo(Document document, URL sourceURL) {
+ public DocumentInfo(Document document, URI sourceURL) {
this.document = document;
- this.sourceURL = sourceURL;
+ this.sourceURI = sourceURL;
}
@@ -75,9 +76,9 @@
}
- public URL getSourceURL() {
+ public URI getSourceURI() {
- return sourceURL;
+ return sourceURI;
}
Index:
jsf-ri/src/main/java/com/sun/faces/config/JavaClassScanningAnnotationSc
anner.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/config/JavaClassScanningAnnotationSc
anner.java (revision 8748)
+++
jsf-ri/src/main/java/com/sun/faces/config/JavaClassScanningAnnotationSc
anner.java (working copy)
@@ -40,6 +40,7 @@
package com.sun.faces.config;
+import java.net.URI;
import com.sun.faces.util.FacesLogger;
import com.sun.faces.util.Util;
@@ -167,12 +168,12 @@
* <code>metadata-complete</code> <code>null</code> will be
returned.
*/
@Override
- public Map<Class<? extends Annotation>,Set<Class<?>>>
getAnnotatedClasses(Set<URL> urls) {
+ public Map<Class<? extends Annotation>,Set<Class<?>>>
getAnnotatedClasses(Set<URI> uris) {
Set<String> classList = new HashSet<String>();
processWebInfClasses(sc, classList);
- processClasspath(urls, classList);
+ processClasspath(uris, classList);
processScripts(classList);
return processClassList(classList);
@@ -184,16 +185,16 @@
/**
* Scans for annotations on classes within JAR files on the
classpath.
*
- * @param urls to a faces-config documents that allow us to refer
to
+ * @param uris to a faces-config documents that allow us to refer
to
* unique jar files on the classpath
* @param classList the <code>Set</code> to which annotated
classes
* will be added
*/
- private void processClasspath(Set<URL> urls, Set<String>
classList) {
+ private void processClasspath(Set<URI> uris, Set<String>
classList) {
- for (URL url : urls) {
+ for (URI uri : uris) {
try {
- Matcher m = JAR_PATTERN.matcher(url.toString());
+ Matcher m = JAR_PATTERN.matcher(uri.toString());
if (m.matches()) {
String jarName = m.group(2);
if (!processJar(jarName)) {
@@ -222,7 +223,7 @@
classList);
} else {
if (LOGGER.isLoggable(Level.FINE)) {
- LOGGER.fine("Unable to match URL to a jar
file: " + url
+ LOGGER.fine("Unable to match URL to a jar
file: " + uri
.toString());
}
}
@@ -231,7 +232,7 @@
LOGGER.log(Level.SEVERE,
"Unable to process annotations for url,
{0}. Reason: "
+ e.toString(),
- new Object[]{url});
+ new Object[]{uri});
LOGGER.log(Level.SEVERE, "", e);
}
}