EJB MaStEr

Enterprise JavaBeans (EJB) is a managed, server-side component architecture for modular construction of enterprise applications.

This is the famouse definition for EJB everywhere......SO Here I'm going to say what I learnt about EJB.
There are three kind of Enterprise JavaBeans.

1.MDB
2.SESSION
3.ENTITY

MDB(Message Driven bean)
This bean is used when we need to do a task with message arriving. MDB has a method called "onMessage", this method is triggered when a message is arrived to the queue.

MDB
stateless.
short live.
not represent directly shared data in DB but can update data base.
allows J2EE applications to process message asynchronously.
can process message from multi clients.


EX:- Just think a JMS client is sending message to a queue and the MDB is listening to that queue for processing that message.

SESSION
session bean is mostly used to process data into a specific way.

EX:- we can use session bean to process the message we got from message driven bean to a way we need according to our application.

ENTITY
entity bean can used to map table of DB with classes.

EX:- we can store the data we processed in session bean in the entity bean. Here we use getters and setters method to map data with DB.

Entity beans are persistent, allow shared access, have primary keys, and may participate in relationships with other entity beans.

There are two types of entity beans.
1) Container Managed Persistence(CMP)
2) Bean Managed Presistence(BMP)