Skip to content

Commit

Permalink
Update SPI to include BeansXml, WELD-560
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Aug 16, 2010
1 parent 2a6fde9 commit 0427017
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 13 deletions.
23 changes: 23 additions & 0 deletions weld-spi/src/main/java/org/jboss/weld/bootstrap/api/Bootstrap.java
Expand Up @@ -16,13 +16,16 @@
*/
package org.jboss.weld.bootstrap.api;

import java.net.URL;

import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.AfterDeploymentValidation;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.BeforeShutdown;
import javax.enterprise.inject.spi.Extension;

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.context.api.BeanStore;
import org.jboss.weld.manager.api.WeldManager;
Expand Down Expand Up @@ -133,5 +136,25 @@ public interface Bootstrap
* @return the manager or null if not yet available or not found.
*/
public WeldManager getManager(BeanDeploymentArchive beanDeploymentArchive);

/**
* Parse the specified URL as a beans.xml file.
*
* @param url the url to parse
* @return the BeansXml data structure which represents the URL
* @throws IllegalArgumentException if the URL cannot be opened
*/
public BeansXml parse(URL url);

/**
* Parse the specified URLs as a series of beans.xml file and merge the result.
*
* Duplicate entries are not removed.
*
* @param url the url to parse
* @return the BeansXml data structure which represents the URL
* @throws IllegalArgumentException if the URL cannot be opened
*/
public BeansXml parse(Iterable<URL> urls);

}
Expand Up @@ -16,9 +16,9 @@
*/
package org.jboss.weld.bootstrap.spi;

import java.net.URL;
import java.util.Collection;

import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.ejb.spi.EjbDescriptor;

Expand Down Expand Up @@ -71,15 +71,18 @@ public interface BeanDeploymentArchive
/**
* Get any deployment descriptors in the bean deployment archive.
*
* The container will normally return a single deployment descriptor per bean
* deployment archive (the physical META-INF/beans.xml or WEB-INF/beans.xml),
* however it is permitted to return other deployment descriptors defined
* using other methods.
* The container will return a a merged view of the beans.xml per bean
* deployment archive. This will normally represent a single file such as the
* physical META-INF/beans.xml or WEB-INF/beans.xml)
*
* @return the URLs pointing to the deployment descriptor,
* or an empty set if none are present
* The container may choose to parse beans.xml itself, or it may use Weld to
* parse beans.xml
*
* @return the parsed beans.xml
* @see {@link Bootstrap#parse(java.net.URL)}
* @see {@link Bootstrap#parse(Iterable)}
*/
public Collection<URL> getBeansXml();
public BeansXml getBeansXml();

/**
* Get all the EJBs in the deployment archive
Expand Down
42 changes: 42 additions & 0 deletions weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/BeansXml.java
@@ -0,0 +1,42 @@
package org.jboss.weld.bootstrap.spi;

import static java.util.Collections.emptyList;

import java.util.List;

public interface BeansXml
{

public static final BeansXml EMPTY_BEANS_XML = new BeansXml()
{

public List<String> getEnabledInterceptors()
{
return emptyList();
}

public List<String> getEnabledDecorators()
{
return emptyList();
}

public List<String> getEnabledAlternativeStereotypes()
{
return emptyList();
}

public List<String> getEnabledAlternativeClasses()
{
return emptyList();
}
};

public List<String> getEnabledAlternativeStereotypes();

public List<String> getEnabledAlternativeClasses();

public List<String> getEnabledDecorators();

public List<String> getEnabledInterceptors();

}
Expand Up @@ -16,10 +16,10 @@
*/
package org.jboss.weld.bootstrap.spi.helpers;

import java.net.URL;
import java.util.Collection;

import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.BeansXml;
import org.jboss.weld.ejb.spi.EjbDescriptor;

/**
Expand All @@ -41,7 +41,7 @@ public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
return delegate().getBeanDeploymentArchives();
}

public Collection<URL> getBeansXml()
public BeansXml getBeansXml()
{
return delegate().getBeansXml();
}
Expand Down
Expand Up @@ -50,6 +50,7 @@ public void testMissingEjbServices()
deploymentServices.add(ServletServices.class, new MockServletServices());
deploymentServices.add(ScheduledExecutorServiceFactory.class, new MockScheduledExecutorServiceFactory());


bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
Expand All @@ -71,6 +72,7 @@ public void testMissingEjbInjectionServices()
deploymentServices.add(ServletServices.class, new MockServletServices());
deploymentServices.add(ScheduledExecutorServiceFactory.class, new MockScheduledExecutorServiceFactory());


bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());

Expand All @@ -91,6 +93,7 @@ public void testMissingJpaServices()
deploymentServices.add(EjbServices.class, new MockEjbServices());
deploymentServices.add(ScheduledExecutorServiceFactory.class, new MockScheduledExecutorServiceFactory());


ServiceRegistry bdaServices = new SimpleServiceRegistry();

bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
Expand All @@ -113,6 +116,7 @@ public void testMissingSecurityServices()
deploymentServices.add(EjbServices.class, new MockEjbServices());
deploymentServices.add(ScheduledExecutorServiceFactory.class, new MockScheduledExecutorServiceFactory());


ServiceRegistry bdaServices = new SimpleServiceRegistry();

bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
Expand All @@ -135,6 +139,7 @@ public void testMissingValidationServices()
deploymentServices.add(EjbServices.class, new MockEjbServices());
deploymentServices.add(ScheduledExecutorServiceFactory.class, new MockScheduledExecutorServiceFactory());


ServiceRegistry bdaServices = new SimpleServiceRegistry();
bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
Expand All @@ -157,6 +162,7 @@ public void testEEEnv()
deploymentServices.add(EjbServices.class, new MockEjbServices());
deploymentServices.add(ScheduledExecutorServiceFactory.class, new MockScheduledExecutorServiceFactory());


ServiceRegistry bdaServices = new SimpleServiceRegistry();
bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
Expand All @@ -178,6 +184,7 @@ public void testMissingTxServices()
deploymentServices.add(EjbServices.class, new MockEjbServices());
deploymentServices.add(ScheduledExecutorServiceFactory.class, new MockScheduledExecutorServiceFactory());


ServiceRegistry bdaServices = new SimpleServiceRegistry();
bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
Expand All @@ -200,6 +207,7 @@ public void testMissingResourceServices()
deploymentServices.add(EjbServices.class, new MockEjbServices());
deploymentServices.add(ScheduledExecutorServiceFactory.class, new MockScheduledExecutorServiceFactory());


ServiceRegistry bdaServices = new SimpleServiceRegistry();
bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
Expand Down Expand Up @@ -241,6 +249,7 @@ public void testMissingScheduledExecutorServiceFactory()
deploymentServices.add(EjbServices.class, new MockEjbServices());
deploymentServices.add(ServletServices.class, new MockServletServices());


ServiceRegistry bdaServices = new SimpleServiceRegistry();
bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
Expand All @@ -257,6 +266,7 @@ public void testSEEnv()
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
deploymentServices.add(ScheduledExecutorServiceFactory.class, new MockScheduledExecutorServiceFactory());

ServiceRegistry bdaServices = new SimpleServiceRegistry();
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
bootstrap.startContainer(Environments.SE, deployment, null);
Expand All @@ -269,6 +279,7 @@ public void testServletEnv()
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
deploymentServices.add(ServletServices.class, new MockServletServices());

deploymentServices.add(ScheduledExecutorServiceFactory.class, new MockScheduledExecutorServiceFactory());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
Expand Down
Expand Up @@ -16,13 +16,17 @@
*/
package org.jboss.weld.bootstrap.api.test;

import static org.jboss.weld.bootstrap.spi.BeansXml.EMPTY_BEANS_XML;

import java.net.URL;
import java.util.Set;

import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Environment;
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
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.context.api.BeanStore;
import org.jboss.weld.manager.api.WeldManager;
Expand Down Expand Up @@ -76,6 +80,16 @@ public Bootstrap startContainer(Environment environment, Deployment deployment,
verifyServices(deployment.getBeanDeploymentArchives().iterator().next().getServices(), environment.getRequiredBeanDeploymentArchiveServices());
return this;
}

public BeansXml parse(URL url)
{
return EMPTY_BEANS_XML;
}

public BeansXml parse(Iterable<URL> urls)
{
return EMPTY_BEANS_XML;
}


}
Expand Up @@ -16,13 +16,15 @@
*/
package org.jboss.weld.bootstrap.api.test;

import java.net.URL;
import static org.jboss.weld.bootstrap.spi.BeansXml.EMPTY_BEANS_XML;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.jboss.weld.bootstrap.api.ServiceRegistry;
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.ejb.spi.EjbDescriptor;

Expand Down Expand Up @@ -53,9 +55,9 @@ public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
return Collections.emptySet();
}

public Collection<URL> getBeansXml()
public BeansXml getBeansXml()
{
return Collections.emptySet();
return EMPTY_BEANS_XML;
}

public Collection<EjbDescriptor<?>> getEjbs()
Expand Down

0 comments on commit 0427017

Please sign in to comment.