Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update SPI to include BeansXml, WELD-560

  • Loading branch information...
commit 04270175ce0de2d0a2f763e128fc62e54b1280bc 1 parent 2a6fde9
@pmuir pmuir authored
View
23 weld-spi/src/main/java/org/jboss/weld/bootstrap/api/Bootstrap.java
@@ -16,6 +16,8 @@
*/
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;
@@ -23,6 +25,7 @@
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;
@@ -133,5 +136,25 @@
* @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);
}
View
19 weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/BeanDeploymentArchive.java
@@ -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;
@@ -71,15 +71,18 @@
/**
* 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
View
42 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();
+
+}
View
4 weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/helpers/ForwardingBeanDeploymentArchive.java
@@ -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;
/**
@@ -41,7 +41,7 @@
return delegate().getBeanDeploymentArchives();
}
- public Collection<URL> getBeansXml()
+ public BeansXml getBeansXml()
{
return delegate().getBeansXml();
}
View
11 weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/BootstrapTest.java
@@ -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());
@@ -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());
@@ -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());
@@ -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());
@@ -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());
@@ -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());
@@ -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());
@@ -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());
@@ -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());
@@ -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);
@@ -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));
View
14 weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockBootstrap.java
@@ -16,6 +16,9 @@
*/
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;
@@ -23,6 +26,7 @@
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;
@@ -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;
+ }
}
View
8 weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockDeployment.java
@@ -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;
@@ -53,9 +55,9 @@ public MockBeanDeploymentArchive(ServiceRegistry services)
return Collections.emptySet();
}
- public Collection<URL> getBeansXml()
+ public BeansXml getBeansXml()
{
- return Collections.emptySet();
+ return EMPTY_BEANS_XML;
}
public Collection<EjbDescriptor<?>> getEjbs()
Please sign in to comment.
Something went wrong with that request. Please try again.