Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

isIdentical() method.

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...........





























 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic