(Tutorial) Enterprise JavaBean 3.0
Tutorial : Enterprise JavaBean 3.0
An Enterprise JavaBean provides reusable, portable J2EE component. It comprises of methods that encapsulate business logic for instance: updating employee data in database can be business logic and it can be in EJBean. The business methods (in EJB) can be invoked by local and remote clients. As an EJBean developer, you have to only focus on business logic that has to be in the bean. Issues like transaction management, clustering, caching, messaging between applications and others are handled by the container.
You must be aware of Plain Old Java Objects (POJOs). EJBeans are developed as POJOs and annotations are used to tell the container how to manage the beans.
Features
Some worth mentioning features of EJBeans 3.0 are listed below:
No need of home and object interface.
No need of any component interface.
Made use of java annotations.
Simplifies APIs to make flexible for bean's environment.
EJB Context
By context we mean environment at runtime. It’s important for a bean to know its context like security principle, transaction context and so on. An API javax.ejb.EJBContext serves the purpose. EJBContext is categorized into SessionContext and MessageDrivenContext for the session beans and message driven beans respectively. There are two ways in which bean instances can access the EJBContext. You may use the dependency injection or you may use lookup() method of the EJBContext interface. Bean must use the JNDI API to access the environmental dependencies.
Types of EJBs
EJBeans comprises of three main types: Session, Entity, and Message-Driven. We use session bean to perform business task like checking credit history for a customer. Entity bean represents a business object that exists in the database. A Message-Driven bean is used to receive asynchronous JMS messages.
Session Beans
Actions or tasks of business process are represented by session beans. Session beans are classified into two: stateful or stateless...
Courtesy:- Java-forums.org
- guru's blog
- Login to post comments
