Sie sind auf Seite 1von 3

Difference between JavaBeans and EJB:

Oi, Check and select the required points alone, some may be
repetition of the same idea,

1.

JavaBeans:-
-----------------
Basically used to CUSTOMIZE EXISTING OBJECTS. I.e. you can
create USER OBJECTS, which are based on existing objects.
For Example: A default button operates as a Single-State Switch. I.e. when you
press a button on a web page, it doesn't remain pressed. In fact, it immediately
bounces back to its OFF state like a Door-Bell.

Now, let's say, you need a button, which should have 2 stable states, like the
typical Electrical Light Switch. So, in this case, what you can do is, take an
existing button (having 1 stable state) and CUSTOMIZE it so that it has 2 stable
states.
This is possible using JavaBeans.

Enterprise Java Beans (EJB):-


-----------------------------------------
EJB is a completely different concept than the one mentioned
above. It is NOT used to customize existing objects. Instead
they are basically used to STANDARDIZE the way, in which
business logic is written.
For Example: We can write our business logic as well as the GUI logic, inside
Servlets/Applets/ Standalone applications itself. But this way, there will be no
clear distinction between the Code that is responsible for the GUI and the actual
Business logic code, because everything is written inside the same class file.

So, to COMPONENTIZE we write business logic in separate class files than the
GUI logic, thereby making a clear distinction between the responsibilities

2.

Java Beans and EJBs are used for different purposes altogether though both
specifications are provided by Sun micro Systems. Java Beans are mainly meant
for building extendable components and typically contain getters and setters for
all its data members along with other required functionality. EJBs are server side
programs that typically implement middle layer business functionality providing
3 - layer architecture for applications. EJBs can be Entity Session or Message
depending on the required functionality. Most of the critical services are provided
by EJB containers and thus allowing the programmmer to concentrate on the
business logic on hand.
3.

A Java Bean is a software component written in the


Java programming language that conforms to the
JavaBeans component specification.
The JavaBeans APIs became part of the "core" Java APIs
as of the 1.1 release of the JDK. The JavaBeans
specification defines a Java-based software component
model that adds a number of features to the
Java programming language. Some of these features
include:

introspection
customization
events
properties
persistence

Enterprise JavaBeans (EJBs) are Java-based software components


that are built to comply with Java's EJB specification
and run inside of an EJB container supplied by
a J2EE provider. An EJB container provides distributed
application functionality such as transaction
support, persistence and lifecycle management for the EJBs

4.
JB

JavaBeans takes a low-level approach to developing reusable software


components that can be used for building different types of Java applications
(applets, stand-alone apps, etc.) in any area.

EJB

Enterprise JavaBeans takes a high-level approach to building distributed


systems. It frees the application developer to concentrate on programming only
the business logic while removing the need to write all the "plumbing" code that's
required in any enterprise application.

5.

1. JavaBeans may be visible or invisible at runtime. For


example, the visual GUI component may be a button, list
box, graphic or a chart.
An EJB is a non visual, remote object.
2. JavaBeans are intended to be local to a single process
and are primarily intended to run on the client side. Although
one can develop server-side Java Beans, it is far easier to
develop them using the EJB specification instead.
EJB's are remotely executable components or business
objects that can be deployed only on the server.
3. JavaBeans is a component technology to create generic
Java components that can be composed together into applets
and applications.
Even though EJB is a component technology, it neither
builds upon nor extends the original Java Bean specification.
4. Java Beans have an external interface called the properties
Interface, which allows a builder tool to interpret the
functionality of the bean.
EJBs have a deployment descriptor that describes its
functionality to an external builder tool or IDE
5. Java Beans may have Bean Info classes, property editors or
customizers
EJB's have no concept of BeanInfo classes, property
editors or customizes and provide no additional information
other than that described in the deployment descriptor.

6. JavaBeans are not typed.


EJBs are of two types - session beans and entity beans.
7. No explicit support exists for transactions in java Beans.

EJB's may be transactional and the EJB servers provide


transactional support.

8. Component bridges are available for JavaBeans. For ex: a


javabean can also be deployed as an ActiveX control.
An EJB cannot be deployed as an ActiveX control because
ActiveX controls are intended to run at the desktop and
EJB's are server side components. However CORBA-IIOP
compatibility via the EJB-to-CORBA mapping is defined by the
OMG.

Das könnte Ihnen auch gefallen