KEMBAR78
Java bean | PPTX
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.
Enterprise Java Beans
 Enterprise 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.
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 CORBA
 EJB provides for vender specific enhancements.
EJB Architecture
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.
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.
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.
Types of Enterprise Beans
 Entity bean
 Session bean
 Message Driven
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.
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.
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.
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.
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.

Java bean

  • 1.
  • 2.
    What is javabean?  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.
  • 3.
    Enterprise Java Beans Enterprise 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.
  • 4.
    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 CORBA  EJB provides for vender specific enhancements.
  • 5.
  • 6.
    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.
  • 7.
    EJB Clients  EJBclient 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.
  • 8.
    EJB remote interfacesand 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.
  • 9.
    Types of EnterpriseBeans  Entity bean  Session bean  Message Driven
  • 10.
    Entity bean  Anentity 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.
  • 11.
    Session Bean  ASession 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.
  • 12.
    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.
  • 13.
    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.
  • 14.
    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.