• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

isIdentical() method.

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic