Unit 4 Part 1 Java Bean
Unit 4 Part 1 Java Bean
• A Bean may register to receive events from other objects and can
generate events that are sent to other objects.
JavaBeans API
BeanInfo It allows designer to specify information about events, methods & properties of a Bean.
Customizer It allows designer to provide a GUI through which a bean may be configured.
PropertyEditor Objects that implement this interface allow to change & display property values.
Visibility Methods in this allow a bean to execute in environment where GUI is not available
BDK (Bean Development Kit)
• Bean Development Kit is a tool that enables to create,
configure and connect a set of Beans
• It can be used to test Java Beans without writing a code.
• The Bean Development Kit (BDK) from Sun includes a simple
example of a building environment which uses beans,
called the beanbox, and some sample beans
• It is a pure Java application whose only dependency is the Java
Development Kit (JDK) 1.1.
• The BDK provides support for the JavaBeans APIs, a test
container (the “BeanBox” to test Bean behavior), sample
Beans complete with their source code, the JavaBeans
Specification.
EJB (Enterprise Java beans)
• EJB is used to implement the Business Logic Application.
• Main use – Handling Large Database
• It is a part of J2EE specification
• It is provided by Sun Microsystems to develop secured,
robust and scalable distributed applications.
• It performs:
EJB Container
EJB1 1 EJB 2
Data
base
EJBn
Architecture of EJB
Benefits of EJB
• Simplified development of large scale enterprise level
application.
a) Stateful EJB - Preserves the previous state. (i.e stores result of last session). Its
name keeps associated client state in its instance variables. EJB Container creates a
separate stateful session bean to process client's each request. As soon as request
scope is over, it is destroyed.
b) Stateless EJB- Do not preserves their state, always work on initial state. It is used
to do independent operations. Its name does not have any associated client state,
but it may preserve its instance state. EJB Container normally creates a pool of few
stateless bean's objects and use these objects to process client's request.
2. Message Driven EJB - Based on trigger or message & works on procedures &
functions. It is invoked by EJB container when it receives a message from queue or
topic. Message driven bean is a stateless bean and is used to do task asynchronously.
3. Entity EJB- Performs a particular task but does not preserve the data of operation.
They work on single type of data of operation. They work on single type of data.