@DependsOn
can be used to ensure that one EJB is initialized before another EJB:
@Startup @Singleton
public class SchemaMigration {
// ...
}
@DependsOn("SchemaMigration")
public class Crud<E extends BaseEntity> {
// ...
}
I'm wondering whether subclasses also implicitly inherit this constraint?
@Startup @Singleton
public class Birds extends Crud<Bird> {
// ...
}
@Startup @Singleton
public class Frogs extends Crud<Frog> {
// ...
}
I know that plain Java annotations are not inherited, but Java EE changes the rules for some annotations. But I haven't found specific informations about the @DependsOn
annotation.
DependsOn
does not ensure, that one EJB is initialized before another EJB.Please refer to the
DependsOn
Javadoc:This does only work for concrete instances of singleton EJBs using the ejb-name of the referenced singleton.
Regarding inheritance of session beans, the EJB spec (4.9.2.1) says: