Skip to content

Commit

Permalink
WELD-560, upgrade Arquillian container to use BeansXml
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Aug 17, 2010
1 parent c8e9d0e commit bdcd00f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
Expand Up @@ -71,6 +71,7 @@ public ContainerMethodExecutor deploy(Context context, Archive<?> archive) throw

ShrinkwrapBeanDeploymentArchive beanArchive = archive.as(ShrinkwrapBeanDeploymentArchive.class);
MockEELifecycle lifecycle = new MockEELifecycle(beanArchive);
beanArchive.setBootstrap(lifecycle.getBootstrap());

ContextClassLoaderManager classLoaderManager = new ContextClassLoaderManager(beanArchive.getClassLoader());
classLoaderManager.enable();
Expand Down
Expand Up @@ -16,7 +16,6 @@
*/
package org.jboss.arquillian.container.weld.ee.embedded_1_1.mock;

import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -33,6 +32,7 @@
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.BeansXml;
import org.jboss.weld.ejb.spi.EjbDescriptor;

/**
Expand All @@ -44,7 +44,7 @@ public class MockBeanDeploymentArchive implements BeanDeploymentArchive


private Collection<Class<?>> beanClasses;
private Collection<URL> beansXmlFiles;
private BeansXml beansXml;
private List<EjbDescriptor<?>> ejbs;
private final ServiceRegistry services;
private final Collection<BeanDeploymentArchive> bdas;
Expand All @@ -59,7 +59,6 @@ public MockBeanDeploymentArchive(String id, Class<?> ... classes)
{
this.services = new SimpleServiceRegistry();
this.beanClasses = Arrays.asList(classes);
this.beansXmlFiles = new HashSet<URL>();
this.bdas = new HashSet<BeanDeploymentArchive>();
this.id = id;
}
Expand All @@ -79,16 +78,16 @@ public void setBeanClasses(Collection<Class<?>> beanClasses)
}
}

public Collection<URL> getBeansXml()
public BeansXml getBeansXml()
{
return beansXmlFiles;
return beansXml;
}

public void setBeansXmlFiles(Collection<URL> beansXmlFiles)
public void setBeansXml(BeansXml beansXml)
{
this.beansXmlFiles = beansXmlFiles;
this.beansXml = beansXml;
}

public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
{
return bdas;
Expand Down
Expand Up @@ -18,6 +18,7 @@

import org.jboss.shrinkwrap.api.Assignable;
import org.jboss.shrinkwrap.classloader.ShrinkWrapClassLoader;
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;

/**
Expand All @@ -29,4 +30,7 @@
public interface ShrinkwrapBeanDeploymentArchive extends BeanDeploymentArchive, Assignable
{
ShrinkWrapClassLoader getClassLoader();

void setBootstrap(Bootstrap bootstrap);

}
Expand Up @@ -44,9 +44,11 @@
import org.jboss.shrinkwrap.impl.base.AssignableBase;
import org.jboss.shrinkwrap.impl.base.Validate;
import org.jboss.shrinkwrap.impl.base.asset.ArchiveAsset;
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.BeansXml;
import org.jboss.weld.ejb.spi.EjbDescriptor;

/**
Expand All @@ -62,12 +64,12 @@ public class ShrinkwrapBeanDeploymentArchiveImpl extends AssignableBase implemen
private ServiceRegistry serviceRegistry = new SimpleServiceRegistry();

private ShrinkWrapClassLoader classLoader;
private Bootstrap bootstrap;

public ShrinkwrapBeanDeploymentArchiveImpl(Archive<?> archive)
{
Validate.notNull(archive, "Archive must be specified");
this.archive = archive;

this.classLoader = new ShrinkWrapClassLoader(archive.getClass().getClassLoader(), archive);
}

Expand All @@ -81,6 +83,11 @@ public ShrinkWrapClassLoader getClassLoader()
{
return classLoader;
}

public void setBootstrap(Bootstrap bootstrap)
{
this.bootstrap = bootstrap;
}

public String getId()
{
Expand All @@ -92,8 +99,12 @@ public ServiceRegistry getServices()
return serviceRegistry;
}

public Collection<URL> getBeansXml()
public BeansXml getBeansXml()
{
if (bootstrap == null)
{
throw new IllegalStateException("must call setBootstrap() before calling getBeansXml()");
}
List<URL> beanClasses = new ArrayList<URL>();
Map<ArchivePath, Node> nestedArchives = archive.getContent(Filters.include(".*\\.jar|.*\\.war"));
for(final Map.Entry<ArchivePath, Node> nestedArchiveEntry : nestedArchives.entrySet())
Expand Down Expand Up @@ -164,7 +175,7 @@ public InputStream getInputStream()
e.printStackTrace();
}
}
return beanClasses;
return bootstrap.parse(beanClasses);
}

public Collection<Class<?>> getBeanClasses()
Expand Down

0 comments on commit bdcd00f

Please sign in to comment.