EJB3 Feature Overview
1) Simplify the development of Enterprise Java applications
2)Standardize the Java Persistence API.
EJB3.0的终极目标由两部分组成:
1)简化java 企业应级用的开发
2)规范java 持久层API
JBoss views the EJB 3.0 specification as a watershed moment for the simplification of Enterprise Java. Both JBoss Chief Architect Bill Burke and Hibernate Founder Gavin King represent JBoss on the EJB 3.0 (JSR220) specification team. EJB 3.0 factors heavily into the future of Java Enterprise Edition as well as the JBoss Application Server and Hibernate products. The EJB 3.0 specification team has released several drafts of the EJB 3.0 specification and JBoss has tracked along with these drafts by offering the ability to test drive EJB 3.0 with JBoss Application Server.
EJB 3.0 introduces the following key features:
Jboss 将 EJB3.0 规范视作java企业级规范的转折时刻。JBoss的首席架构师Bill Burk和Hibernate 之父 Gavin King均可代表JBoss在EJB3(JSR-220)规范团队的应用。EJB3.0特点着重于J2EE和JBoss应用服务+hibernate的产品。EJB3规范团队已经发布了几版EJB3.0规范的初稿,JBoss也已通过JBoss应用服务对提供EJB3.0测试驱动功能。
EJB3.0介绍了已下特色:
EJB 3.0 eliminates the need for Home interfaces and for beans to implement required EJB APIs. Session Beans, Message driven Beans, and Entity Beans are now simple Java Beans that are focused on implementing your business logic. Since Entity Beans are now standard Java classes with no onerous interface requirements, this means that Entity Beans can follow object-oriented (O-O) design principles and benefit from inheritance, polymorphism, and other standard O-O constructs.
简化EJB API
通过EJB APIs,EJB3.0减少了对Home接口和beans实现的需求,会话bean、消息驱动bean、实体bean都变成了专注于业务逻辑的简单Java Bean。由于实体Bean现在已是无需复杂接口的实现标准java类,这就意味着实体Bean的设计满足面向对象原则,并且也受益于继承、多态和其他标准面向对象结构。
EJB 3.0 embraces Java Annotations introduced in JDK 5.0. Annotation have been introduced in a way that makes the use of deployment descriptors purely optional. The EJB 3.0 specification defines a wide range of Annotations that cover such things as Bean Types, Dependency Injection, Transaction and Security, Callbacks, ObjectRelational Mapping, Relations, etc. Deployment descriptors still have their place for those who want to override Annotations. Both JBoss Application Server and Hibernate support these annotations which means that by using Hibernate, you can get the benefits of EJB 3.0 annotations outside of the EJB 3.0 container and within standalone Java applications.
Java 注解
EJB3.0涵盖了在JDK5.0引入的java注解,EJB3.0规范定义了许多覆盖到bean类型、依赖注入、事务安全、回调、对象关系映射等等注解,发布时只需要引用这些注解即可。不管是JBoss应用服务还是hibernate都支持这些注解。这就意味着,即便是在EJB容器之外,使用hibernate可受益于EJB3.0注解的使用。
No more boilerplate code for looking up EJBs and related resources. By introducing the @Inject, @EJB, and @Resource annotations, these dependencies are now injected transparently by the container into your simple Java Beans.
依赖注入
不再使用格式化编码来查找EJB和其他关联资源,通过引入@Inject ,@EJB 和@Resource注解,便可将依赖通过EJB容器轻松地注入到java bean 中。
Developers can now just implement the callbacks they are interested in. By using such callback annotations as @PostConstruct, @PreDestroy, @PrePersist, or @PostPersist, developers can map any Java Bean or callback class method to be a callback that receives event notifications.
可选的回调
开发者现在只需实现回调的方法,通过回调注解@PostConstruct, @PreDestroy, @PrePersist, @PostPersist,可映射任何java Bean 或者回调类方法作为接收消息的回调方法
The Entity Manager API is introduced in EJB 3.0 and it is designed to enable Java Bean instances to be detached, updated locally, and then sent back to the EntityManager to be persisted in the database. Both JBoss Application Server and Hibernate support this new API.
实体管理API
EJB3.0引入实体管理API,意于分离以及本地更新Java Bean实例,然后返回到实体管理去持续化数据块。JBoss应用服务器和hibernate都支持实体管理API.
EJB 3.0 standardizes the Java persistence model with Hibernate playing a crucial role in the definition of this API. A full complement of Java Annotations have been defined to handle Object-Relational Mapping and a range of different relation types. EJB 3.0 also enhances EJB-QL with such improvements as support for dynamic queries, subqueries, bulk updates, and bulk deletes.
简化持久层、提高查询效率
EJB3.0规范了java 持久层实体,其中hibernate在定义实体层API起到了至关重要的作用。一个完整的java注解用于处理对象关系映射和管理关系类型,而且,EJB3.0还包含了EJB-QL作为动态查询、子查询、批量更新、批量删除的支持。