Solved

EJB questions

Posted on 2008-10-26
1
298 Views
Last Modified: 2013-11-24
If I pass an object to and EJB and the EJB changes the object.  Will I see those changes when the EJB method completes?  Does this differ when Local EJBs are used?

If I get a reference to a Stateless Session Bean and invoke two method calls.  Will those calls be guaranteed to be made on the same EJB?

0
Comment
Question by:pzaprianov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
Mr_It earned 500 total points
ID: 22829524
To answer your first question:

When you use a remote business interface, a pass-by-value is involved. So when the bean modifies the object, this has no impact on the object that the client sees. Using remote interfaces implicitly provides a layer of isolation between the client and the bean.
However, with local business interfaces everything is different; a pass-by-reference is involved. So the client does see changes to the object and vice versa. If you don't want the client to modify retrieved data, you should make an explicit copy before returning it.

This is covered in the EJB Core specs (3.2.3 Choosing Between a Local or Remote Client View)

And the second question:

No, when a business method invoked on a stateless session bean completes, the bean is returned to the method-ready pool of beans. It is not guaranteed, but possible, that the same instance of the bean is used for 2 successive calls. You should never put state into a stateless session bean. If you need to preserve state between 2 successive calls, you should use a stateful session bean.

You can read in the EJB Core specs: 'There is no fixed mapping between clients and stateless instances. The container simply delegates a clients work to any available instance that is method-ready.'
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question