Monday, April 18, 2011

Inside EJBs

Inside EJBs
Session and message-driven beans require a EJB container to run and entities require a persistence provider. A Java EE Container is an application server solution that supports EJB 3, a web container and other Java EE APIs and services. There are a number of Java EE containers that you can use
  • JBoss Application Server
  • BEA WebLogic Server
  • IBM WebSphere
  • Oracle Application Server
  • Sun GlassFish
The container is an extension of the basic idea of a JVM, but manages the memory on your behalf and provides services such as transactions, security management, remoting, web services. The EJB 3 part will provide services applicable to session beans and MDBs only, and putting a EJB 3 component inside a container is called deployment, once deployed it can be accessed via a client. To provide persistence you will require a JPA which can be plugged into the container, this means that you are freely to choice what JPA you want to use, JBoss Hibernate and Oracle TopLink are popular and you can mix and match containers with persistence providers.
There are a number of EJB 3 component services
Applies To
What's offered
Session beans, MDBs
Helps glue components together, in EJB 3 you use dependency injection (DI) as well as lookup
Stateless session beans and MDBs
The EJB platform creates a pool of component instances that are shared by clients. All instances are returned to the pool when the client has finished with them.
Session beans, MDBs
EJB makes all components thread-safe and highly performant in ways that are completely invisible, however complex the application.
State Management
Stateful session beans
The EJB container manages state transparently.
You can write messaging aware components with out to much detail of the JMS service
Session beans, MDBs
EJB supports declarative transaction management using simple configuration instead of code, the container can handle the commit and rollback of transactions.
Session beans
Integration of JAAS API, means that it is easy to implement security with simple configuration instead of code.
Session beans, MDBs
EJB 3 introduces AOP in a very lightweight, accessible manner using interceptors. This allows you to separate out crossing cutting concerns such as logging, auditing and so on in a configurable way.
Remote Access
Session beans
EJB 3 can make components remotely accessible without writing code. It allows clients to access components as if they were local using DI
Web Services
Stateless session beans
EJB 3 can transparently turn business components into robust web services with minimal code change.
Automated persistence as an alternative to verbose and error-prone JDBC/SQL code.
Caching and Performance
JPA provides a number of services geared toward data caching, performance optimization and application tuning, especially in large environments.