0% found this document useful (0 votes)
52 views3 pages

Diff B/W Java Bean and Ejb: Mybean Serializable

Java bean is just a set of conventions for reusable components, while EJB is an enterprise standard for developing reusable business components that run within an EJB container in a J2EE application server. Specifically, a Java bean follows conventions like having a public default constructor and getter and setter methods prefixed with get and set, while an EJB runs within an EJB container and can support features like transactions. While both are reusable components, EJBs are intended specifically for server-side enterprise applications.

Uploaded by

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

Diff B/W Java Bean and Ejb: Mybean Serializable

Java bean is just a set of conventions for reusable components, while EJB is an enterprise standard for developing reusable business components that run within an EJB container in a J2EE application server. Specifically, a Java bean follows conventions like having a public default constructor and getter and setter methods prefixed with get and set, while an EJB runs within an EJB container and can support features like transactions. While both are reusable components, EJBs are intended specifically for server-side enterprise applications.

Uploaded by

Zacharia Alex
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Diff b/w Java Bean and ejb

A JavaBean is just a plain old Java object that conforms to certain conventions including the
use of accessor functions (getFoo/setFoo) for member access, provision of a default
constructor and a few other things like that.

An Enterprise JavaBean is a component in a Java EE application server which comes in


several flavours, the details of which vary by which version of Java EE you're talking about
(or, more specifically, which specific set of EJB specifications are involved).

JavaBeans were originally mostly intended to be used in builder tools by providing a known
interface which could be looked for through introspection in the tools. They quickly turned
into what amounts to a religion, however.

Enterprise JavaBeans are intended to provide encapsulated business logic for enterprise
applications within a general container that provided things like session management,
security, resource pooling, etc. as services thus allowing the business logic to be (relatively)
untainted by these cross-cutting concerns. (Whether or not they accomplished this is a
matter that is up for debate, given how difficult they were to use at first. More recent
versions of the specification have made this easier, however. Legacy apps, though, are still
a pain and sadly likely the majority of the EJBs you're likely to encounter.)

Java bean is just a set of conventions. EJB is a standard for J2EE business components.

Specifically a Java bean:

 has a public default constructor;


 readable property methods precedes with "get";
 writable property methods precedes with "set"; and
 is Serializable.
For example, a Java bean with a property of "margin" would minimally look like this:

public class MyBean implements Serializable {


private int margin;

public MyBean() { }
public int getMargin() { return margin; }
public void setMargin(int margin) { this.margin = margin; }
}
EJB, despite the name, is almost completely unrelated.
Java Beans :

- Java beans are reusable components that can be used for customized user objects.

- Java beans adhere to two methods known as setter and getter methods and one public
constructor.

- For example: an employee object can be used to set (setter method) and get (getter method)
employee details which are a customized object.

- AWT and Swing components are based on java beans.

Enterprise Java Beans (EJB) :

- EJB are reusable components that are developed to comply with enterprise specification
adhering to setter and getter methods and one public constructor.

- These beans are running in an EJB container of J2EE architecture.

JavaBeans :

- JavaBeans may be visible or nonvisible at runtime.

- 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 JavaBeans, it is far easier to develop them
using the EJB specification instead.

- JavaBean is a component technology to create generic java components that can be


composed together into applets and applications.

- JavaBeans have an external interface called the properties interface, which allows a
builder tool to interpret the functionality of the bean.

- JavaBeans may have BeanInfo classes,property editors or Customizers.


- JavaBeans have no types.

- No explicit support exists for transactions in JavaBeans.

- Component bridges are available for JavaBeans.

EJB :

- An EJB is a nonvisual, remote object.

- EJB's are remotely executable components or business objects that can be deployed
only on the server.

- Even though EJB is a component technology, it neither builds upon nor extends the
original JavaBean specification.

- EJBs have a deployment descriptor that describes its functionality to an external


builder tool or IDE.

- EJB's have no concept of BeanInfo classes, property editors or customizers and


provide no additional information other than that described in the deployment descriptor.

- EJBs are of two types - session beans and entity beans.

- EJB's may be transactional and the EJB servers provide the transactional support.

- 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.

You might also like