[jboss-cvs] JBossAS SVN: r107877 - in branches/weld-snapshot/weld-int: deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Aug 28 14:57:23 EDT 2010
Author: pete.muir at jboss.org
Date: 2010-08-28 14:57:22 -0400 (Sat, 28 Aug 2010)
New Revision: 107877
Modified:
branches/weld-snapshot/weld-int/deployer-mc-int/src/test/java/org/jboss/test/deployers/test/AbstractWeldTest.java
branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/FlatDeployment.java
branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossBeanDeploymentArchive.java
branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryDeployer.java
branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java
branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java
branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java
branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/MockWeldBootstrap.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/WeldDEWrapper.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/WeldDiscoveryEnvTestCase.java
Log:
WELD-521
Modified: branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/FlatDeployment.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/FlatDeployment.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/FlatDeployment.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -16,10 +16,24 @@
*/
package org.jboss.weld.integration.deployer.env;
+import static java.util.logging.Level.WARNING;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
-import java.util.ServiceLoader;
+import java.util.Set;
+import java.util.logging.Logger;
import javax.enterprise.inject.spi.Extension;
@@ -27,6 +41,7 @@
import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.bootstrap.spi.Metadata;
import org.jboss.weld.ejb.spi.EjbDescriptor;
/**
@@ -40,6 +55,359 @@
*/
public class FlatDeployment implements Deployment
{
+
+
+ /**
+ * This class handles looking up service providers on the class path. It
+ * implements the <a href="http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#Service%20Provider"
+ * >Service Provider section of the JAR File Specification</a>.
+ *
+ * The Service Provider programmatic lookup was not specified prior to Java 6 so
+ * this interface allows use of the specification prior to Java 6.
+ *
+ * The API is copied from <a
+ * href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html"
+ * >java.util.ServiceLoader</a> and enhanced to support the {@link Metadata}
+ * contract.
+ *
+ * @author Pete Muir
+ * @author <a href="mailto:dev at avalon.apache.org">Avalon Development Team</a>
+ * @author Nicklas Karlsson
+ */
+ private static class ServiceLoader<S> implements Iterable<Metadata<S>>
+ {
+
+ private static class ServiceLoaderMetadata<S> implements Metadata<S>
+ {
+
+ private final URL file;
+ private final int lineNumber;
+ private final S value;
+ public ServiceLoaderMetadata(S value, URL file, int lineNumber)
+ {
+ this.file = file;
+ this.lineNumber = lineNumber;
+ this.value = value;
+ }
+
+ public String getLocation()
+ {
+ return file + "@" + lineNumber;
+ }
+
+ public S getValue()
+ {
+ return value;
+ }
+
+ }
+
+ private static final String SERVICES = "META-INF/services";
+
+ private static final Logger log = Logger.getLogger("ServiceLoader");
+
+ /**
+ * Creates a new service loader for the given service type, using the current
+ * thread's context class loader.
+ *
+ * An invocation of this convenience method of the form
+ *
+ * {@code ServiceLoader.load(service)</code>}
+ *
+ * is equivalent to
+ *
+ * <code>ServiceLoader.load(service,
+ * Thread.currentThread().getContextClassLoader())</code>
+ *
+ * @param service The interface or abstract class representing the service
+ * @return A new service loader
+ */
+ public static <S> ServiceLoader<S> load(Class<S> service)
+ {
+ return load(service, Thread.currentThread().getContextClassLoader());
+ }
+
+ /**
+ * Creates a new service loader for the given service type and class loader.
+ *
+ * @param service The interface or abstract class representing the service
+ * @param loader The class loader to be used to load provider-configuration
+ * files and provider classes, or null if the system class loader
+ * (or, failing that, the bootstrap class loader) is to be used
+ * @return A new service loader
+ */
+ public static <S> ServiceLoader<S> load(Class<S> service, ClassLoader loader)
+ {
+ if (loader == null)
+ {
+ loader = service.getClassLoader();
+ }
+ return new ServiceLoader<S>(service, loader);
+ }
+
+ /**
+ * Creates a new service loader for the given service type, using the
+ * extension class loader.
+ *
+ * This convenience method simply locates the extension class loader, call it
+ * extClassLoader, and then returns
+ *
+ * <code>ServiceLoader.load(service, extClassLoader)</code>
+ *
+ * If the extension class loader cannot be found then the system class loader
+ * is used; if there is no system class loader then the bootstrap class
+ * loader is used.
+ *
+ * This method is intended for use when only installed providers are desired.
+ * The resulting service will only find and load providers that have been
+ * installed into the current Java virtual machine; providers on the
+ * application's class path will be ignored.
+ *
+ * @param service The interface or abstract class representing the service
+ * @return A new service loader
+ */
+ public static <S> ServiceLoader<S> loadInstalled(Class<S> service)
+ {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ private final String serviceFile;
+ private Class<S> expectedType;
+ private final ClassLoader loader;
+
+ private Set<Metadata<S>> providers;
+
+ private ServiceLoader(Class<S> service, ClassLoader loader)
+ {
+ this.loader = loader;
+ this.serviceFile = SERVICES + "/" + service.getName();
+ this.expectedType = service;
+ }
+
+ /**
+ * Clear this loader's provider cache so that all providers will be reloaded.
+ *
+ * After invoking this method, subsequent invocations of the iterator method
+ * will lazily look up and instantiate providers from scratch, just as is
+ * done by a newly-created loader.
+ *
+ * This method is intended for use in situations in which new providers can
+ * be installed into a running Java virtual machine.
+ */
+ public void reload()
+ {
+ providers = new HashSet<Metadata<S>>();
+
+ for (URL serviceFile : loadServiceFiles())
+ {
+ loadServiceFile(serviceFile);
+ }
+ }
+
+ private List<URL> loadServiceFiles()
+ {
+ List<URL> serviceFiles = new ArrayList<URL>();
+ try
+ {
+ Enumeration<URL> serviceFileEnumerator = loader.getResources(serviceFile);
+ while (serviceFileEnumerator.hasMoreElements())
+ {
+ serviceFiles.add(serviceFileEnumerator.nextElement());
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Could not load resources from " + serviceFile, e);
+ }
+ return serviceFiles;
+ }
+
+ private void loadServiceFile(URL serviceFile)
+ {
+ InputStream is = null;
+ try
+ {
+ is = serviceFile.openStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ String serviceClassName = null;
+ int i = 0;
+ while ((serviceClassName = reader.readLine()) != null)
+ {
+ i++;
+ serviceClassName = trim(serviceClassName);
+ if (serviceClassName.length() > 0)
+ {
+ loadService(serviceClassName, serviceFile, i);
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ // FIXME: correct exception
+ throw new RuntimeException("Could not read services file " + serviceFile);
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ // FIXME: correct exception
+ throw new RuntimeException("Could not close services file " + serviceFile, e);
+ }
+ }
+ }
+ }
+
+ private String trim(String line)
+ {
+ final int comment = line.indexOf('#');
+
+ if (comment > -1)
+ {
+ line = line.substring(0, comment);
+ }
+ return line.trim();
+ }
+
+ private void loadService(String serviceClassName, URL file, int lineNumber)
+ {
+ Class<? extends S> serviceClass = loadClass(serviceClassName);
+ if (serviceClass == null)
+ {
+ return;
+ }
+ S serviceInstance = prepareInstance(serviceClass);
+ if (serviceInstance == null)
+ {
+ return;
+ }
+ providers.add(new ServiceLoaderMetadata<S>(serviceInstance, file, lineNumber));
+ }
+
+ private Class<? extends S> loadClass(String serviceClassName)
+ {
+ Class<?> clazz = null;
+ Class<? extends S> serviceClass = null;
+ try
+ {
+ clazz = loader.loadClass(serviceClassName);
+ serviceClass = clazz.asSubclass(expectedType);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.warning("Could not load service class " + serviceClassName);
+ }
+ catch (ClassCastException e)
+ {
+ throw new RuntimeException("Service class " + serviceClassName + " didn't implement the Extension interface");
+ }
+ return serviceClass;
+ }
+
+ private S prepareInstance(Class<? extends S> serviceClass)
+ {
+ try
+ {
+ // TODO Support the SM
+ Constructor<? extends S> constructor = serviceClass.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ return constructor.newInstance();
+ }
+ catch (NoClassDefFoundError e)
+ {
+ log.log(WARNING, "Could not instantiate service class " + serviceClass.getName(), e);
+ return null;
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new RuntimeException("Error instantiating " + serviceClass, e.getCause());
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new RuntimeException("Error instantiating " + serviceClass, e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException("Error instantiating " + serviceClass, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException("Error instantiating " + serviceClass, e);
+ }
+ catch (SecurityException e)
+ {
+ throw new RuntimeException("Error instantiating " + serviceClass, e);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new RuntimeException("Error instantiating " + serviceClass, e);
+ }
+ }
+
+ /**
+ * Lazily loads the available providers of this loader's service.
+ *
+ * The iterator returned by this method first yields all of the elements of
+ * the provider cache, in instantiation order. It then lazily loads and
+ * instantiates any remaining providers, adding each one to the cache in
+ * turn.
+ *
+ * To achieve laziness the actual work of parsing the available
+ * provider-configuration files and instantiating providers must be done by
+ * the iterator itself. Its hasNext and next methods can therefore throw a
+ * ServiceConfigurationError if a provider-configuration file violates the
+ * specified format, or if it names a provider class that cannot be found and
+ * instantiated, or if the result of instantiating the class is not
+ * assignable to the service type, or if any other kind of exception or error
+ * is thrown as the next provider is located and instantiated. To write
+ * robust code it is only necessary to catch ServiceConfigurationError when
+ * using a service iterator.
+ *
+ * If such an error is thrown then subsequent invocations of the iterator
+ * will make a best effort to locate and instantiate the next available
+ * provider, but in general such recovery cannot be guaranteed.
+ *
+ * Design Note Throwing an error in these cases may seem extreme. The
+ * rationale for this behavior is that a malformed provider-configuration
+ * file, like a malformed class file, indicates a serious problem with the
+ * way the Java virtual machine is configured or is being used. As such it is
+ * preferable to throw an error rather than try to recover or, even worse,
+ * fail silently.
+ *
+ * The iterator returned by this method does not support removal. Invoking
+ * its remove method will cause an UnsupportedOperationException to be
+ * thrown.
+ *
+ * @return An iterator that lazily loads providers for this loader's service
+ */
+ public Iterator<Metadata<S>> iterator()
+ {
+ if (providers == null)
+ {
+ reload();
+ }
+ return providers.iterator();
+ }
+
+ /**
+ * Returns a string describing this service.
+ *
+ * @return A descriptive string
+ */
+ @Override
+ public String toString()
+ {
+ return "Services for " + serviceFile;
+ }
+ }
+
+
+
private final JBossBeanDeploymentArchive beanDeploymentArchive;
private final List<BeanDeploymentArchive> beanDeploymentArchives;
private final ServiceRegistry services;
@@ -71,7 +439,7 @@
return services;
}
- public Iterable<Extension> getExtensions()
+ public Iterable<Metadata<Extension>> getExtensions()
{
return ServiceLoader.load(Extension.class);
}
Modified: branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossBeanDeploymentArchive.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossBeanDeploymentArchive.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossBeanDeploymentArchive.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -28,7 +28,7 @@
this.id = id;
}
- public Collection<Class<?>> getBeanClasses()
+ public Collection<String> getBeanClasses()
{
return environment.getWeldClasses();
}
Modified: branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryDeployer.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryDeployer.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryDeployer.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -53,6 +53,7 @@
setStage(DeploymentStages.PRE_REAL);
}
+ @Override
public void deploy(VFSDeploymentUnit unit, JBossWeldMetaData deployment) throws DeploymentException
{
@SuppressWarnings("unchecked")
Modified: branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -34,7 +34,7 @@
*/
public class WeldDiscoveryEnvironment
{
- private Set<Class<?>> classes = new HashSet<Class<?>>();
+ private Set<String> classes = new HashSet<String>();
private Set<URL> urls = new HashSet<URL>();
/**
@@ -44,7 +44,7 @@
*/
public void addWeldClass(Class<?> clazz)
{
- classes.add(clazz);
+ classes.add(clazz.getName());
}
/**
@@ -62,7 +62,7 @@
*
* @return the weld classes
*/
- public Collection<Class<?>> getWeldClasses()
+ public Collection<String> getWeldClasses()
{
// FIXME WELDINT-1 old classes that use this method should get an Unmodifiable
// collection; if those classes are not deleted this method needs to be reviewed
Modified: branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -69,7 +69,7 @@
}
// the classes contained in this archive
- private final Collection<Class<?>> classes;
+ private final Collection<String> classes;
// the bean.xml URLs contained in this archive
private final Collection<URL> xmlURLs;
@@ -118,7 +118,7 @@
*
* @return the classes contained in this archive
*/
- public Collection<Class<?>> getClasses()
+ public Collection<String> getClasses()
{
return classes;
}
@@ -161,7 +161,8 @@
*/
public void addClass(Class<?> beanClass)
{
- classes.add(beanClass);
+ // TODO Move this higher up the hierarchy, so we never load the class
+ classes.add(beanClass.getName());
}
/**
@@ -290,6 +291,7 @@
}
}
+ @Override
public String toString()
{
return "Archive[" + classLoader + "]";
Modified: branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -71,7 +71,7 @@
return archive.getClasspath().getBDAs(this);
}
- public Collection<Class<?>> getBeanClasses()
+ public Collection<String> getBeanClasses()
{
return archive.getClasses();
}
Modified: branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -26,7 +26,6 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.ServiceLoader;
import javax.enterprise.inject.spi.Extension;
@@ -36,6 +35,7 @@
import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.bootstrap.spi.Metadata;
import org.jboss.weld.ejb.spi.EjbDescriptor;
/**
@@ -63,6 +63,8 @@
private Collection<Archive> loadedArchives;
private Collection<EjbDescriptor<?>> ejbs;
+
+ private Iterable<Metadata<Extension>> extensions;
/**
* Constructor.
@@ -94,6 +96,7 @@
archive.createBeanDeploymentArchive(bootstrap, bdaServices);
}
}
+ extensions = bootstrap.loadExtensions(Thread.currentThread().getContextClassLoader());
}
public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
@@ -192,9 +195,9 @@
}
}
- public Iterable<Extension> getExtensions()
+ public Iterable<Metadata<Extension>> getExtensions()
{
- return ServiceLoader.load(Extension.class);
+ return extensions;
}
@Override
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/MockWeldBootstrap.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/MockWeldBootstrap.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/MockWeldBootstrap.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -23,11 +23,14 @@
import java.net.URL;
+import javax.enterprise.inject.spi.Extension;
+
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Environment;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.BeansXml;
import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.bootstrap.spi.Metadata;
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.manager.api.WeldManager;
@@ -125,4 +128,9 @@
// TODO Auto-generated method stub
return null;
}
+
+ public Iterable<Metadata<Extension>> loadExtensions(ClassLoader classLoader)
+ {
+ return null;
+ }
}
\ No newline at end of file
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/WeldDEWrapper.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/WeldDEWrapper.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/WeldDEWrapper.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -41,13 +41,13 @@
this.deployment = deployment;
}
- public Iterable<Class<?>> discoverWebBeanClasses()
+ public Iterable<String> discoverWebBeanClasses()
{
- Set<Class<?>> result = new HashSet<Class<?>>();
+ Set<String> result = new HashSet<String>();
Collection<BeanDeploymentArchive> bdas = deployment.getBeanDeploymentArchives();
for (BeanDeploymentArchive bda : bdas)
{
- for (Class<?> clazz : bda.getBeanClasses())
+ for (String clazz : bda.getBeanClasses())
result.add(clazz);
}
return result;
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -85,11 +85,11 @@
assertEquals(getExpectedArchives(), archives.size());
//List<BeansXml> urls = new ArrayList<BeansXml>();
- List<Class<?>> classes = new ArrayList<Class<?>>();
+ List<String> classes = new ArrayList<String>();
for (BeanDeploymentArchive bad : archives)
{
//urls.add(bad.getBeansXml());
- for (Class<?> clazz : bad.getBeanClasses())
+ for (String clazz : bad.getBeanClasses())
classes.add(clazz);
}
@@ -130,8 +130,8 @@
assertEquals("Illegal size or classes.", classes.size(), expected.size());
- for (Class<?> clazz : classes)
- assertTrue(expected.remove(clazz.getName()));
+ for (String className : classes)
+ assertTrue(expected.remove(className));
assertEmpty("Should be emtpy, missing " + expected, expected);
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -59,12 +59,12 @@
private void assertExpectedClasses(E environment, Set<String> expected)
{
- Collection<Class<?>> weldClasses = getClasses(environment);
+ Collection<String> weldClasses = getClasses(environment);
assertNotNull(weldClasses);
assertTrue("Unexpected empty weld classes collection", expected.isEmpty() || !weldClasses.isEmpty());
- for (Class<?> clazz : weldClasses)
+ for (String className : weldClasses)
{
- assertTrue("Found unexpected class: " + clazz.getName(), expected.remove(clazz.getName()));
+ assertTrue("Found unexpected class: " + className, expected.remove(className));
}
assertEmpty("Should be emtpy, missing " + expected, expected);
}
@@ -146,5 +146,5 @@
* @param environment the environment
* @return the list of classes that have been found in the environment
*/
- protected abstract Collection<Class<?>> getClasses(E environment);
+ protected abstract Collection<String> getClasses(E environment);
}
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -223,7 +223,7 @@
}
@Override
- protected Collection<Class<?>> getClasses(
+ protected Collection<String> getClasses(
WeldDiscoveryEnvironment environment)
{
return environment.getWeldClasses();
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -886,7 +886,7 @@
}
@Override
- protected Collection<Class<?>> getClasses(BeanDeploymentArchive bda)
+ protected Collection<String> getClasses(BeanDeploymentArchive bda)
{
return bda.getBeanClasses();
}
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/WeldDiscoveryEnvTestCase.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/WeldDiscoveryEnvTestCase.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/WeldDiscoveryEnvTestCase.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -27,6 +27,7 @@
import java.util.Set;
import junit.framework.Test;
+
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.test.deployers.support.crm.CrmWebBean;
import org.jboss.test.deployers.support.ejb.BusinessInterface;
@@ -101,8 +102,8 @@
addExpectedClass(expected, ServletWebBean.class);
addExpectedClass(expected, CrmWebBean.class);
- for (Class<?> clazz : wbDiscovery.getWeldClasses())
- assertTrue(expected.remove(clazz.getName()));
+ for (String className : wbDiscovery.getWeldClasses())
+ assertTrue(expected.remove(className));
assertEmpty("Should be emtpy, missing " + expected, expected);
}
Modified: branches/weld-snapshot/weld-int/deployer-mc-int/src/test/java/org/jboss/test/deployers/test/AbstractWeldTest.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer-mc-int/src/test/java/org/jboss/test/deployers/test/AbstractWeldTest.java 2010-08-28 14:39:19 UTC (rev 107876)
+++ branches/weld-snapshot/weld-int/deployer-mc-int/src/test/java/org/jboss/test/deployers/test/AbstractWeldTest.java 2010-08-28 18:57:22 UTC (rev 107877)
@@ -90,17 +90,17 @@
.addPath(metaInfParent);
}
- protected Class<?> findClass(DeploymentUnit unit, String name, boolean mustFind)
+ protected Class<?> findClass(DeploymentUnit unit, String name, boolean mustFind) throws ClassNotFoundException
{
//The class is loaded by a different classloader, so search for the correct class
FlatDeployment flatDeployment = (FlatDeployment)getBean(DeployersUtils.getDeploymentBeanName(unit));
assertNotNull(flatDeployment);
Class<?> found = null;
- for (Class<?> current : flatDeployment.getFlatBeanDeploymentArchive().getBeanClasses())
+ for (String current : flatDeployment.getFlatBeanDeploymentArchive().getBeanClasses())
{
- if (name.equals(current.getName()))
+ if (name.equals(current))
{
- found = current;
+ found = unit.getClassLoader().loadClass(current);
break;
}
}
More information about the jboss-cvs-commits
mailing list