Author: pete.muir(a)jboss.org
Date: 2009-01-05 12:57:26 -0500 (Mon, 05 Jan 2009)
New Revision: 772
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/SimpleResourceLoader.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java
Log:
WBRI-89
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/SimpleResourceLoader.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/SimpleResourceLoader.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/SimpleResourceLoader.java 2009-01-05
17:57:26 UTC (rev 772)
@@ -0,0 +1,47 @@
+package org.jboss.webbeans.bootstrap;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.resources.spi.ResourceLoadingException;
+import org.jboss.webbeans.util.EnumerationIterable;
+
+public class SimpleResourceLoader implements ResourceLoader
+{
+
+ public Class<?> classForName(String name)
+ {
+
+ try
+ {
+ return Class.forName(name);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ResourceLoadingException(e);
+ }
+ catch (NoClassDefFoundError e)
+ {
+ throw new ResourceLoadingException(e);
+ }
+ }
+
+ public URL getResource(String name)
+ {
+ return getClass().getResource(name);
+ }
+
+ public Iterable<URL> getResources(String name)
+ {
+ try
+ {
+ return new
EnumerationIterable<URL>(getClass().getClassLoader().getResources(name));
+ }
+ catch (IOException e)
+ {
+ throw new ResourceLoadingException(e);
+ }
+ }
+
+}
Property changes on:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/SimpleResourceLoader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java 2009-01-05
17:22:12 UTC (rev 771)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java 2009-01-05
17:57:26 UTC (rev 772)
@@ -23,6 +23,7 @@
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.PropertiesBasedBootstrap;
+import org.jboss.webbeans.bootstrap.SimpleResourceLoader;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.ApplicationContext;
import org.jboss.webbeans.context.DependentContext;
@@ -52,21 +53,16 @@
// Create the manager
this.manager = new ManagerImpl();
- // Create a resouce loader based on the servlet context for initial loading
- ResourceLoader servletContextResourceLoader = new
ServletContextResourceLoader(servletContext);
- this.deploymentProperties = new
DeploymentProperties(servletContextResourceLoader);
+ // Create a simpple resource loader based for initial loading
+ this.resourceLoader = new SimpleResourceLoader();
+ this.deploymentProperties = new DeploymentProperties(resourceLoader);
// Attempt to create a plugin resource loader
- Constructor<? extends ResourceLoader> resourceLoaderConstructor =
getClassConstructor(deploymentProperties, servletContextResourceLoader,
ResourceLoader.PROPERTY_NAME, ResourceLoader.class, ServletContext.class);
+ Constructor<? extends ResourceLoader> resourceLoaderConstructor =
getClassConstructor(deploymentProperties, resourceLoader, ResourceLoader.PROPERTY_NAME,
ResourceLoader.class, ServletContext.class);
if (resourceLoaderConstructor != null)
{
this.resourceLoader = newInstance(resourceLoaderConstructor, servletContext);
}
- else
- {
- // If no plugin resource loader, use the servlet context resource loader
- this.resourceLoader = servletContextResourceLoader;
- }
// Now safe to initialize other properties and register the manager
super.initProperties();
Show replies by date