Services Provided by EJB Container

An applications server provides middleware services to the applications, such as transaction services, security services and others. These services are needed for the applciations to be scalable, robust and secure for multiple concurrent users.

The EJB container :

The EJB container provides a playground where the enterprise beans can run. There can be many beans running within a container. Beans containers are responsible for managing the beans running within them. They interact with the beans calling a few required methods that the bean must expose. Containers may also provide access to legacy system.

The EJB server :

The EJB server provides a runtime environment for one or more containers. EJB servers manage low-level system resources, allocating resources to containers as they are needed. EJB specification does not exactly demonstrate differences between an EJB container and EJB server. They go hand by hand.

The services that Implicit distributed transaction management provide :

Implicit distributed transaction management transactions allow us to perform robust, deterministic operations in a distributed environment by setting attributes on the enterprise beans. The EJB server provides a transaction service a low-level implementation of transaction management and coordination. The transaction service must be exposed throught the Java Transaction API(JTA). The JTA is a high-level interface that we can use to control transactions.

Implicit Security :

Security is a majour consideration for multitier deployments. The Java2 platform Standard Edition yields a robust security service that can authorize and authenticate users, securing deployments from unwanted visitors. EJB adds to this the notion of transparent security, allowing components to reap the benefits of a secure deployment without necessarily coding to a security API.

Implicit resource management and component life cycle:

The EJB server implicityly manages the resources for the components such as threads, sockets and database connections. The life cycle of the components themselves are also managed, allowing for components to be reused by the EJB server as necessary.

Implicit persistence:

Persistence is a natural requirement of any deployment that requires permanent storage. EJB offers assistance hereby automatically saving persistent object data to an underlying storage and retrieving that data at a later time.

Implicit remote accessibility :

EJB products will automatically convert our stand-alone, network-less components into distributed, network-aware beings,

Implicit multiclient support:

EJB servers automatically route concurrent requests from client. EJB servers provide built-in thread support, instantiating multiple copies of your component as necessary and channeling client requests to those instances.

Define EJB frame work

EJB provides the following frame work support.

  1. Distributed object infra structure.
  2. Component packing add employment.
  3. Declarative transaction management.
  4. Factory support.
  5. Bean activation and passivation.
  6. Container metadata.
  7. Security.

i)  Distributed object infrastructure:

EJB does not concern itself with the distributed object infrastructing. It assumes underlying ORB that understands the CORBA RMI/IDI. Semantics. The ORB transports must be able to propagate CORBA OTS transactions. IIOP ORB’s are designed to provide this type of service.

ii) Component packaging and deployment :

EJB defines a packaging mechanism for Server-side components based on JAR’s manifests and deployment descriptors. The container un-JAR’s the EJB and then runs if based on the instruction it gets from the maifest and deployment descriptors.

iii) Declarative transaction Management :

EJB supports implicit transaction built on the CORBA OTS/JTS services. EJB does not need to make implicit calls to OTS/JTS to participate in distributed transaction. The EJB container automatically manges the start, commit and roll back of a transaction. Programming can define the transactional attribute of a bean at design time using declartive statement in deployment descriptor. Metadata about the beans they contain, for example, the container can return the class name of the Enterprise bean that this factory interface is associated with.

iv) Factory Support :

As a bean provides programmer is responsibel for defining a remote factory interface for bean. Developer define a factory I/F that extends factory and define one or more create method. The container provider will automatically generate the factory implementation.How ever, bean must implement an EJB  create() for each create(). As a last step, programmer must register factories with the container, so, that client can create new beans. The container also provide a finder interface to help clients locate existing entity bean.

v) Bean activation and passivation:

As a part of managing the life cycle of an enterprise bean the container calls your bean when it is loaded into memory(or activation). It also calls it when it is deactivated from memory for passionate.

vi) Bean state management :

EJB container can handle both transient and persistent bean. Persistent bean encapsulate in their object reference a unique ID that point to their state. An entity bean manages its own persistence by implementing the persistencde operation directly the container simply hands it a unique-key and tells it to load its state.

vii) Container Metadata

EJB containers can provide metadata about the beans they contain. For example the container an return the class name of the enterprise bean that  this factory interface is associated with.

viii) Security :

EJB cotainer automate the management of some of the security aspects of a bean . Programming needs to declaratively define the security rules for an enterprise bean in security descriptor object. Programmer must then serialize this object and put it in the beans JAR. The EJB container uses this object to perform all security check on behalf of bean.

Write a note on EJB frame work

EJB Frame Work:

EJB defines the callBack interfaces a Java Bean must expose to its OTM, and viceversa. In addition. EJB specifies a packaging mechanism for server-side components. The EJB specification defines a server component model for Java Beans. An EJB is specialized non-visual Java Bean that runs on a server like Java Beans. EJB can be assembled via tools to create new application. In a multitier application architecture, most of an application logic is moved from the client to one or more server.

A server component model simplifies the process of moving the logic to the server. The component model implements a set of automatic services to manage the components.

EJB provides the following frame work support.

  1. Distributed object infra structure.
  2. Component packing add employment.
  3. Declarative transaction management.
  4. Factory support.
  5. Bean activation and passivation.
  6. Container metadata.
  7. Security.

To know more about this frame work visit here

Define Transaction Isolation in EJB

Q) What are transaction isolation levels in EJB?

A)

1. Transaction_read_uncommitted- Allows a method to read uncommitted data from a DB(fast but not wise).
2. Transaction_read_committed- Guarantees that the data you are getting has been committed.
3. Transaction_repeatable_read – Guarantees that all reads of the database will be the same during the transaction (good for read and update operations).
4. Transaction_serializable- All the transactions for resource are performed serial.