Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

isIdentical()

 
Tejastejas Gokhale
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does this always return false for stateful session beans? It may be possible that I have two stubs at client side(same client) reffering to same EJBObject on server side.
Or even two references to same stub?
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stateful session beans have a one to one relationship between clients and their component interface implementors (or EJBObject). Given this condition, no two instances of EJBObject can be the same.

HTH
 
Akila kamalanathan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
For a stateful bean, the bean will maintain the conversational state of the client. Eventhough the bean comes from the same home, it will always return false.

Thanks and Regards,
Akila
 
Tejastejas Gokhale
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct. but what i am saying is same client can have two stubs to same EJBObject.or
it can have two references to same stub itself. Then in that case isIdentical should return true.
 
Rajesh Chande
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Tejas,

This is what the spec has to say....

The following example illustrates the use of the isIdentical method for a stateful session object.
FooHome fooHome = ...; // obtain home of a stateful session bean
Foo foo1 = fooHome.create(...);
Foo foo2 = fooHome.create(...);
if (foo1.isIdentical(foo1)) {// this test must return true
...
}
if (foo1.isIdentical(foo2)) {// this test must return false
...
}

Is the second stub (object) just a simple copy of the first? In that it will return TRUE.. no?

Regards,
tiro
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the second stub (object) just a simple copy of the first? In that it will return TRUE.. no?


No and No. EJB does not work like a Servlet would (meaning that it doesn't recognize inbound requests from the same client implicitely). Each call to create() would create another stateful session bean instance.

HTH
[ June 29, 2006: Message edited by: Patrick Williams ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic