- Business logic interface (also known as the object interface)
- Life cycle interface (also known as the home interface)
- EJB component class
- XML deployment descriptor
For every EJB component you must implement certain methods. These are called callback or life cycle methods. For example, a method is called just after a component instance is created, or just before it is destroyed, or just prior to its passivation (a form of serialization) or reactivation.
Although users are responsible for writing the life cycle and business logic, their implementation classes are generated automatically prior to deployment by container tools. XML files are written to describe the required distribution properties for EJBs. With an appropriate XML deployment descriptor editor, we are able to display and alter the deployment properties. Container tools read these XML deployment descriptor files and generate distribution code. Among the various properties there are some worth to mention:
Security - logical security role names are used. Allows user to say who is allowed to invoke which methods.
Transaction scope, persistence requirements, composition, and the type of EJB - e.g. indicate to the container the kind of EJB you have developed and chain of methods used in a transaction. If a persistent EJB, the parts of the EJB that should be synchronized with a table in an underlying RDBMS.
There are three kinds of EJBs:
Session EJBs - used to encapsulate business logic. Stateful session and stateless session EJBs are two variants of session beans. Their data is not synchronized automatically with an underlying persistent store by the container.
Entity EJBs - used to encapsulate business logic. Unlike the session EJBs, their data is synchronized. This synchronization can either be at the control of the container entirely (container-managed persistence), or can be partially the responsibility of the EJB code (bean-managed persistence).
Message driven EJBs - this is new to EJB 2.0. While session and entity EJBs support synchronous communication, message driven EJBs support asynchronous communication. It read message objects off an associated destination (a queue or topic).