java bean

14
java bean

Upload: jafar-nesargi

Post on 20-Jan-2015

85 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Java bean

java bean

Page 2: Java bean

What is java bean? Java Beans are software component

models.A java bean is a general purpose

component model. A java bean is a reusable software

component that can be visually manipulated in builder tools.

Their primary goal of java bean is WORA (Write Once Run Anywhere).

Java beans should adhere to portability, reusability and interoperability.

Page 3: Java bean

Enterprise Java BeansEnterprise JavaBeans (EJB) technology is

the server-side component architecture for Java Platform, Enterprise Edition (Java EE).

EJB technology enables rapid and simplified development of distributed, transactional, secure and portable applications based on Java technology.

Page 4: Java bean

Advantages of EJB

EJB gives developers architectural independence.

EJB is WORA for server side components.EJB establishes roles for application

development.EJB takes care of transaction management.EJB provides distributed transaction support.EJB help create portable and scalable solutions.EJB integrates seamlessly with CORBAEJB provides for vender specific enhancements.

Page 5: Java bean

EJB Architecture

Page 6: Java bean

EJB Architecture

EJB Container

An EJB container is a runtime environment that manages one or more enterprise beans.

The EJB container manages the life cycles of enterprise bean objects, coordinates distributed transactions, and implements object security.

Generally, each EJB container is provided by an EJB server and contains a set of enterprise beans that run on the server.

If we want to execute an enterprise bean it must be placed in one of the EJB container, which provides system level services for its execution.

Page 7: Java bean

EJB Clients

EJB client applications utilize the Java Naming and Directory interface (JNDI) to look up references to home interfaces and use home and remote EJB interface to utilize all EJB based functionality.

EJB home interface and stubs

EJB home interfaces provide operations for clients to create remove and find handles to EJB remote interface objects. Underlying stubs marshal home interface requests and unmarshal home interface responses for the client.

Page 8: Java bean

EJB remote interfaces and stubs

EJB remote interfaces provide business specific client interface methods defined for a particular EJB. Underlying stubs marshal remote interface request and unmarshal remote interface responses for the client.

Page 9: Java bean

Types of Enterprise Beans

Entity bean Session bean Message Driven

Page 10: Java bean

Entity bean An entity bean represents the business data.

An entity bean is an object representation of persistent data maintained in a permanent data store such as a database. A primary key identifies each instance of an entity bean.

Entity beans are transactional and are recoverable in the event of a system crash.

Entity beans are representations of explicit data or collections of data, such as a row in a relational database. Entity bean methods provide procedures for acting on the data representation of the bean. An entity bean is persistent and survives as long as its data remains in the database.

Page 11: Java bean

Session Bean A Session bean represents the business processing

logic.

It is a java class that implements the methods in Session Interface.

A session bean usually performs operations such as calculations or database access on behalf of the client. While a session bean may be transactional, it is not recoverable if a system crash occurs.

There are two types of session beans: ◦ Stateful◦ Stateless.

Page 12: Java bean

Stateful Session Beans The state of an object consists of the values of its

instance variables. In a stateful session bean, the instance variables represent the state of a unique client-bean session. Because the client interacts (“talks”) with its bean, this state is often called the conversational state.

The state is retained for the duration of the client-bean session. If the client removes the bean or terminates, the session ends and the state disappears. This transient nature of the state is not a problem, however, because when the conversation between the client and the bean ends there is no need to retain the state.

Page 13: Java bean

Stateless Session Beans

A stateless session bean does not maintain a conversational state with the client. When a client invokes the methods of a stateless bean, the bean’s instance variables may contain a state specific to that client, but only for the duration of the invocation. When the method is finished, the client specific state should not be retained.

Clients may, however, change the state of instance variables in pooled stateless beans, and this state is held over to the next invocation of the pooled stateless bean. Except during method invocation, all instances of a stateless bean are equivalent, allowing the EJB container to assign an instance to any client. That is, the state of a stateless session bean should apply across all clients.

Page 14: Java bean

Message Driven Bean A message-driven bean is an enterprise bean that

allows Java EE applications to process messages asynchronously. It normally acts as a JMS message listener, which is similar to an event listener except that it receives JMS messages instead of events.

The messages can be sent by any Java EE component (an application client, another enterprise bean, or a web component) or by a JMS application or system that does not use Java EE technology.

Message-driven beans can process JMS messages or other kinds of messages.