Java EJB Question and Answers

1. What is EJB?
 
  • EJB is a standard for building server side components in JAVA.
  • It specifies an agreement between components and application servers that enables any component to run in any application server.
  • EJP components are deployable and can be imported in to an application server which hosts these components.
  • EJB are not intended for client side they are server side components.
  • They are specially meant for complex server side components like executing complex algorithms or high volume business transactions.
 
Your Name Your Email-ID
Your Answer
2. What are the different kind of EJB's?
  There are three kinds of EJB's
  • Session beans: Session beans are construct in EJB. They represent business logic of an application. They represent a group of logical related functioanality. There are two types of session beans: Stateless: they do not maintain state across method calls. So every time client makes a call its like a new object from scratch. Stateful: These beans can hold client state across method invocations. This is possible with the use of instance variables declared in the class definition. Every time the client calls it they can get there previous states. Stateless session bean provide greater scalability as EJB container does not have to maintain state across method invocations. Storing state for EJB container is huge activity.
  • Entity beans: Entity bean represent persistent data in an EJB application. They provide object oriented abstraction to a relational database. When session bean needs to access data it calls the entity beans. Entity beans do read, write, update and delete from tables.
  • Message driven beans: There are situations in project where you would like to communicate asynchronously with some other systems. This is achieved by using message driven beans.
 
Your Name Your Email-ID
Your Answer
3. What is passivation and activation in EJB?
 
  • When we are dealing with stateful session beans we need to store the client conversation of the bean so that it can be available in client's next request.
  • But when we talk about server it has limited resources.
  • If the conservation of the bean is large then the server can run out of resources.
  • If the conservation of the bean is large then the server can run out of resources. So, in order to preserve resources.
  • EJB server swaps this conversational data in memory to hard disk is called as "Passivation".
  • Now when the clients comes back the conversational data is again swapped from the hard disk to the bean.
  • This process is called as "Activation". The container informs the bean that its about to passivate or activate using the "ejbPassivate()" and "ejbActivate()" methods.
 
Your Name Your Email-ID
Your Answer
4. Can beans who are involved in transaction have passivation process?
  No
 
Your Name Your Email-ID
Your Answer
12345678910 Page 1 of 10