study notes for EJB 3 in action (I)

EJB 3 in Action

preface

The initial goal for EJB was to provide a simpler alternative to CORBA through components and framework benefits-but the component benefits were oversold.

The heavyweight inheritance-based programming model was abandoned in favor of POJO programming and the verbose XML descriptor was now out of the developer's way.

EJB 3 leaves behind the flawed Entity Beans model in favor of the lightweight Java Persistence API (JPA).


1. What's what in EJB3

In very straightforward terms, Enterprise JavaBean (EJB) is a platform for building portable, reusable, and scalable business applications using the Java programming language.

From a developer's point of view, an EJB is a piece of Java code that executes in a specialized runtime environment called the EJB container, which provides a number of component services.

EJB as Components
The real idea behind a component is that it should effectively encapsulate application behavior. The users of a component aren't required to know its inner workings. All they need to know is what to pass in what to expect back.

There are three types of EJB components: session beans, message-driven beans and entities. Session beans and message-driven beans are used to implement business logic in an EJB application, and entities are used for persistence.

EJB as Framework
Most server-side applications have a lot in common, including churning business logic, managing application state, storing and retrieving information from a relational database, managing transactions, implementing security, performing asynchronous processing, integrating systems, and so on.

Being able to support high-performance, fault-tolerant, scalable applications is an up-front concern for the EJB platform instead of being an after-thought.

You'll be able to count on moving your application to a distributed, clustered server farm by doing nothing more than a bit of configuration.

Layered architectures and EJB
EJB allows you to build application using two different layered architectures: the traditional four-tier architecture and domain-driven design (DDD).

The traditional four-tier layered architecture is not perfect. One of the most common criticisms is that it undermines the OO ideal of modeling the business domain as objects that encapsulate both data and behavior. Because the traditional architecture focuses on modeling  business processes instead of the domain, the business logic tier tends to look more like database-driven procedural application than an OO one. Since persistence-tier components are simple data holders, they look a lot like database record definitions rather than first-class citizens of the OO world.

DDD emphasizes that domain objects should contain business logic and should not just be a dumb replica of database record. Domain objects are known as entities in EJB 3.

Why choose EJB 3?
Ease of use
Integrated solution stack (JDBC, JavaMail, JTA, JMS, JAAS, JNDI, RMI)
Open Java EE standard
Broad vendor support (IBM, Oracle, JBoss, Geronimo)
Stable, high-quality code base
Clustering, load balancing, and failover
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值