Add test to verify visibly of beans registered explicitly through an extension 
in non-bean archives
---------------------------------------------------------------------------------------------------

                 Key: CDITCK-206
                 URL: https://issues.jboss.org/browse/CDITCK-206
             Project: CDI TCK
          Issue Type: Feature Request
      Security Level: Public (Everyone can see)
          Components: Tests
    Affects Versions: 1.0.4.Final
            Reporter: Dan Allen


Add a test that answers this question:

Can an extension register a bean programmatically for a class that resides in 
another non-bean archive?

This question requires a short example which is available in the OpenTCK test 
suite and may be ported to the CDI TCK [1].

Assume one archive, a.jar, has the following contents:

org/opentck/javaee/cdi/spi/beforebeandiscovery/BeanClassToRegister.class

A second archive, b.jar, has the following contents:

org/opentck/javaee/cdi/spi/beforebeandiscovery/AnotherBeanClassToRegister.class
org/opentck/javaee/cdi/spi/beforebeandiscovery/AnotherManualBeanRegistrationExtension.class
org/opentck/javaee/cdi/spi/beforebeandiscovery/ManualBeanRegistrationExtension.class
META-INF/services/javax.enterprise.inject.spi.Extension

AnotherBeanClassToRegister has an injection point of type BeanClassToRegister:

public class AnotherBeanClassToRegister {
   @Inject
   private BeanClassToRegister collaborator;
}

BeanClassToRegister and AnotherBeanClassToRegister are added as beans 
programmatically in respective extensions listed in the service provider 
descriptor:

public class ManualBeanRegistrationExtension implements Extension {
   public void registerBeans(@Observes BeforeBeanDiscovery event, BeanManager 
bm) {
      event.addAnnotatedType(bm.createAnnotatedType(BeanClassToRegister.class));
   }
}

public class AnotherManualBeanRegistrationExtension implements Extension {
   public void registerBeans(@Observes BeforeBeanDiscovery event, BeanManager 
bm) {
      
event.addAnnotatedType(bm.createAnnotatedType(AnotherBeanClassToRegister.class));
   }
}

The two libraries, a.jar and b.jar are bundled in a web archive, test.war

WEB-INF/lib/a.jar
WEB-INF/lib/b.jar
WEB-INF/beans.xml

Deploying this archive to the reference implementation fails with an error 
message that the injection point from above cannot be satisfied. There appears 
to be a visibility problem across bean archives in this case.

Adding META-INF/beans.xml to a.jar and removing the 
ManualBeanRegistrationExtension from b.jar resolves the issue in the reference 
implementation.

[1] 
https://github.com/opentck/javaee_cdi/tree/master/src/test/java/org/opentck/javaee/cdi/spi/beforebeandiscovery

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
weld-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/weld-issues

Reply via email to