[jboss-cvs] JBossAS SVN: r108525 - branches/weld-snapshot-integration/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 12 12:44:36 EDT 2010
Author: marius.bogoevici
Date: 2010-10-12 12:44:35 -0400 (Tue, 12 Oct 2010)
New Revision: 108525
Added:
branches/weld-snapshot-integration/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClassLoaderResourceLoader.java
Modified:
branches/weld-snapshot-integration/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java
Log:
JBAS-8355
Modified: branches/weld-snapshot-integration/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java
===================================================================
--- branches/weld-snapshot-integration/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java 2010-10-12 16:40:52 UTC (rev 108524)
+++ branches/weld-snapshot-integration/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java 2010-10-12 16:44:35 UTC (rev 108525)
@@ -28,10 +28,12 @@
import java.util.Map;
import java.util.WeakHashMap;
+import org.jboss.client.ReflectionLauncher;
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.ejb.spi.EjbDescriptor;
+import org.jboss.weld.resources.spi.ResourceLoader;
/**
* An archive is an abstract representation of one or more deployed archives.
@@ -248,6 +250,7 @@
{
if (bda == null)
{
+ services.add(ResourceLoader.class, new ClassLoaderResourceLoader(classLoader));
bda = new BeanDeploymentArchiveImpl(classLoader.toString(), bootstrap, services, this);
for (ArchiveLifecycleListener listener: lifecycleListeners)
{
Copied: branches/weld-snapshot-integration/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClassLoaderResourceLoader.java (from rev 108196, branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClassLoaderResourceLoader.java)
===================================================================
--- branches/weld-snapshot-integration/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClassLoaderResourceLoader.java (rev 0)
+++ branches/weld-snapshot-integration/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClassLoaderResourceLoader.java 2010-10-12 16:44:35 UTC (rev 108525)
@@ -0,0 +1,74 @@
+package org.jboss.weld.integration.deployer.env.bda;
+
+import org.jboss.weld.resources.spi.ResourceLoader;
+import org.jboss.weld.resources.spi.ResourceLoadingException;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+
+/**
+ * A (@link ResourceLoader} implementation that uses a specific @{link ClassLoader}
+ *
+ * @author Marius Bogoevici
+ */
+public class ClassLoaderResourceLoader implements ResourceLoader
+{
+ private ClassLoader classLoader;
+
+ public ClassLoaderResourceLoader(ClassLoader classLoader)
+ {
+ this.classLoader = classLoader;
+ }
+
+ public Class<?> classForName(String name)
+ {
+ try
+ {
+ return classLoader.loadClass(name);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ResourceLoadingException("Error loading class " + name, e);
+ }
+ catch (NoClassDefFoundError e)
+ {
+ throw new ResourceLoadingException("Error loading class " + name, e);
+ }
+ catch (TypeNotPresentException e)
+ {
+ throw new ResourceLoadingException("Error loading class " + name, e);
+ }
+ }
+
+ public URL getResource(String name)
+ {
+ return classLoader.getResource(name);
+
+ }
+
+ public Collection<URL> getResources(String name)
+ {
+ try
+ {
+ final Enumeration<URL> enumResources = classLoader.getResources(name);
+ ArrayList<URL> resources = new ArrayList<URL>();
+ while (enumResources.hasMoreElements())
+ {
+ resources.add(enumResources.nextElement());
+ }
+ return resources;
+ }
+ catch (IOException e)
+ {
+ throw new ResourceLoadingException("Error loading resource " + name, e);
+ }
+ }
+
+ public void cleanup()
+ {
+ this.classLoader = null;
+ }
+}
More information about the jboss-cvs-commits
mailing list