- 浏览: 164532 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
ooo456mmm:
正解~~~
无需安装oracle,配置plsql developer -
tjuking:
帮我解决了一大问题,thx~
vim批量修改文件 解决 非法字符: \65279 问题 -
dou85dou:
where is lz's content?
如何打造Linux下的IDE
转自 :http://stackoverflow.com/questions/2930889/are-managedbeans-obsolete-in-javaee6-because-of-named-in-cdi-weld
一句话,如果是使用jsf 2.0,但是不使用CDI,那么你需要managedBean。否则直接用CDI就行,忘了managedBean吧。
Re: Comparisons to @ManagedBean annotations in JSF2?:
While looking through the Weld examples, and the older WebBeans documentation, it looks like a competitor to the new @ManagedBean JSF 2.0 annotations. Is there any information on when we'd want to use one over the other?
It's a good question, and I'm not really in full agreement with the answers that have been posted so far.
The new EE Managed Beans specification defines a base component model for Java EE, together with a very basic set of container services (@Resource, @PostConstruct, @PreDestroy).
The idea is that other specifications (beginning with EJB, CDI, JSF and the new Java Interceptors spec) build upon this base component model and layer additional services, for example transaction management, typesafe dependency injection, interceptors. So at this level, the managed beans, CDI, interceptors and EJB specifications all work hand-in-hand and are highly complementary.
Now, the Managed Beans specification is quite open-ended with respect to identifying exactly which classes are managed beans. It does provide the @ManagedBean annotation as one mechanism, but it also allows other specifications to define different mechanisms. So, for example:
The EJB specification says that a class obeying certain programming restrictions with a @Stateless or @Stateful annotation deployed in an EJB jar is a managed bean.
The CDI specification says that any class with an appropriate constructor deployed in a "bean deployment archive" is a managed bean.
Given that EJB and CDI provide arguably more convenient ways to identify a managed bean, you might wonder precisely what @ManagedBean is needed for. The answer, as alluded to by Dan, is that if you have CDI available in your environment (for example, if you are using EE6), then @ManagedBean is just not really needed. @ManagedBean is really there for use by people who are using JSF2 without CDI.
OTOH, if you do annotate a bean @ManagedBean, and you do have CDI in your environment, you can still use CDI to inject stuff into your bean. It's just that the @ManagedBean annotation is not required in this case.
To summarize, if you do have CDI available to you, it provides a far superior programming model to the @ManagedBean/@ManagedProperty model that JSF2 inherits from JSF1. So superior, in fact, that the EE 6 web profile does not require support for @ManagedProperty etc. The idea being that you should just use CDI instead.
一句话,如果是使用jsf 2.0,但是不使用CDI,那么你需要managedBean。否则直接用CDI就行,忘了managedBean吧。
Re: Comparisons to @ManagedBean annotations in JSF2?:
While looking through the Weld examples, and the older WebBeans documentation, it looks like a competitor to the new @ManagedBean JSF 2.0 annotations. Is there any information on when we'd want to use one over the other?
It's a good question, and I'm not really in full agreement with the answers that have been posted so far.
The new EE Managed Beans specification defines a base component model for Java EE, together with a very basic set of container services (@Resource, @PostConstruct, @PreDestroy).
The idea is that other specifications (beginning with EJB, CDI, JSF and the new Java Interceptors spec) build upon this base component model and layer additional services, for example transaction management, typesafe dependency injection, interceptors. So at this level, the managed beans, CDI, interceptors and EJB specifications all work hand-in-hand and are highly complementary.
Now, the Managed Beans specification is quite open-ended with respect to identifying exactly which classes are managed beans. It does provide the @ManagedBean annotation as one mechanism, but it also allows other specifications to define different mechanisms. So, for example:
The EJB specification says that a class obeying certain programming restrictions with a @Stateless or @Stateful annotation deployed in an EJB jar is a managed bean.
The CDI specification says that any class with an appropriate constructor deployed in a "bean deployment archive" is a managed bean.
Given that EJB and CDI provide arguably more convenient ways to identify a managed bean, you might wonder precisely what @ManagedBean is needed for. The answer, as alluded to by Dan, is that if you have CDI available in your environment (for example, if you are using EE6), then @ManagedBean is just not really needed. @ManagedBean is really there for use by people who are using JSF2 without CDI.
OTOH, if you do annotate a bean @ManagedBean, and you do have CDI in your environment, you can still use CDI to inject stuff into your bean. It's just that the @ManagedBean annotation is not required in this case.
To summarize, if you do have CDI available to you, it provides a far superior programming model to the @ManagedBean/@ManagedProperty model that JSF2 inherits from JSF1. So superior, in fact, that the EE 6 web profile does not require support for @ManagedProperty etc. The idea being that you should just use CDI instead.
发表评论
-
c++与java内存模型& c++ vTable
2012-11-03 16:25 930参见: http://stackoverflow.com/q ... -
maven pom 指南
2012-11-03 15:56 731http://maven.apache.org/pom.htm ... -
could not discover transaction status
2012-11-01 18:08 992https://community.jboss.org/thr ... -
zz java 类初始化顺序
2012-08-17 14:42 693zz from http://ig2net.info/arch ... -
JSP JSF tag关系
2012-07-12 23:44 917zz from http://drewdev.blogspot ... -
class泛型反射相关API介绍
2012-06-21 10:49 836class泛型反射相关API介绍: 1. getGeneri ... -
服务提供者框架(Service provider framework)
2012-06-14 16:55 1099服务提供者框架(Service provider framew ... -
JMS的使用
2012-05-30 16:24 9311. 何时使用MQ 如果仅仅是为了达到异步调用的目的, ... -
maven 默认编码
2012-05-28 15:59 5395maven会使用平台的默认编码,中文系统就是GBK 如果使用 ... -
Seam的事务管理
2012-05-17 17:10 1108Seam的事务管理 Seam和jsf绑定在一起,seam将j ... -
seam与jsf的结合
2012-04-10 23:02 844Seam与JSF的结合 1. 采用org.jboss.seam ... -
maven依赖之optional
2012-04-09 15:42 856http://maven.apache.org/guides/ ... -
Visualsvn+trac 0.12 配置
2012-03-13 09:54 898主要参考了: http://www.cnblogs.com/ ... -
seam 的interceptor分析
2012-03-12 10:36 9921. componet.initialInstance()的时 ... -
zzEJB sessionBean的生命周期
2012-02-29 22:18 805【译】 Stateless Session Be ... -
关于jboss 4 的JNDIVIew 名字空间
2012-02-27 18:11 993Jboss JNDI http://do ... -
多个EJB entity jar 使用同一个 persistence.xml
2012-02-22 18:32 710可以利用 persistence.xml 的 class、ma ... -
java的ClassLoader机制
2012-02-22 16:27 838zz from :http://www.cnblogs.com ... -
关于JPA的FlushModel---Manual
2012-02-21 17:08 1680zz from : http://www.codeinstr ... -
hibernate 分页
2011-11-01 09:10 641setFirstResult 是起始数据,setMaxResu ...
相关推荐
在Java EE 6中使用JSF 2.0简化页面制作 在Java EE 6中使用JSF 2.0简化页面制作 在Java EE 6中使用JSF 2.0简化页面制作
JSF2.0标签手册DQSV
JSF2.0实战 - 6、TextBox示例代码
Mojarra JSF 2.0库文件。开发JSF2.0 Web应用时放在lib目录下。
JSF 2.0 Programming Cookbook JSF PAGE Ajax JSF J2EE Eclipse IDE support
JavaServer Faces(JSF)2.0 规范
较为全面,课件中有很多例子代码片段,较为实用.比较经典.很值得刚刚学JSF的看看.本内容为managedbean部分的讲解.
jSF2.0与Spring整合实例+教程
jsf2.0的开发配置说明,和简单的配置例子,开发例子,及JSF2.0的所有标签的详细分析。
JSF2.0实战 - 10、自定义Ajax更新方式源代码
JSF2.0_开发入门JSF2.0_开发入门JSF2.0_开发入门JSF2.0_开发入门JSF2.0_开发入门JSF2.0_开发入门JSF2.0_开发入门
CDI+JSF2.0项目成功部署在 websphere8.5下, 兼容性问题总结.
jsf2.0+richfaces4.2.3需要的jar包
全面介绍JSF2.0、详述如何使用Ajax,以及按照JSF2.0、的方式构建组件、快速理解众多可以直接运行的代码示例。 作者 作者:(美国)伯恩斯 (Ed Burns) (美国)沙尔克 (Chris Schalk) (美国)格里芬 (Neil Griffin) 译者...
JSF2.0 Tutorial,总共18个章节,详细介绍了jsf2.0的overview, new feature, managedbean, el, ajax,spring集成等,并配source code.由于文件比较大切分成了3个压缩包。
全面介绍JSF2.0、详述如何使用Ajax,以及按照JSF2.0、的方式构建组件、快速理解众多可以直接运行的代码示例。 作者 作者:(美国)伯恩斯 (Ed Burns) (美国)沙尔克 (Chris Schalk) (美国)格里芬 (Neil Griffin) 译者...
JSF2.0系列简介.doc 和 文档想配的源代码,后面的AJAX的例子做,留给你们自己完成.希望能帮助到大家
个人收集的JSF2.0的开发简介 共64页 讲解了绝大部份JSF2.0的新特性
JSF2.0 Tutorial,总共18个章节,详细介绍了jsf2.0的overview, new feature, managedbean, el, ajax,spring集成等,并配source code.由于文件比较大切分成了3个压缩包。
JSF2.0 Tutorial,总共18个章节,详细介绍了jsf2.0的overview, new feature, managedbean, el, ajax,spring集成等,并配source code.由于文件比较大切分成了3个压缩包。