- 浏览: 167346 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
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 1002参见: http://stackoverflow.com/q ... -
maven pom 指南
2012-11-03 15:56 774http://maven.apache.org/pom.htm ... -
could not discover transaction status
2012-11-01 18:08 1019https://community.jboss.org/thr ... -
zz java 类初始化顺序
2012-08-17 14:42 718zz from http://ig2net.info/arch ... -
JSP JSF tag关系
2012-07-12 23:44 939zz from http://drewdev.blogspot ... -
class泛型反射相关API介绍
2012-06-21 10:49 866class泛型反射相关API介绍: 1. getGeneri ... -
服务提供者框架(Service provider framework)
2012-06-14 16:55 1121服务提供者框架(Service provider framew ... -
JMS的使用
2012-05-30 16:24 9561. 何时使用MQ 如果仅仅是为了达到异步调用的目的, ... -
maven 默认编码
2012-05-28 15:59 5428maven会使用平台的默认编码,中文系统就是GBK 如果使用 ... -
Seam的事务管理
2012-05-17 17:10 1153Seam的事务管理 Seam和jsf绑定在一起,seam将j ... -
seam与jsf的结合
2012-04-10 23:02 874Seam与JSF的结合 1. 采用org.jboss.seam ... -
maven依赖之optional
2012-04-09 15:42 892http://maven.apache.org/guides/ ... -
Visualsvn+trac 0.12 配置
2012-03-13 09:54 937主要参考了: http://www.cnblogs.com/ ... -
seam 的interceptor分析
2012-03-12 10:36 10211. componet.initialInstance()的时 ... -
zzEJB sessionBean的生命周期
2012-02-29 22:18 827【译】 Stateless Session Be ... -
关于jboss 4 的JNDIVIew 名字空间
2012-02-27 18:11 1036Jboss JNDI http://do ... -
多个EJB entity jar 使用同一个 persistence.xml
2012-02-22 18:32 743可以利用 persistence.xml 的 class、ma ... -
java的ClassLoader机制
2012-02-22 16:27 863zz from :http://www.cnblogs.com ... -
关于JPA的FlushModel---Manual
2012-02-21 17:08 1710zz from : http://www.codeinstr ... -
hibernate 分页
2011-11-01 09:10 670setFirstResult 是起始数据,setMaxResu ...
相关推荐
Mojarra JSF 2.0是针对JSF 2.0规范的实现库,包含了处理JSF生命周期、渲染组件以及与其他Java EE技术集成所需的所有类和接口。将Mojarra JSF 2.0库文件放置在Web应用的`WEB-INF/lib`目录下,是为了让应用服务器能够...
- Managed Beans是JSF中的业务逻辑组件,可以使用注解定义bean及其作用域,如`@ManagedBean(name="helloBean")`和`@ViewScoped`。 - 通过EL(Expression Language)在视图和bean之间传递数据,如`#{helloBean....
这允许在JSF的managed bean中直接注入业务服务或者DAO。 4. **数据访问**:使用Hibernate的Session接口执行CRUD操作,Spring可以帮助管理事务,确保数据一致性。 5. **测试与部署**:完成集成后,进行单元测试和...
**JSF 2.0(JavaServer Faces 2.0)是Java EE 6中引入的一个重要的Web应用程序开发框架,用于构建用户界面。这个框架基于MVC(Model-View-Controller)模式,提供了丰富的组件库和事件处理机制,极大地简化了前端...
3. **依赖注入**:JSF 2.0集成了Java EE 6中的CDI(Contexts and Dependency Injection),使得组件之间的依赖关系可以通过注解自动管理。 4. ** Managed Beans**:Managed Beans是JSF中处理业务逻辑的对象,2.0...
JavaServer Faces (JSF) 2.0 是Java EE平台中的官方组件化视图技术,专为构建Web应用程序而设计。JSF的核心特性包括预定义的用户界面(UI)组件、事件驱动的编程模型以及对第三方组件的支持。其目标是易于扩展、使用...
9. ** 集成CDI (Contexts and Dependency Injection)**:JSF 2.0与Java EE 6中的CDI集成,使得开发者可以利用CDI的强大功能,如依赖注入、拦截器等。 10. ** 安全性**:JSF 2.0提供了基本的安全框架,如对HTTP参数...
- **CDI集成**: 与Java EE 6中的Contexts and Dependency Injection (CDI)框架集成,提供了更强大的依赖注入功能。 综上所述,`jsf2.0(mojarra-2.0.2-FCS-binary.zip)`是一个全面的JSF 2.0开发工具包,包含了从...
4. **依赖注入**:JSF 2.0集成了Java EE的依赖注入(DI)功能,开发者可以使用`@ManagedBean`和`@Inject`注解来管理bean实例和注入依赖,这使得代码更加整洁,提高了可测试性。 5. **转换和验证**:JSF 2.0提供了...
Java EE 6(Java Platform, Enterprise Edition 6)是Java技术在企业级开发中的一个里程碑,它为构建可扩展、高性能、分布式的企业级应用程序提供了全面的框架和规范。本教程由Sun Microsystems(后被Oracle收购)...
1. **轻量级框架支持**:Java EE 6引入了JSF 2.0(JavaServer Faces 2.0)、CDI(Contexts and Dependency Injection)和EJB 3.1,这些框架使得开发更加简单和灵活。JSF 2.0提供了更多的组件,更好的事件处理和渲染...
4. **JPA 2.0**:Java Persistence API (JPA) 2.0提供了更多的查询语言特性,如命名查询和实体图形,同时支持双向关系和懒加载,使得对象-关系映射更为灵活。 5. **CDI 1.0**:Contexts and Dependency Injection ...
- **ManagedBean**: JSF中的可管理bean,用于存储业务数据和逻辑。 - **EL (Expression Language)**: 提供了表达式语言,用于在页面上绑定和操作bean属性。 - **Converter**: 用于数据类型转换,确保页面输入和...
- JSF 2.0集成了Java EE 6的CDI(Contexts and Dependency Injection),使得组件之间可以通过注解进行依赖注入,提高了代码的可测试性和可维护性。 - 例如,`@ManagedProperty` 注解可以用来注入其他bean的属性,...
1. **与Java EE平台的关系**:CDI是Java EE平台的一部分,为其他Java EE规范(如EJB、JPA、JSF等)提供了统一的依赖注入和上下文管理机制。 2. **与EJB的关系**:虽然EJB自身也提供了依赖注入,但CDI提供了一个更加...
2. **Managed Beans (JSR 330)**:通过JSR 330规范,Java EE 6引入了依赖注入(Dependency Injection)的标准实现,比如@ManagedBean和@Inject,使得组件间的依赖关系更加清晰。 3. **Contexts and Dependency ...
2. **CDI (Contexts and Dependency Injection)**:CDI是Java EE 6中引入的一个重要组件,它提供了依赖注入(DI)和上下文管理的功能,使得对象的创建和管理更加简单。`@Inject`注解用于注入依赖,`@Named`注解用于...
JavaServer Faces 2.0是Java EE6中的用户界面框架,它提供了显著的改进,包括异步请求处理、更简洁的代码以及面部组件的可复用性。这些特性让开发者可以更高效地构建富客户端Web应用。 **Managed Beans** Managed ...