Skip to main content

Posts

Showing posts with the label Entity Bean

What is the differences between bean and ejb ?

A Java Bean is defined as an instance of a class that contains private attributes (data), and getter & setter methods. If you have: private String myString; in your class, you should have the methods public String getMyString (); and public void setMyString (String settingString); defined in your code. Although, I have found that it is not absolutely nessary to have everything defined; just don't be surprised if something breaks! An EJB (Enterprise Java Bean) is much more complex They only reside in application servers that handle EJBs (Tomcat doesn't hold EJBs). There are 3 types of EJBs: 1) Session Usually contain some business logic. 2) Entity Usually interface with a data store (such as a database). 3) Message-Driven Receives messages from JMS

The Life Cycle of an Entity Bean

The following figure shows the life cycle of an entity bean. An entity bean has the following three states:   Does Not Exist . In this state, the bean instance simply does not exist. Pooled . When WebLogic server is first started, several bean instances are created and placed in the pool. A bean instance in the pooled state is not tied to particular data, that is, it does not correspond to a record in a database table . Additional bean instances can be added to the pool as needed, and a maximum number of instances can be set Ready . A bean instance in the ready state is tied to particular data, that is, it represents an instance of an actual business object. The various state transitions as well as the methods available during the various states are discussed below.