javaee / ejb-spec

See javax.ejb project for API. Contains legacy issues only.
https://github.com/javaee/javax.ejb
6 stars 1 forks source link

Decoupling the @Startup/@DependsOn annotations from the EJB component model #19

Open glassfishrobot opened 13 years ago

glassfishrobot commented 13 years ago

Currently the EJB @Startup/@DependsOn annotations can only be used with @Singleton beans. The @Startup/@DependsOn annotations are actually a very useful and elegant way of declaratively listening to the container life-cycle and managing component inter-dependency. With the introduction of managed beans and CDI, there are not many good technical reasons why the @Startup/@DependsOn annotations should not be used in managed beans as well. Decoupling useful EJB services such as @Startup/@DependsOn from the component model moves towards removing one-off component models in Java EE in favor of unifying around managed beans/CDI.

We currently allow this capability in Resin. The code looks like this:

@ApplicationScoped @Startup @DependsOn(...) public class MyStartupBean { ... @PostConstruct public void init()

{ ... } ... @PreDestroy public void destroy() { ... }

... }

It should also be possible to use @Startup/@DependsOn in CDI stereotypes so that developers can compose custom component types to meet the needs of their individual applications. The code for this could look like the following:

@ApplicationScoped @Stereotype @Retention(RUNTIME) @Target(TYPE) @Startup @DependsOn(...) public @interface StartupComponent {}

Affected Versions

[3.2]

glassfishrobot commented 13 years ago

Reported by reza_rahman

glassfishrobot commented 11 years ago

reza_rahman said: One logical place for decoupled @Startup/@DependsOn annotations could be the common annotations JSR.

glassfishrobot commented 13 years ago

Was assigned to mvatkina

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA EJB_SPEC-19