EJB stands for Enterprise Java Bean. EJB are server side components which can be used to build large scale distributed application. EJB became popular with 2+ version but quickly lost the favour of developers due to its extra complex implementation framework. Those coming from Microsoft world can relate EJB to the COM architecture. The EJB2.1 has a lot of implementation details, in which the business related object oriented architecture was lost. Frameworks like Spring became very popular, which did solved the problem of complexity by using POJO programming model and delegating the infrastructural work to the container.
To solve the above issues, the spec committee came up with EJB3.0 specification, which main focus was to reduce the programming complexity and at the same time retaining the power of enterprise application development capabilities. Also another important thing incorporate in EJB3 model is adoption of annotation and preferring convention over configuration.
With the notion of EJB3, we should also clearly understand the notion of container. An EJB in itself is a java object written against certain rules. However the real power to this object so that it can act like an enterprise object is provided by the container. An analogy can be drawn to a Formula one racing. A driver is alike an EJB component, where we desire certain capabilities especially quick reaction time. However the real power to this driver is provided by the machine in which he/she is sitting. So an EJB component is like a driver and the container is the machine. An EJB container has the same role as a Servlet container that it controls the lifecycle of the EJB component. However on top of that it provides the following capabilities:
- Transactions
- Security
- Persistence
- Remoteability
- Interceptors
- Timers
- State Management
- Messaging
With the above capabilities provided by the container, a simple EJB3 object turns into a powerful business component.
Those coming from EJB2.1 background, a quick comparison to EJB3 is:
- Remove Boiler plate code
- Container does more work than developer
- No home and object interface are required
- No component interface required
- Use of java metadata annotation
- Simplification of API’s for accessing bean’s environment
- The Entity beans and persistence api's are separated.
EJB3 has following categories:
- Session Bean
- Stateless Bean
- Stateful Bean
- Entity Bean
- Message Driven Bean
No comments:
Post a Comment