Showing posts with label EJB. Show all posts
Showing posts with label EJB. Show all posts

Thursday, 24 November 2016

Differences between EJB 2 and EJB 3

Differences between EJB 2 and EJB 3 | Java Source World


Differences between EJB 2 and EJB 3 :



Lets find the some differences between EJB 2.0 and EJB 3.0 below:


                   EJB 2.0
                  EJB 3.0
EJB 2.0 uses the entity Beans for accessing the databases.
EJB 3.0 uses the JPA to access the database.
EJB 2.0 needs deployment description.
There is no requirement of deployment description while using EJB 3.0.
In EJB 2.0, we have to write Home and Remote interface to have access the databases.
EJB 3.0 does not have such constraint and is more convenient in this regard.
Security issues are handling through Deployment descriptors in EJB 2.0.
EJB 3.0 is using annotation.
EJB 2.0 has limitation in its pluggability with third party persistence providers.
These limitations not exist in EJB 3.0.


What are Enterprise Beans



Here below lets find some more differences between EJB 2.1  and EJB 3.0.

1) EJB 3.0 is much faster than EJB 2.


2) An EJB 2.1 session bean must implement the SessionBean interface. But an EJB 3.0 session bean does not implement the SessionBean interface.


3) An EJB 2.1 session bean includes one or more ejbCreate(), ejbPostCreate(), ejbActivate(), ejbPassivate(), ejbRemove(), and setSessionContext(), and the business methods defined in the local/remote interface. Whereas an EJB 3.0 session bean class includes only business methods.


4) EJB 2.1 includes home interface that extends the EjbHome interface, remote interface that extends the javax.ejb.EJBObject interface, local home interface that extends the javax.ejb.EJBLocalHome interface, and local interface that extends the javax.ejb.EJBLocalObject interface. EJB 3.0 interfaces are POJI (Plain Old Java Interface) business interfaces and do not require home and component interfaces.


5) EJB 2.1 must have the deployment descriptor. EJB 3.0 may or may not contain deployment descriptors. Annotations are added to the language that can serve almost all the purposes that were previously served by the deployment descriptor.


6) An EJB 2.1 Entity EJB bean class must implement the EntityBean interface and must provide implementation to the ejbCreate() and ejbPostCreate() methods. EJB 3.0 entities are persistent objects that are not required to implement the EntityBean interface.


7) EJB 2.1 entity bean includes the home, component, local home and local component interfaces that extend the EJBHome, EJBObject, EJBLocalHome and EJBObject interfaces respectively. EJB 3.0 entities are Plain Old Java Objects (POJO) and do not require home and component interfaces.


8) An EJB 2.1 bean must define resource-ref in ejb-jar.xml to lookup resources. An EJB 3.0 bean can use either dependency injection or JNDI lookup.


9) An EJB 2.1 message-driven must implement the javax.ejb.MessgeDrivenBean interface. An EJB 3.0 message-driven may or may not implement the javax.ejb.MessgeDrivenBean interface.


10) EJB 3 introduced persistence API for database access. In EJB 2 you can use Entity bean.



Related posts:





Read More »

Thursday, 3 September 2015

Java Source World: What is Session Bean. What are the various types of Session Bean

Session Bean in EJB | Java Source World

           

                                                                                       Java Source World                A Java quick reference blog


What is Session Bean. What are the various types of Session Bean


SessionBeans



They are usually associated with one client. Each session bean is created
and destroyed by the particular EJB client that is associated with it. These beans do not
survive after system shutdown.

These Session Beans are of two types:

Stateful Session Beans:



They maintain conversational state between subsequest calls by a client
  • Stateful Session Beans : These beans have internal states. They can be stored (getHandle()) and restored (getEJBObject()) across client sessions.Since they can be persistence, they are also called as Persistence Session Beans.
  • Stateless Session Beans : These beans do not have internal States. They need not bepassivated. They can be pooled into service multiple clients.

More about:



Stateless Session Bean:

Consider this as a servlet equivalent in EJB. It is just used to service clients regardless of state and does not maintain any state.



Stateful:


Stateful sessionBeans have the passivated and Active state which the Stateless bean does not have.

Stateful beans are also Persistent session beans. They are designed to service business processes that span multiple method requests or transactions.

Stateful session beans remembers the previous requests and reponses.

Stateful session beans does not have pooling concept.

Stateful Session Beans can retain their state on behave of an individual client.

Stateful Session Beans can be passivated and reuses them for many clients.

Stateful Session Bean has higher performance over stateless sessiob bean as they are pooled by the application server.

Stateless:


Stateless Session Beans are designed to service business process that last only for a single method call or request.

Stateless session beans do not remember the previous request and responses.

Stattless session bean instances are pooled.

Stateless Session Beans donot maintain states.

Stateless Session Beans, client specific data has to be pushed to the bean for each method invocation which result in increase of network traffic.


Also Read: Difference between Stateful session bean and Stateless session bean




                         

                                                                                       Java Source World                A Java quick reference blog







Read More »

Saturday, 15 August 2015

Java Source World: Difference between Stateful session bean and Stateless session bean

Difference between Stateful session bean and Stateless session bean in EJB | Java Source World

     


                                                                   Java Source World              A Java quick reference blog

Difference between Stateful session bean and Stateless session bean in EJB:


Stateful Session in EJB:


Stateful sessionBeans have the passivated and Active state which the Stateless bean does not
have.

Stateful beans are also Persistent session beans. They are designed to service business
processes that span multiple method requests or transactions.

Stateful session beans remembers the previous requests and reponses.

Stateful session beans does not have pooling concept.

Stateful Session Beans can retain their state on behave of an individual client.

Stateful Session Beans can be passivated and reuses them for many clients.

Stateful Session Bean has higher performance over stateless sessiob bean as they are pooled
by the application server.

Stateless Session in EJB:


Stateless Session Beans are designed to service business process that last only for a single
method call or request.

Stateless session beans do not remember the previous request and responses.

Stattless session bean instances are pooled.

Stateless Session Beans donot maintain states.

Stateless Session Beans, client specific data has to be pushed to the bean for each method


invocation which result in increase of network traffic.




Also read:

Enterprise beans 
SessionBeans in EJB



                                                               Java Source World              A Java quick reference blog









Read More »

Thursday, 16 July 2015

Java Source World: Difference between HTTPSession and Stateful Session Bean

Difference between HTTPSession and Stateful Session Bean in EJB | Java Source World
                                                                   Java Source World         A Java quick reference blog

Difference between HTTPSession and Stateful Session Bean in EJB:



 From a logical point of view, a Servlet/JSP session is similar to an EJB session. Using a session, in fact, a client can connect to a server and maintain his state.

But, is important to understand, that the session is maintained in different ways and, in theory, for different scopes.



A session in a Servlet, is maintained by the Servlet Container through the HttpSession object, that is acquired through the request object. You cannot really instantiate a new HttpSession object, and it does not contains any business logic, but is more of a place where to store objects.


A session in EJB is maintained using the SessionBeans. You design beans that can contain business logic, and that can be used by the clients. You have two different session beans: Stateful and Stateless. The first one is somehow connected with a single client. It maintains the state for that client, can be used only by that client and when the client "dies" then the session bean is "lost".



A Stateless Session Bean does not maintain any state and there is no guarantee that the same client will use the same stateless bean, even for two calls one after the other. The lifecycle of a Stateless Session EJB is slightly different from the one of a Stateful Session EJB. Is EJB Containers responsability to take care of knowing exactly how to track each session and redirect the request from a client to the correct instance of a Session Bean. 


The way this is done is vendor dependant, and is part of the contract.




Also Read: 

Difference between stateful and stateless session



                                                                        Java Source World         A Java quick reference blog








Read More »