Can CDI be lessened towards Java SE?

China☆狼群 提交于 2019-12-21 11:28:35

问题


JSR-330 dependency injection can be applied to both Java SE and Java EE environments, while JSR-299 is titled "Contexts and Dependency Injection for the Java EE platform".

Except strictly Java EE-oriented features, what CDI features make sense on Java SE as well? Any examples available? Thanks!

[Revised] Here's Weld on JSE.


回答1:


Except strictly Java EE-oriented features, what CDI features make sense on Java SE as well? Any examples available? Thanks!

Well, the one mentioned in the Weld documentation:

18.4. Java SE

In addition to improved integration of the Enterprise Java stack, the "Contexts and Dependency Injection for the Java EE platform" specification also defines a state of the art typesafe, stateful dependency injection framework, which can prove useful in a wide range of application types. To help developers take advantage of this, Weld provides a simple means for being executed in the Java Standard Edition (SE) environment independently of any Java EE APIs.

When executing in the SE environment the following features of Weld are available:

  • Managed beans with @PostConstruct and @PreDestroy lifecycle callbacks
  • Dependency injection with qualifiers and alternatives
  • @Application, @Dependent and @Singleton scopes
  • Interceptors and decorators
  • Stereotypes
  • Events

This obviously makes sense in a Java SE context.




回答2:


see openwebbeans.apache.org



来源:https://stackoverflow.com/questions/3575211/can-cdi-be-lessened-towards-java-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!