CDI: bean -discovery-mode = annotated is ignored

I am using welding as a CDI container. Also, I am using osgi (felix). So this is javase + felix + weld + pax. I have the following beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"
       bean-discovery-mode="annotated">
</beans>

      

And I have two classes:

@ApplicationScoped
public class A {
  @Inject
  private B b;
  public void postCreate(@Observes ContainerInitialized event, BundleContext ctx) {
   b.test();
  }
}

      

And class B

public class B{
  public void test(){
  System.out.println("test is here");
  }
}

      

As you can see, class B does not have any @scopes or @dependent annotations. However, when I run the application object of class B, it is inserted into the object A and the test method is called. What for? As far as I understand, it cannot be entered.

EDIT 1
I tried using version 1.1:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
        http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="annotated" version="1.1">
</beans>

      

but it did not help.

+3


source to share


2 answers


I wrote about this to weld the mailing list and this is what Jozef Hartinger (one of the main welder developers) wrote



It seems that Pax CDI only implements explicit bean archives. I submitted the question at https://ops4j1.jira.com/browse/PAXCDI-186 You will need to tag the classes / packages you don't want to open with @Vetod or use the exclusion filter http://docs.jboss.org/ cdi / spec / 1.2 / cdi-spec.html # exclude_filters

0


source


You must specify version 1.1 in beans.xml.

version="1.1" bean-discovery-mode="annotated"

      



Your bean deployment archive is now an explicit weld archive.
More details: enter link here

0


source







All Articles