SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
WEB PROGRAMMING UNIT-IV

PREPARED BY BHAVSINGH MALOTH

JAVA BEANS:
o Java bean is a reusable s software component which is visible and
customizable.
 A JavaBean is a specially constructed Java class written in the Java and coded
according to the JavaBeans API specifications.
Following are the unique characteristics that distinguish a JavaBean from other Java
classes:


It provides a default, no-argument constructor.



It should be serializable and implement the Serializable interface.



It may have a number of properties which can be read or written.



It may have a number of "getter" and "setter" methods for the properties.

JavaBeans Properties:




A JavaBean property is a named attribute that can be accessed by the user of the
object. The attribute can be of any Java data type, including classes that you
define.
A JavaBean property may be read, write, read only, or write only. JavaBean
properties are accessed through two methods in the JavaBean's implementation
class:

Method
getPropertyName()

setPropertyName()


Description
For example, if property name is firstName, your method
name would be getFirstName() to read that property. This
method is called accessor.
For example, if property name is firstName, your method
name would be setFirstName() to write that property. This
method is called mutator.

A read-only attribute will have only a getPropertyName() method, and a writeonly attribute will have only a setPropertyName() method.

Page

 The properties, events, and methods of a bean that are exposed to an application
builder tool can be controlled.

1

ADVANTAGES OF JAVA BEANS:
 A bean obtains all the benefits of java’s “write once, run anywhere” paradigm.
 A bean may be designed to operate correctly in different locals, which makes it
useful in global markets.
 The configuration settings of a bean can be saved in persistent storage and
restored at a later time.
 A bean may register to receive events for other objects and can generate events
that are sent to other objects.
Disadvantages with JavaBeans

 A class with a nullary constructor is subject to being instantiated in an invalid
state. If such a class is instantiated manually by a developer (rather than
automatically by some kind of framework), the developer might not realize that
the class has been improperly instantiated. The compiler can’t detect such a
problem, and even if it’s documented, there’s no guarantee that the developer will
see the documentation.
 Having to create a getter for every property and a setter for many, most, or all of
them can lead to an immense quantity of boilerplate code.


WHY USE JAVA BEAN?

Page

2

According to Java white paper, it is a reusable software component. A bean encapsulates
many objects into one object, so we can access this object from multiple places.
Moreover, it provides the easy maintenance.
Page

Starting the BDK: To start the BDK, follow these steps:
 Change to the directory c:bdkbeanbox.
 Execute the batch file called “run.bat” This causes the BDK to display the three
windows. Toolbox lists all of the different beans that have included with the
BDK. Bean box provides an area to layout and connect the beans selected from

3

The Bean Developer Kit (BDK):
 The bean Developer kit (BDK), available for the java soft site is a simple example
of a tool enables you to create, configure and connect a set of beans.
the toolbox. Properties provide the ability to configure a selected bean.
JAR FILES:
 JAR files-stands for Java Archive Files.
 A jar file allows you to efficiently deploy a set of classes and their associated
resources. A set of beans can be placed into one JAR file.

Page

4

1
Jar technology makes it much easier to deliver and install software. Also, the
elements in a Jar file are compressed, which makes down loading a JAR file much
faster than separately downloading several uncompressed files.
MANIFEST FILES:
A developer must provide a manifest file to indicate, which of the components in
a JAR file are Java Beans. An example of a manifest file is provided in the
following listing. It defines a JAR file that contains four “.gif” files and one
“.class” file. The last entry is a bean.
Ex: NAME: sunw/deco/slides/slide0.gif NAME:
sunw/deco/slides/slide1.gif NAME:
sunw/deco/slides/slide2.gif NAME:
sunw/deco/slides/slide3.gif NAME:
sunw/deco/slides/slides.class Java-Bean:
True
Creating a JAR file:
The following command creates a Jar file named “xyz.jar” that contains all of the
“.class” and “.gif” files in the current directory
Ex: Jar cf xyz.jar *.class *.gif
If a manifest file such as xyz.mf is available, it can be used with the following
command:
Ex: Jar cfm xyz.jar yxz.mf *.class *.gif
INTROSPECTION:
A quality of a bean to express the properties of itself is known as Introspection.
Introspection can be done in two ways:
i.
Simple naming conventions
ii.
Providing additional classes to have introspection
Simple naming convention makes use of setter and getter methods.
In case of providing additional classes, for a bean class, to have the properties of
the bean, another class files are written, called for ex: Bean property class.
1.Bean Naming Conventions:

•

“setters”
– set or modify a bean property value
–

“getters”
retrieve property values from a bean

–

must start with “get”

5

–

Page

•

must start with “set”
For ex: Simple naming convention bean will be like
Class bean1
{
:
:
Property1 ( )
{
}
Property2 ( )
{
}
:
:
}
For ex: providing additional classes will be like:
Class bean1
{
:
:
}
Class properties
{
:
:
}

Page

6

Design patterns for Properties:
A property is a subset of a beans state. Three types of properties:
Simple
Boolean
Indexed
Simple Properties: A simple property has a single value. I t can be identified by the
following design patterns, where N is the name of the property and T is the type.
Ex:
public T getN( );
public void setN( T arg);
Boolean Properties: A Boolean property has a value of true or false. It can be identified
by the following design patterns, where N is the name of the property.
Ex:
public Boolean isN( );
public Boolean getN( );
public void setN(Boolean value);
Indexed Properties: An Indexed property consists of multiple values. It can be identified
by the following design patterns, where N is the name of the property and T is the type:
Ex:
public T getN (int index);
public void setN(int index, T value);
public void setN(T values[]);
Creating a new Bean: The steps that are involved in creating a new bean are:
1. Create a directory for the new bean.
2. Create the java source file(s).
3. Compile the source file(s).
4. Create a manifest file.
5. Generate a JAR file.
6. Start the BDK.
7. Test.
Creating a Bean:
Step 1: import java.awt.*; import
java.io.*;
public class Bean1 extends Canvas implements Serializable
{
public Bean1 ( )
{
setSize(60,40);
setBackground(Color.red);
}
}
Step 2:

javac Bean1.java

Step 3:

Manifest.txt
Name: Bean1.class
Java-Bean:true

Step 4:

jar cfm demo.jar manifest.txt Bean1.class

3
Dept. of Computer Science

Step 5:

Open the bean box:

Page

7

Java Bean
i. In the folder c:bdkbeanboxrun.bat
ii. “run.bat” will open the bean box tool.
Step 6:

File->Load->demo. jar / (or)
Copy demo.jar in beans / jars directory.

EVENTS
A bean class can fire off any type of event, including custom events. As with properties,
events are identified by a specific pattern of method names.
public void add<Event>Listener(<Event>Listener a)
public void remove<Event>Listener(<Event>Listener a)
The listener type must be a descendant of java.util.EventListener.
For example, a Swing JButton is a bean that fires action events when the user clicks on it.
JButton includes the following methods (actually inherited from AbstractButton), which
are the bean pattern for an event:
public void addActionListener(ActionListener l);
public void removeActionListener(ActionListener l);
Bean events are recognized by builder tools and can be used in wiring components
together. For example, you can wire a button's action event to make something happen,
like invoking another bean's method.

Customizers





The JavaBeans specification provides for user-defined customizers, through
which you can define a higher level of customization for bean properties than is
a available with property editors.
When you use a bean Customizer, you have complete control over how to
configure or edit a bean. A Customizer is an application that specifically targets a
bean’s customization. Sometimes properties are insufficient for representing a
bean's configurable attributes.
Customizers are used where sophisticated instructions would be needed to change
a bean, and where property editors are too primitive to achieve bean
customization.

All customizers must:

Implement the java.beans.Customizer interface This means implementing
methods to register PropertyChangeListener objects, and firing property change
events at those listeners when a change to the target bean has occurred.

8



Extend java.awt.Component or one of its subclasses.

Page




Implement a default constructor. Associate the customizer with its target class via
BeanInfo.getBeanDescriptor.

JavaBeans API
The JavaBeans functionality is provided by a set of classes and interfaces in the
java.beans package.
Interface

Description
Methods in this interface are used to initialize Beans that are
AppletInitializer
also applets.
This interface allows the designer to specify information about
BeanInfos
the events, methods and properties of a Bean.
This interface allows the designer to provide a graphical user
Customizer
interface through which a bean may be configured.
Methods in this interface determine if a bean is executing in
DesignMode
design mode.
A method in this interface is invoked when an exception has
ExceptionListener
occurred.
A method in this interface is invoked when a bound property is
PropertyChangeListener
changed.
Objects that implement this interface allow the designer to
PropertyEditor
change and display property values.
A method in this interface is invoked when a Constrained
VetoableChangeListener
property is changed.
Visibility

Methods in this interface allow a bean to execute in
environments where the GUI is not available.

JAVABEAN AP I:

Page

9

 The JavaBeans API architecture supplies a set of classes and interfaces to provide
introspection.
 The following figure represents a hierarchy of the FeatureDescriptor classes:
INTRODUCTION EJB







Enterprise Java Beans (EJB) is development architecture for building highly
scalable and robust enterprise level applications to be deployed on J2EE
compliant Application Server such as JBOSS, Web Logic etc.
EJB 3.0 is being a great shift from EJB 2.0 and makes development of EJB based
applications quite easy.
EJB stands for Enterprise Java Beans. EJB is an essential part of a J2EE platform.
J2EE platform have component based architecture to provide multi-tiered,
distributed and highly transactional features to enterprise level applications.
EJB provides an architecture to develop and deploy component based enterprise
applications considering robustness, high scalability and high performance. An
EJB application can be deployed on any of the application server compliant with
J2EE 1.3 standard specification. We'll be discussing EJB 3.0 in this tutorial.

 An EJB is just a collection of Java classes and XML file, bundled into a single
unit. The Java classes must follow certain rules and provide certain callback
methods.
 EJB is just a specification. It is not a product.
 EJBs are reusable components.

 EJB is a widely-adopted server-side component architecture for J2EE.

BENEFITS (OR) ADVANTAGES OF EJB

Page

10

 EJB components are designed to encapsulate business logic, and to protect the
application developer from having to worry about system level issues.














Application Server/ EJB container provides most of the system level services like
transaction handling, logging, load balancing, persistence mechanism, exception
handling and so on. Developer has to focus only on business logic of the
application.
EJB container manages life cycle of ejb instances thus developer needs not to
worry about when to create/delete ejb objects.
EJB components are server-side components written entirely in the Java
programming language
EJB components contain business logic only - no System-level programming
System-level services (i.e. "plumbing") such as transactions, security, Life-cycle,
threading, persistence, etc. are automatically managed for the EJB component by
the EJB server
EJB architecture is inherently transactional, distributed, portable, multi-tier,
scalable and secure
EJB components are fully portable across any EJB server and any OS, work with
any client.
Components are declaratively customized
There are four major parts to every bean: the home interface, the remote interface,
the implementation class and the XML deployment descriptor

11



Simplified development of large scale enterprise level application.

Page


EJB ARCHITECTURE:



EJB VS JAVABEANS
 The JavaBeans architecture is meant to provide a format for general-purpose
components whereas the EJB architecture provides a format for encapsulation
and management of business logic.
 JavaBeans has tier of execution at Client and EJB has at Server (specifically
business logic tier)

1. Session Beans

Page

VAR IETIES OF BEANS :

12

 In JavaBeans the runtime execution environment provides services like Java
libraries, Java application etc. The EJB runtime environment provides services
of Persistence, declarative transactions and security, connection pooling and
lifecycle services.



Stateful session bean
Stateless session bean

2. Entity Beans



With container-managed persistence
With bean-managed persistence

3. Message-Driven Beans

TYPES
EJB are primarily of three types which are briefly described below:
Type

Description

Session Bean

Session bean stores data of a particular user for a single session. It can
be stateful or stateless. It is less resource intensive as compared to entity beans.
Session bean gets destroyed as soon as user session terminates.

Entity Bean

Entity beans represents persistent data storage. User data can be saved to
database via entity beans and later on can be retrived from the database in the
entity bean.

Message Driven Bean

Message driven beans are used in context of JMS (Java Messaging Service).
Message Driven Beans can consumes JMS messages from external entities and
act accordingly.

STATELESS SESS ION BE AN LIFE CYCLE
1. There are two stages in the Lifecycle of Stateless Session Bean. These are:

Page

3. b) Method Ready Pool
In the Method Ready Pool stage bean has instance(s) in the memory of the EJB
container and it is ready to serve clients. On the startup of the EJB container some
instances of the bean are created and placed in the pool. EJB container creates the
new instance of the Bean and then sets the session context (setSessioncontext())
and it calls the ejbCreate() method to place the bean in the Method Ready Pool

13

2. a) Does Not Exist
In the Does Not Exist stage, bean does not have instance in the memory. In this
stage bean has not been instantiated.
stage. Container calls the ejbRemove() method to move the bean into Does Not
Exist state.
4. Following Diagram shows the Life cycle of Stateless Session Bean

STATEFUL SESS ION BEAN LIFE CYCLE
There are there stages in the life cycle of Stateful Session bean Life cycle. These are:
a) Does Not Exist
This is the Does Not Exist stage, bean does not have instance in the memory. In this stage
bean has not been instantiated.
b) Method Ready Pool
In the Method Ready Pool stage bean has instance in the memory of the EJB container
and it is ready to serve client. One instance of the Stateful Session Bean servers only one
client. When Client Calls create(args) method on the Home Interface, server creates new

Page

c) Passive state
In the Passive state the bean is passivated to conserve the resource. The passivate method
is called before the instance enters the "passive" state. The instance should release any
resources that it can re-acquire later in the ejbActivate() method. After the passivate
method completes, the instance must be in a state that allows the container to use the Java
Serialization protocol to externalize and store away the instance's state. ejbRemove or
Timeout moves the bean into Does Not Exist stage.

14

instance of the bean and sets the Session Context and then container calls the
ejbCreate(args) method on the bean and places the bean into Method Ready Pool stage.
ejbRemove or Timeout moves the bean into Does Not Exist stage.
Following Diagram shows the Life cycle of Statelful Session Bean

Advertisement

Page

 A requirement of any of the services provided by an EJB container like
transactions, scalability, persistence, security, future growth possibilities is an
appropriate reason to use EJB in the design of the application.

15

WHY USE EJBS IN YOUR DES IGN?

Weitere ähnliche Inhalte

Was ist angesagt?

intro unix/linux 08
intro unix/linux 08intro unix/linux 08
intro unix/linux 08duquoi
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaKavitha713564
 
Intro to OOP PHP and Github
Intro to OOP PHP and GithubIntro to OOP PHP and Github
Intro to OOP PHP and GithubJo Erik San Jose
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and OutputEduardo Bergavera
 
Unit 1-introduction to perl
Unit 1-introduction to perlUnit 1-introduction to perl
Unit 1-introduction to perlsana mateen
 
Program Structure in GNU/Linux (ELF Format)
Program Structure in GNU/Linux (ELF Format)Program Structure in GNU/Linux (ELF Format)
Program Structure in GNU/Linux (ELF Format)Varun Mahajan
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructorShivam Singhal
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010Bastian Feder
 
Structure of java program diff c- cpp and java
Structure of java program  diff c- cpp and javaStructure of java program  diff c- cpp and java
Structure of java program diff c- cpp and javaMadishetty Prathibha
 
Consuming Libraries with CMake
Consuming Libraries with CMakeConsuming Libraries with CMake
Consuming Libraries with CMakeRichard Thomson
 
Object Oriented Programming - Java
Object Oriented Programming -  JavaObject Oriented Programming -  Java
Object Oriented Programming - JavaDaniel Ilunga
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing fileskeeeerty
 
intro unix/linux 10
intro unix/linux 10intro unix/linux 10
intro unix/linux 10duquoi
 

Was ist angesagt? (20)

intro unix/linux 08
intro unix/linux 08intro unix/linux 08
intro unix/linux 08
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Intro to OOP PHP and Github
Intro to OOP PHP and GithubIntro to OOP PHP and Github
Intro to OOP PHP and Github
 
Spsl unit1
Spsl   unit1Spsl   unit1
Spsl unit1
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and Output
 
JAVA BASICS
JAVA BASICSJAVA BASICS
JAVA BASICS
 
Unit 1-introduction to perl
Unit 1-introduction to perlUnit 1-introduction to perl
Unit 1-introduction to perl
 
ELF
ELFELF
ELF
 
Program Structure in GNU/Linux (ELF Format)
Program Structure in GNU/Linux (ELF Format)Program Structure in GNU/Linux (ELF Format)
Program Structure in GNU/Linux (ELF Format)
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructor
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010
 
Structure of java program diff c- cpp and java
Structure of java program  diff c- cpp and javaStructure of java program  diff c- cpp and java
Structure of java program diff c- cpp and java
 
Consuming Libraries with CMake
Consuming Libraries with CMakeConsuming Libraries with CMake
Consuming Libraries with CMake
 
Object Oriented Programming - Java
Object Oriented Programming -  JavaObject Oriented Programming -  Java
Object Oriented Programming - Java
 
Handling I/O in Java
Handling I/O in JavaHandling I/O in Java
Handling I/O in Java
 
Java IO
Java IOJava IO
Java IO
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing files
 
intro unix/linux 10
intro unix/linux 10intro unix/linux 10
intro unix/linux 10
 

Ähnlich wie WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH

Ähnlich wie WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH (20)

Javabeans .pdf
Javabeans .pdfJavabeans .pdf
Javabeans .pdf
 
introduction of Java beans
introduction of Java beansintroduction of Java beans
introduction of Java beans
 
Unit iv
Unit ivUnit iv
Unit iv
 
Java beans
Java beansJava beans
Java beans
 
Java beans
Java beansJava beans
Java beans
 
Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
 
Java Beans Unit 4(part 2)
Java Beans Unit 4(part 2)Java Beans Unit 4(part 2)
Java Beans Unit 4(part 2)
 
Java beans
Java beansJava beans
Java beans
 
Spring by rj
Spring by rjSpring by rj
Spring by rj
 
Java beans
Java beansJava beans
Java beans
 
02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions
 
Javabean1
Javabean1Javabean1
Javabean1
 
Java beans
Java beansJava beans
Java beans
 
How to use the java bean api library
How to use the java bean api libraryHow to use the java bean api library
How to use the java bean api library
 
How to use the java bean api library
How to use the java bean api libraryHow to use the java bean api library
How to use the java bean api library
 
P20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptxP20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptx
 
How to run java program without IDE
How to run java program without IDEHow to run java program without IDE
How to run java program without IDE
 
Ecom lec3 16_ej_bs
Ecom lec3 16_ej_bsEcom lec3 16_ej_bs
Ecom lec3 16_ej_bs
 
Universal Java Beans with DB2 from 1999, early Internet work
Universal Java Beans with DB2 from 1999, early Internet workUniversal Java Beans with DB2 from 1999, early Internet work
Universal Java Beans with DB2 from 1999, early Internet work
 

Mehr von Bhavsingh Maloth

web programming Unit VIII complete about python by Bhavsingh Maloth
web programming Unit VIII complete about python  by Bhavsingh Malothweb programming Unit VIII complete about python  by Bhavsingh Maloth
web programming Unit VIII complete about python by Bhavsingh MalothBhavsingh Maloth
 
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTHWeb programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTHBhavsingh Maloth
 
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTHBhavsingh Maloth
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHBhavsingh Maloth
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHBhavsingh Maloth
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothBhavsingh Maloth
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothBhavsingh Maloth
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Bhavsingh Maloth
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Bhavsingh Maloth
 
98286173 government-polytechnic-lecturer-exam-paper-2012
98286173 government-polytechnic-lecturer-exam-paper-201298286173 government-polytechnic-lecturer-exam-paper-2012
98286173 government-polytechnic-lecturer-exam-paper-2012Bhavsingh Maloth
 
Web Programming UNIT VIII notes
Web Programming UNIT VIII notesWeb Programming UNIT VIII notes
Web Programming UNIT VIII notesBhavsingh Maloth
 

Mehr von Bhavsingh Maloth (17)

web programming Unit VIII complete about python by Bhavsingh Maloth
web programming Unit VIII complete about python  by Bhavsingh Malothweb programming Unit VIII complete about python  by Bhavsingh Maloth
web programming Unit VIII complete about python by Bhavsingh Maloth
 
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTHWeb programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
Web programming unit IIII XML &DOM NOTES BY BHAVSINGH MALOTH
 
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh maloth
 
Polytechnic jan 6 2012
Polytechnic jan 6 2012Polytechnic jan 6 2012
Polytechnic jan 6 2012
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007
 
Appsc poly key 2013
Appsc poly key 2013Appsc poly key 2013
Appsc poly key 2013
 
Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007Appscpolytechniclecturersg.s.paper2007
Appscpolytechniclecturersg.s.paper2007
 
Appsc poly key 2013
Appsc poly key 2013Appsc poly key 2013
Appsc poly key 2013
 
98286173 government-polytechnic-lecturer-exam-paper-2012
98286173 government-polytechnic-lecturer-exam-paper-201298286173 government-polytechnic-lecturer-exam-paper-2012
98286173 government-polytechnic-lecturer-exam-paper-2012
 
Unit vii wp ppt
Unit vii wp pptUnit vii wp ppt
Unit vii wp ppt
 
Wp unit III
Wp unit IIIWp unit III
Wp unit III
 
Web Programming UNIT VIII notes
Web Programming UNIT VIII notesWeb Programming UNIT VIII notes
Web Programming UNIT VIII notes
 
Wp unit 1 (1)
Wp  unit 1 (1)Wp  unit 1 (1)
Wp unit 1 (1)
 

Kürzlich hochgeladen

physiotherapy in Acne condition.....pptx
physiotherapy in Acne condition.....pptxphysiotherapy in Acne condition.....pptx
physiotherapy in Acne condition.....pptxAneriPatwari
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Employablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptxEmployablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptxryandux83rd
 
The Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian CongressThe Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian CongressMaria Paula Aroca
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipKarl Donert
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptxmary850239
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfChristalin Nelson
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...DhatriParmar
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 

Kürzlich hochgeladen (20)

physiotherapy in Acne condition.....pptx
physiotherapy in Acne condition.....pptxphysiotherapy in Acne condition.....pptx
physiotherapy in Acne condition.....pptx
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Employablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptxEmployablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptx
 
The Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian CongressThe Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian Congress
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenship
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx
 
Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdf
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 

WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH

  • 1. WEB PROGRAMMING UNIT-IV PREPARED BY BHAVSINGH MALOTH JAVA BEANS: o Java bean is a reusable s software component which is visible and customizable.  A JavaBean is a specially constructed Java class written in the Java and coded according to the JavaBeans API specifications. Following are the unique characteristics that distinguish a JavaBean from other Java classes:  It provides a default, no-argument constructor.  It should be serializable and implement the Serializable interface.  It may have a number of properties which can be read or written.  It may have a number of "getter" and "setter" methods for the properties. JavaBeans Properties:   A JavaBean property is a named attribute that can be accessed by the user of the object. The attribute can be of any Java data type, including classes that you define. A JavaBean property may be read, write, read only, or write only. JavaBean properties are accessed through two methods in the JavaBean's implementation class: Method getPropertyName() setPropertyName()  Description For example, if property name is firstName, your method name would be getFirstName() to read that property. This method is called accessor. For example, if property name is firstName, your method name would be setFirstName() to write that property. This method is called mutator. A read-only attribute will have only a getPropertyName() method, and a writeonly attribute will have only a setPropertyName() method. Page  The properties, events, and methods of a bean that are exposed to an application builder tool can be controlled. 1 ADVANTAGES OF JAVA BEANS:  A bean obtains all the benefits of java’s “write once, run anywhere” paradigm.
  • 2.  A bean may be designed to operate correctly in different locals, which makes it useful in global markets.  The configuration settings of a bean can be saved in persistent storage and restored at a later time.  A bean may register to receive events for other objects and can generate events that are sent to other objects. Disadvantages with JavaBeans  A class with a nullary constructor is subject to being instantiated in an invalid state. If such a class is instantiated manually by a developer (rather than automatically by some kind of framework), the developer might not realize that the class has been improperly instantiated. The compiler can’t detect such a problem, and even if it’s documented, there’s no guarantee that the developer will see the documentation.  Having to create a getter for every property and a setter for many, most, or all of them can lead to an immense quantity of boilerplate code.  WHY USE JAVA BEAN? Page 2 According to Java white paper, it is a reusable software component. A bean encapsulates many objects into one object, so we can access this object from multiple places. Moreover, it provides the easy maintenance.
  • 3. Page Starting the BDK: To start the BDK, follow these steps:  Change to the directory c:bdkbeanbox.  Execute the batch file called “run.bat” This causes the BDK to display the three windows. Toolbox lists all of the different beans that have included with the BDK. Bean box provides an area to layout and connect the beans selected from 3 The Bean Developer Kit (BDK):  The bean Developer kit (BDK), available for the java soft site is a simple example of a tool enables you to create, configure and connect a set of beans.
  • 4. the toolbox. Properties provide the ability to configure a selected bean. JAR FILES:  JAR files-stands for Java Archive Files.  A jar file allows you to efficiently deploy a set of classes and their associated resources. A set of beans can be placed into one JAR file. Page 4 1
  • 5. Jar technology makes it much easier to deliver and install software. Also, the elements in a Jar file are compressed, which makes down loading a JAR file much faster than separately downloading several uncompressed files. MANIFEST FILES: A developer must provide a manifest file to indicate, which of the components in a JAR file are Java Beans. An example of a manifest file is provided in the following listing. It defines a JAR file that contains four “.gif” files and one “.class” file. The last entry is a bean. Ex: NAME: sunw/deco/slides/slide0.gif NAME: sunw/deco/slides/slide1.gif NAME: sunw/deco/slides/slide2.gif NAME: sunw/deco/slides/slide3.gif NAME: sunw/deco/slides/slides.class Java-Bean: True Creating a JAR file: The following command creates a Jar file named “xyz.jar” that contains all of the “.class” and “.gif” files in the current directory Ex: Jar cf xyz.jar *.class *.gif If a manifest file such as xyz.mf is available, it can be used with the following command: Ex: Jar cfm xyz.jar yxz.mf *.class *.gif INTROSPECTION: A quality of a bean to express the properties of itself is known as Introspection. Introspection can be done in two ways: i. Simple naming conventions ii. Providing additional classes to have introspection Simple naming convention makes use of setter and getter methods. In case of providing additional classes, for a bean class, to have the properties of the bean, another class files are written, called for ex: Bean property class. 1.Bean Naming Conventions: • “setters” – set or modify a bean property value – “getters” retrieve property values from a bean – must start with “get” 5 – Page • must start with “set”
  • 6. For ex: Simple naming convention bean will be like Class bean1 { : : Property1 ( ) { } Property2 ( ) { } : : } For ex: providing additional classes will be like: Class bean1 { : : } Class properties { : : } Page 6 Design patterns for Properties: A property is a subset of a beans state. Three types of properties: Simple Boolean Indexed
  • 7. Simple Properties: A simple property has a single value. I t can be identified by the following design patterns, where N is the name of the property and T is the type. Ex: public T getN( ); public void setN( T arg); Boolean Properties: A Boolean property has a value of true or false. It can be identified by the following design patterns, where N is the name of the property. Ex: public Boolean isN( ); public Boolean getN( ); public void setN(Boolean value); Indexed Properties: An Indexed property consists of multiple values. It can be identified by the following design patterns, where N is the name of the property and T is the type: Ex: public T getN (int index); public void setN(int index, T value); public void setN(T values[]); Creating a new Bean: The steps that are involved in creating a new bean are: 1. Create a directory for the new bean. 2. Create the java source file(s). 3. Compile the source file(s). 4. Create a manifest file. 5. Generate a JAR file. 6. Start the BDK. 7. Test. Creating a Bean: Step 1: import java.awt.*; import java.io.*; public class Bean1 extends Canvas implements Serializable { public Bean1 ( ) { setSize(60,40); setBackground(Color.red); } } Step 2: javac Bean1.java Step 3: Manifest.txt Name: Bean1.class Java-Bean:true Step 4: jar cfm demo.jar manifest.txt Bean1.class 3 Dept. of Computer Science Step 5: Open the bean box: Page 7 Java Bean
  • 8. i. In the folder c:bdkbeanboxrun.bat ii. “run.bat” will open the bean box tool. Step 6: File->Load->demo. jar / (or) Copy demo.jar in beans / jars directory. EVENTS A bean class can fire off any type of event, including custom events. As with properties, events are identified by a specific pattern of method names. public void add<Event>Listener(<Event>Listener a) public void remove<Event>Listener(<Event>Listener a) The listener type must be a descendant of java.util.EventListener. For example, a Swing JButton is a bean that fires action events when the user clicks on it. JButton includes the following methods (actually inherited from AbstractButton), which are the bean pattern for an event: public void addActionListener(ActionListener l); public void removeActionListener(ActionListener l); Bean events are recognized by builder tools and can be used in wiring components together. For example, you can wire a button's action event to make something happen, like invoking another bean's method. Customizers    The JavaBeans specification provides for user-defined customizers, through which you can define a higher level of customization for bean properties than is a available with property editors. When you use a bean Customizer, you have complete control over how to configure or edit a bean. A Customizer is an application that specifically targets a bean’s customization. Sometimes properties are insufficient for representing a bean's configurable attributes. Customizers are used where sophisticated instructions would be needed to change a bean, and where property editors are too primitive to achieve bean customization. All customizers must: Implement the java.beans.Customizer interface This means implementing methods to register PropertyChangeListener objects, and firing property change events at those listeners when a change to the target bean has occurred. 8  Extend java.awt.Component or one of its subclasses. Page 
  • 9.  Implement a default constructor. Associate the customizer with its target class via BeanInfo.getBeanDescriptor. JavaBeans API The JavaBeans functionality is provided by a set of classes and interfaces in the java.beans package. Interface Description Methods in this interface are used to initialize Beans that are AppletInitializer also applets. This interface allows the designer to specify information about BeanInfos the events, methods and properties of a Bean. This interface allows the designer to provide a graphical user Customizer interface through which a bean may be configured. Methods in this interface determine if a bean is executing in DesignMode design mode. A method in this interface is invoked when an exception has ExceptionListener occurred. A method in this interface is invoked when a bound property is PropertyChangeListener changed. Objects that implement this interface allow the designer to PropertyEditor change and display property values. A method in this interface is invoked when a Constrained VetoableChangeListener property is changed. Visibility Methods in this interface allow a bean to execute in environments where the GUI is not available. JAVABEAN AP I: Page 9  The JavaBeans API architecture supplies a set of classes and interfaces to provide introspection.  The following figure represents a hierarchy of the FeatureDescriptor classes:
  • 10. INTRODUCTION EJB     Enterprise Java Beans (EJB) is development architecture for building highly scalable and robust enterprise level applications to be deployed on J2EE compliant Application Server such as JBOSS, Web Logic etc. EJB 3.0 is being a great shift from EJB 2.0 and makes development of EJB based applications quite easy. EJB stands for Enterprise Java Beans. EJB is an essential part of a J2EE platform. J2EE platform have component based architecture to provide multi-tiered, distributed and highly transactional features to enterprise level applications. EJB provides an architecture to develop and deploy component based enterprise applications considering robustness, high scalability and high performance. An EJB application can be deployed on any of the application server compliant with J2EE 1.3 standard specification. We'll be discussing EJB 3.0 in this tutorial.  An EJB is just a collection of Java classes and XML file, bundled into a single unit. The Java classes must follow certain rules and provide certain callback methods.  EJB is just a specification. It is not a product.  EJBs are reusable components.  EJB is a widely-adopted server-side component architecture for J2EE. BENEFITS (OR) ADVANTAGES OF EJB Page 10  EJB components are designed to encapsulate business logic, and to protect the application developer from having to worry about system level issues.
  • 11.         Application Server/ EJB container provides most of the system level services like transaction handling, logging, load balancing, persistence mechanism, exception handling and so on. Developer has to focus only on business logic of the application. EJB container manages life cycle of ejb instances thus developer needs not to worry about when to create/delete ejb objects. EJB components are server-side components written entirely in the Java programming language EJB components contain business logic only - no System-level programming System-level services (i.e. "plumbing") such as transactions, security, Life-cycle, threading, persistence, etc. are automatically managed for the EJB component by the EJB server EJB architecture is inherently transactional, distributed, portable, multi-tier, scalable and secure EJB components are fully portable across any EJB server and any OS, work with any client. Components are declaratively customized There are four major parts to every bean: the home interface, the remote interface, the implementation class and the XML deployment descriptor 11  Simplified development of large scale enterprise level application. Page 
  • 12. EJB ARCHITECTURE:  EJB VS JAVABEANS  The JavaBeans architecture is meant to provide a format for general-purpose components whereas the EJB architecture provides a format for encapsulation and management of business logic.  JavaBeans has tier of execution at Client and EJB has at Server (specifically business logic tier) 1. Session Beans Page VAR IETIES OF BEANS : 12  In JavaBeans the runtime execution environment provides services like Java libraries, Java application etc. The EJB runtime environment provides services of Persistence, declarative transactions and security, connection pooling and lifecycle services.
  • 13.   Stateful session bean Stateless session bean 2. Entity Beans   With container-managed persistence With bean-managed persistence 3. Message-Driven Beans TYPES EJB are primarily of three types which are briefly described below: Type Description Session Bean Session bean stores data of a particular user for a single session. It can be stateful or stateless. It is less resource intensive as compared to entity beans. Session bean gets destroyed as soon as user session terminates. Entity Bean Entity beans represents persistent data storage. User data can be saved to database via entity beans and later on can be retrived from the database in the entity bean. Message Driven Bean Message driven beans are used in context of JMS (Java Messaging Service). Message Driven Beans can consumes JMS messages from external entities and act accordingly. STATELESS SESS ION BE AN LIFE CYCLE 1. There are two stages in the Lifecycle of Stateless Session Bean. These are: Page 3. b) Method Ready Pool In the Method Ready Pool stage bean has instance(s) in the memory of the EJB container and it is ready to serve clients. On the startup of the EJB container some instances of the bean are created and placed in the pool. EJB container creates the new instance of the Bean and then sets the session context (setSessioncontext()) and it calls the ejbCreate() method to place the bean in the Method Ready Pool 13 2. a) Does Not Exist In the Does Not Exist stage, bean does not have instance in the memory. In this stage bean has not been instantiated.
  • 14. stage. Container calls the ejbRemove() method to move the bean into Does Not Exist state. 4. Following Diagram shows the Life cycle of Stateless Session Bean STATEFUL SESS ION BEAN LIFE CYCLE There are there stages in the life cycle of Stateful Session bean Life cycle. These are: a) Does Not Exist This is the Does Not Exist stage, bean does not have instance in the memory. In this stage bean has not been instantiated. b) Method Ready Pool In the Method Ready Pool stage bean has instance in the memory of the EJB container and it is ready to serve client. One instance of the Stateful Session Bean servers only one client. When Client Calls create(args) method on the Home Interface, server creates new Page c) Passive state In the Passive state the bean is passivated to conserve the resource. The passivate method is called before the instance enters the "passive" state. The instance should release any resources that it can re-acquire later in the ejbActivate() method. After the passivate method completes, the instance must be in a state that allows the container to use the Java Serialization protocol to externalize and store away the instance's state. ejbRemove or Timeout moves the bean into Does Not Exist stage. 14 instance of the bean and sets the Session Context and then container calls the ejbCreate(args) method on the bean and places the bean into Method Ready Pool stage. ejbRemove or Timeout moves the bean into Does Not Exist stage.
  • 15. Following Diagram shows the Life cycle of Statelful Session Bean Advertisement Page  A requirement of any of the services provided by an EJB container like transactions, scalability, persistence, security, future growth possibilities is an appropriate reason to use EJB in the design of the application. 15 WHY USE EJBS IN YOUR DES IGN?