0% found this document useful (0 votes)
0 views7 pages

Enterprise Java Bean (Advanced Java)

Enterprise Java Beans (EJB) is a specification for developing secure, robust, and scalable distributed applications, requiring an application server for lifecycle management, security, and transaction management. There are three types of EJB: Session Beans, Message Driven Beans, and deprecated Entity Beans, with EJB differing from RMI in that it provides middleware services automatically and is a server-side component. The Beans Development Kit (BDK) aids in developing JavaBeans components, while JAR files are used for packaging EJB applications, containing necessary classes and deployment descriptors.

Uploaded by

sekhon85578
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views7 pages

Enterprise Java Bean (Advanced Java)

Enterprise Java Beans (EJB) is a specification for developing secure, robust, and scalable distributed applications, requiring an application server for lifecycle management, security, and transaction management. There are three types of EJB: Session Beans, Message Driven Beans, and deprecated Entity Beans, with EJB differing from RMI in that it provides middleware services automatically and is a server-side component. The Beans Development Kit (BDK) aids in developing JavaBeans components, while JAR files are used for packaging EJB applications, containing necessary classes and deployment descriptors.

Uploaded by

sekhon85578
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Enterprise Java Bean

EJB is an acronym for enterprise java bean. It is a specification provided by Sun


Microsystems to develop secured, robust and scalable distributed applications.

To run EJB application, you need an application server (EJB Container) such as Jboss,
Glassfish, Weblogic, Websphere etc. It performs:

a. life cycle management,


b. security,
c. transaction management, and
d. object pooling.

EJB application is deployed on the server, so it is called server side component also.

EJB is like COM (Component Object Model) provided by Microsoft. But, it is different
from Java Bean, RMI and Web Services.

When use Enterprise Java Bean?


1. Application needs Remote Access. In other words, it is distributed.
2. Application needs to be scalable. EJB applications supports load balancing,
clustering and fail-over.
3. Application needs encapsulated business logic. EJB application is separated
from presentation and persistent layer.

Types of Enterprise Java Bean


There are 3 types of enterprise bean in java.

Session Bean

Session bean contains business logic that can be invoked by local, remote or
webservice client.

Message Driven Bean


Like Session Bean, it contains the business logic but it is invoked by passing message.

Entity Bean

It encapsulates the state that can be persisted in the database. It is deprecated. Now,
it is replaced with JPA (Java Persistent API).

Difference between RMI and EJB


Both RMI and EJB, provides services to access an object running in another JVM (known
as remote object) from another JVM. The differences between RMI and EJB are given
below:

RMI EJB

In RMI, middleware services such as security, In EJB, middleware services are


transaction management, object pooling etc. need to provided by EJB Container
be done by the java programmer. automatically.

RMI is not a server-side component. It is not required EJB is a server-side component, it


to be deployed on the server. is required to be deployed on the
server.

RMI is built on the top of socket programming. EJB technology is built on the top
of RMI.
EJB and Webservice
In EJB, bean component and bean client both must be written in java language.

If bean client need to be written in other language such as .net, php etc, we need to
go with webservices (SOAP or REST). So EJB with web service will be better option.

Disadvantages of EJB
1. Requires application server
2. Requires only java client. For other language client, you need to go for
webservice.
3. Complex to understand and develop ejb applications.

Beans Development Kit (BDK)

The Beans Development Kit (BDK) includes example beans and the
BeanBox tool. The BDK is optional; you can create beans without it.
However, the BeanBox tool is extremely useful and is used
throughout this book.

The BeanBox Tool

JavaSoft's Beans Development Kit provides a simple application


named the BeanBox tool for testing your beans and simple
applications composed of beans. The BeanBox tool is itself a
composite JavaBean application. The BeanBox tool displays a form
(the BeanBox window) where you place and arrange beans. You
then connect the beans together so that they can communicate.
The resulting application can be saved and reloaded through the
BeanBox tool.
The Beans Development Kit (BDK) is intended to support the early development
of JavaBeans components and to act as a standard reference base for both bean
TM

developers and tool vendors. The BDK provides a reference bean container, the
"BeanBox" and a variety of reusable example source code (in the demo and
beanbox subdirectories) for use by both bean developers and tools developers.

The BDK is not intended for use by application developers, nor is it intended to be
a full-fledged application development environment. Instead application
developers should check the various Java application development environments
supporting JavaBeans.

System Requirements
This BDK 1.0 release requires you to have installed the Java Development Kit
(JDK) 1.1. We recommend using JDK 1.1.4 (or later) as this fixes some GUI
related bugs.

The BDK is qualified for Solaris 2.5, Windows 95, and Windows NT 4.0.
However the BDK is "pure Java" and should run on any JDK 1.1 enabled system.

Licensing Information
Check the BDK Licensing Terms for terms and conditions governing the use and
redistribution of the BDK.
Contents

 The JavaBeans API sources. These are provided as .java reference sources
in the "apis" sub-directory. Note that the sources correspond to the class
files shipped in JDK 1.1.4
 The BeanBox test container. This allows you to test out your new beans
against a reference container, and also acts an example of how to build a
bean container.
o Running the BeanBox
o Adding new beans to the BeanBox
o Making applets from beans using the BeanBox
 We provide a dozen example beans which can run in the BeanBox and
demonstrate various bean behaviour.
 We provide a variety of reference source code.
 Makefile information.

And at our web site...


There is also additional information at our web site, including
The ejb-jar File
The JAR file format is a platform-independent format for
compressing, packaging, and delivering several files together.
Based on the ZIP file format and the ZLIB compression standards,
the JAR ( Java archive) packages and tool were originally
developed to make downloads of Java applets more efficient. As a
packaging mechanism, however, the JAR file format is a convenient
way to “shrink-wrap” components and other software for delivery to
third parties. The original JavaBeans component architecture
depends on JAR files for packaging, as does Enterprise
JavaBeans. The goal in using the JAR file format is to package all
the classes and interfaces associated with one or more beans,
including the deployment descriptor, into one file.

The JAR file is created using a vendor-specific tool, or using


the jar utility that is part of the Java 2, Standard Edition
development kit. An ejb-jar file contains:

 The XML deployment descriptor


 The bean classes
 The remote and home interfaces
 The primary key class
 Dependent classes and interfaces

The XML deployment descriptor must be located in the path META-


INF/[Link] and must contain all the deployment information for
all the beans in the ejb-jar file. For each bean declared in the XML
deployment descriptor, the ejb-jar file must contain its bean class,
remote and home interfaces, and dependent classes and
interfaces. Dependent classes and interfaces are usually things like
application-specific exceptions, business interfaces and other ...
The JavaBeans API

JavaBeans technology is a component architecture for the Java 2 Platform, Standard


Edition (J2SE). JavaBean components are known as beans. Beans are reusable software
programs that you can develop and assemble easily to create sophisticated applications.
JavaBeans technology is based on the JavaBeans specification.
The JavaBeans API and its implementation are contained in the [Link] package. A
few of the classes are used by beans while they run in an application. For example the
event classes are used by beans that fire property and vetoable change events
(see PropertyChangeEvent). However, most of the classes in this package are meant to
be used by a bean editor that is, a development environment for customizing and
putting together beans to create an application. In particular, these classes help the
bean editor create a user interface that the user can use to customize the bean. For
example, a bean may contain a property of a special type that a bean editor may not
know how to handle. By using the PropertyEditor interface, a bean developer can
provide an editor for this special type.
The [Link] package provides support for long-term persistence - reading and writing
a bean as a textual representation of its property values. The property values are treated
as beans, and are recursively read or written to capture their publicly available state.
This approach is suitable for long-term storage because it relies only on public API,
rather than the likely-to-change private implementation. You read and write beans in
XML format using the XMLDecoder and XMLEncoder classes, respectively. One notable
feature of the persistence scheme is that reading in a bean requires no special
knowledge of the bean.
To minimize the resources used by a bean, the classes used by bean editors are loaded
only when the bean is being edited. They are not needed while the bean is running in an
application and therefore not loaded. This information is kept in what's called a bean-info
(see BeanInfo). These classes is not contained in core (real-time) library ([Link]). You
should use additional (design-time) library ([Link]). This library contains bean-info
classes for Swing.
Package [Link] provides classes and interfaces relating to bean
context. A bean context is a container for beans and defines the execution environment
for the beans it contains. There can be several beans in a single bean context, and a
bean context can be nested within another bean context. This package also contains
events and listener interface for beans being added and removed from a bean context.

Future plans
JSR 273: Design-Time API for JavaBeans <[Link]
This JSR extends the JavaBeans specification and APIs to improve design-time
functionality for component authors to leverage within the visual design environments in
IDEs.
JSR 295: Beans Binding <[Link]
This JSR provides an API that allows two properties of two beans to stay in sync.

Source Code & Building


The source code of the JavaBeans API and its implementation resides in the
"src/share/classes" directory of the workspace. Java classes are located corresponding to
the package hierarchy (eg [Link]) are in
"src/share/classes/java/beans/[Link]".
Non-public classes reside in:
 /src/share/classes/sun/beans
The makefile structure is as follows:
 make/java/beans - builds the JavaBeans API and its implementation in
 packages [Link] and [Link].
 make/sun/beans - builds default editors and bean-info classes.

You might also like