mardi 21 avril 2015

@PostConstruct of abstract ancestors are not invoked

I'm writing a JAX-RS library (not an application).

I my src/main/java, I have.

public abstract class A {

    @PostConstruct private void constructed_a() {} // not invoked
}


public abstract class B extends A {

    @PostConstruct private void constructed_b() {} // not invoked
}

In my src/test/java, I have.

@Path("c")
public class C extends B {

    @PostConstrct private void constructed_c() {} // invoked
}

I'm testing with jersey test framework.

<dependency>
  <groupId>org.glassfish.jersey.test-framework.providers</groupId>
  <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
  <version>2.17</version>
  <scope>test</scope>
</dependency>

I found that only constructed_c() is invoked and those method defined in ancestors are not invoked.

Is this normal? What should I do?

Aucun commentaire:

Enregistrer un commentaire