Skip to content

Commit

Permalink
Merge EjbModule -> BeanDeploymentArchive
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@3023 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Jul 7, 2009
1 parent 46f9a14 commit c02587b
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 141 deletions.
Expand Up @@ -23,8 +23,8 @@
import javax.enterprise.inject.spi.BeforeShutdown;
import javax.enterprise.inject.spi.Extension;

import org.jboss.webbeans.ContextualIdStore;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.ContextualIdStore;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.DeploymentException;
Expand Down Expand Up @@ -53,7 +53,6 @@
import org.jboss.webbeans.conversation.ServletConversationManager;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.ejb.spi.EJBModule;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.jsf.JsfApiAbstraction;
Expand Down Expand Up @@ -120,13 +119,9 @@ private void visit(BeanDeploymentArchive beanDeploymentArchive)
{
beansXmlUrls.add(url);
}
if (beanDeploymentArchive instanceof EJBModule)
for (EjbDescriptor<?> ejbDescriptor : beanDeploymentArchive.getEjbs())
{
EJBModule ejbModule = (EJBModule) beanDeploymentArchive;
for (EjbDescriptor<?> ejbDescriptor : ejbModule.getEjbs())
{
ejbDescriptors.add(ejbDescriptor);
}
ejbDescriptors.add(ejbDescriptor);
}
for (BeanDeploymentArchive archive : beanDeploymentArchive.getBeanDeploymentArchives())
{
Expand Down
Expand Up @@ -19,7 +19,7 @@
import java.net.URL;
import java.util.List;

import org.jboss.webbeans.ejb.spi.EJBModule;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;

/**
* Represents a CDI bean deployment archive.
Expand All @@ -39,7 +39,6 @@
* container could define a deployment archive with container specific metadata
* to be a bean deployment archive).
*
* @see EJBModule
* @see Deployment
*
* @author Pete Muir
Expand Down Expand Up @@ -80,4 +79,12 @@ public interface BeanDeploymentArchive
*/
public Iterable<URL> getBeansXml();

/**
* Get all the EJBs in the deployment archive
*
* @return an iteration of the EJBs, or empty if no EJBs are present or if
* this is not an EJB archive
*/
public Iterable<EjbDescriptor<?>> getEjbs();

}
Expand Up @@ -19,7 +19,6 @@
import java.util.List;

import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.ejb.spi.EJBModule;

/**
* Represents a deployment of a CDI application.
Expand All @@ -45,7 +44,6 @@
* TODO Java SE structure
*
* @see BeanDeploymentArchive
* @see EJBModule
*
* @author Pete Muir
*
Expand Down
46 changes: 0 additions & 46 deletions spi/src/main/java/org/jboss/webbeans/ejb/spi/EJBModule.java

This file was deleted.

Expand Up @@ -17,11 +17,19 @@
package org.jboss.webbeans.mock;

import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.ejb.MessageDriven;
import javax.ejb.Singleton;
import javax.ejb.Stateful;
import javax.ejb.Stateless;

import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;

/**
* @author pmuir
Expand All @@ -45,11 +53,6 @@ public Iterable<URL> getBeansXml()
return webBeansXmlFiles;
}

public void setBeanClasses(Iterable<Class<?>> webBeanClasses)
{
this.beanClasses = webBeanClasses;
}

public void setWebBeansXmlFiles(Iterable<URL> webBeansXmlFiles)
{
this.webBeansXmlFiles = webBeansXmlFiles;
Expand All @@ -59,5 +62,35 @@ public List<BeanDeploymentArchive> getBeanDeploymentArchives()
{
return Collections.emptyList();
}

private List<EjbDescriptor<?>> ejbs;

public void setBeanClasses(Iterable<Class<?>> beanClasses)
{
this.beanClasses = beanClasses;
ejbs = new ArrayList<EjbDescriptor<?>>();
for (Class<?> ejbClass : discoverEjbs(getBeanClasses()))
{
ejbs.add(MockEjbDescriptor.of(ejbClass));
}
}

public Iterable<EjbDescriptor<?>> getEjbs()
{
return ejbs;
}

protected static Iterable<Class<?>> discoverEjbs(Iterable<Class<?>> webBeanClasses)
{
Set<Class<?>> ejbs = new HashSet<Class<?>>();
for (Class<?> clazz : webBeanClasses)
{
if (clazz.isAnnotationPresent(Stateless.class) || clazz.isAnnotationPresent(Stateful.class) || clazz.isAnnotationPresent(MessageDriven.class) || clazz.isAnnotationPresent(Singleton.class))
{
ejbs.add(clazz);
}
}
return ejbs;
}

}
12 changes: 6 additions & 6 deletions tests/src/main/java/org/jboss/webbeans/mock/MockDeployment.java
Expand Up @@ -25,15 +25,15 @@
public class MockDeployment implements Deployment
{

private MockEjbModule ejbModule;
private MockBeanDeploymentArchive archive;

private List<BeanDeploymentArchive> beanDeploymentArchives;

public MockDeployment()
{
this.ejbModule = new MockEjbModule();
this.archive = new MockBeanDeploymentArchive();
this.beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
this.beanDeploymentArchives.add(ejbModule);
this.beanDeploymentArchives.add(archive);
}

public List<BeanDeploymentArchive> getBeanDeploymentArchives()
Expand All @@ -43,12 +43,12 @@ public List<BeanDeploymentArchive> getBeanDeploymentArchives()

public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
{
return ejbModule;
return archive;
}

public MockEjbModule getEjbModule()
public MockBeanDeploymentArchive getArchive()
{
return ejbModule;
return archive;
}

}
70 changes: 0 additions & 70 deletions tests/src/main/java/org/jboss/webbeans/mock/MockEjbModule.java

This file was deleted.

Expand Up @@ -20,7 +20,7 @@ public boolean deploy(Iterable<Class<?>> classes, Iterable<URL> beansXml)
lifecycle.initialize();
try
{
MockBeanDeploymentArchive archive = lifecycle.getDeployment().getEjbModule();
MockBeanDeploymentArchive archive = lifecycle.getDeployment().getArchive();
archive.setBeanClasses(classes);
if (beansXml != null)
{
Expand Down
Expand Up @@ -28,7 +28,7 @@ public void beforeClass() throws Throwable
{
lifecycle = new MockServletLifecycle();
lifecycle.initialize();
MockBeanDeploymentArchive archive = lifecycle.getDeployment().getEjbModule();
MockBeanDeploymentArchive archive = lifecycle.getDeployment().getArchive();
archive.setBeanClasses(Arrays.asList(Animal.class, DeadlyAnimal.class, DeadlySpider.class, DeadlyAnimal.class, Hound.class, HoundLocal.class, Salmon.class, ScottishFish.class, SeaBass.class, Sole.class, Spider.class, Tarantula.class, TarantulaProducer.class, Tuna.class));
lifecycle.beginApplication();
lifecycle.beginSession();
Expand Down

0 comments on commit c02587b

Please sign in to comment.