File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes isIdentical()  method. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "isIdentical()  method." Watch "isIdentical()  method." New topic
Author

isIdentical() method.

Parvathi G
Greenhorn

Joined: Dec 17, 2005
Posts: 28
Hi,

The isIdentical() mtd is used to find
1. Whether the two remote reference are same or not - Session bean
2. Whether two PK's are same or not - Entity bean.

For Stateless the mtd returns True if both references came form the same home. Same home means, from the same client. But there will be only Home.
The Home object differs from client to client ?

For Statefull Session beans, the method returns always false.
Bcoz every client has its own bean and EJBObject. So for Statefull session bean it is as per the EJBObject and bean.
For Stateless bean is from the pool but the EJBObject is a new instatnce
rite.....

So confusing...........





























Mini Sarin
Ranch Hand

Joined: Apr 07, 2006
Posts: 31
isIdentical method is used to determine if 2 object references (remote or local) refer to the same session bean EJBObject/EJBLocalObject.

Stateful session bean:

A stateful session bean has a unique identity that is assigned by the container at create time.

MyHome myHome = //obtain home
MyObj obj1 = myHome.create()
MyObj obj2 = myHome.create()

obj1.isIdentical(obj1) //should return true
obj1.isIdentical(obj2) //should return false

Stateless session bean:

Stateless session beans belonging to the same home have the same object identity.

MyHome myHome = //obtain home
MyObj obj1 = myHome.create()
MyObj obj2 = myHome.create()

obj1.isIdentical(obj1) //should return true
obj1.isIdentical(obj2) //should return true

This is because the stateless bean's EJBObject is linked to a bean instance in the pool when client invokes a business method. The container can pick up any instance from the pool (beans belonging to one home belong to one pool) for the EJBObject. So, all EJBObjects for the beans belonging to one home have the same identity, because they are coming from the same pool.

The Home object does not differ from client to client, but it depends on the deployement. Home is created during deployment of the bean.
If a stateless session bean is deployed multiple times, each deployment results in the creation of a distinct home.

Hope the above explanation has not confused you further. I am sorry if it has.

-Mini
Parvathi G
Greenhorn

Joined: Dec 17, 2005
Posts: 28
Hi,

For the Stateless bean same home represents same bean pool.
As the session beans are from the same bean pool they are identical.
But the EJBObject will be the new object for each Sateless bean rite.

isIdentical method is used to determine if 2 object references (remote or local) refer to the same session bean EJBObject/EJBLocalObject.

Please clarify this.

Thanks & Regards,
Parvathi.
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

It will not check both objects are identical. It will check both objects are MEANINGFULLY equivalent.

Stateful Session Beans:

isIdentical() method will always return false for stateful session beans.

Stateless Session Beans:

isIdentical() method will return true, if both stateless session beans where retrieved from the same Home.

Entity Beans:

isIdentical() method will return true, if entity beans if the two entities have the same primary key.

Message Driven :

No client view. so no component interface.

hth,


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
Rajan Murugan
Ranch Hand

Joined: Jun 24, 2006
Posts: 182
Originally posted by Parvathi G:
Hi,

The isIdentical() mtd is used to find
1. Whether the two remote reference are same or not - Session bean
2. Whether two PK's are same or not - Entity bean.

For Stateless the mtd returns True if both references came form the same home. Same home means, from the same client. But there will be only Home.
The Home object differs from client to client ?

For Statefull Session beans, the method returns always false.
Bcoz every client has its own bean and EJBObject. So for Statefull session bean it is as per the EJBObject and bean.
For Stateless bean is from the pool but the EJBObject is a new instatnce
rite.....

So confusing...........


For Stateless the mtd returns True if both references came form the same home. Same home means, from the same client. But there will be only Home.


Yes for stateless the mtd returns true if both are from same home.
you are saying "same home means,from the same client".you seem to be little confused here.home is at the server side.And yes it will be only one per bean type.(irrespective any number of bean instances of that type).
Home object will be same irrespective of the any client.


With Regards,<br /> Rajan<br />"Java Rocks"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: isIdentical() method.
 
Similar Threads
isIdentical() clarification......
question about multiple instances of same ejb..
can some one explain
Doubt from Spec
Stateless Sessionbean ejbCreate() mtd