What is the difference between an EJB and a JavaBean? [closed]

closed . this question needs details or clarification . He's not getting answers right now.

want to improve this question? Add details and clarify the problem by editing this post .

Closed 4 years ago .

Improve this question

I would like to know what or what are the differences between an EJB and a JavaBean?

 2
Author: Shaz, 2016-07-04

1 answers

The Java bean is a "flat" java class, which has to meet the following requirements/conventions:

  • the constructor without arguments.
  • class attributes must be private.
  • each property must have the getter setter methods respecting the nomenclature.
  • must be serializable.

For example, the following class Person is a Java Bean

Public class Persona implements java. io. Serializable {

private String nombre;

public Persona(){}

public String getNombre(){
    return nombre;
}

public void setNombre(String nombre){
    this.nombre = nombre;
}

}

As you can see, Java Beans are extremely basic and simple. Any Java program, can have Java Beans.

In the old days, IdeS could do introspection of Java Beans because they respected conventions.

By contrast, EJBs (Enterprise Java Beans) are much more complex objects... They were born with J2EE and you need a application server like WebSphere or Jboss for them to run.

The goal of the J2EE platform, among other things, was to offer the framework/platform for making scalable and robust applications.

EJBs are not just a Java class, but have some associated artifacts (xml at first, annotations later), and also a own life cycle of execution within the container EJB...

When working with EJB, you have to think about whether EJB implement the interface Home or remote , and the type of EJB to be created: if it is entity, Session or Message Driven (less common)....

If you are thinking about EJB of entities , you have to think about how persistence will be handled. It can be CMP (container handles persistence) or BMP (Bean handles persistence).

Finally, as EJBs were so complex when they were born with the Java Enterprise platform (J2EE) where a "heavy" application Server was needed for them to run, it began to emerge as an alternative Spring as a lightweight container which also solved a lot of EJB design problems.

Since the incorporation of the annotations in EJB, its use was greatly simplified...

Java Beans can be said to have to respect the conventions listed above.

While the EJB they are part of a standard

 5
Author: Pablo Ezequiel Inchausti, 2016-07-05 00:49:25