Solved

EJB questions

Posted on 2008-10-26
1
297 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mapAB Challlenge 35 171
Core Java. What output will be and why ? 6 68
eclipse compiler vs Installed JREs option 3 112
maven module vs maven project 3 72
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.

713 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