wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubt from Spec Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Doubt from Spec" Watch "Doubt from Spec" New topic
Author

Doubt from Spec

Shanmugam Karthikeyan
Ranch Hand

Joined: Aug 02, 2002
Posts: 58
Hi,

I have just started preparing for SCBCD.I am currently going through the EJB spec.

In the spec in the following paragraph i have a doubt (page 66)

" All session objects of the same stateless session bean within the same home have the same object identity,which is assigned by the container."

Here in the above statement i have the following doubts.

1. I am i right to say that "All session objects" means "All EJB Objects" ?If what i have understood is right then according to Head First each client gets his own EJBObject and his own bean.

So it means that if there is client A, then that client A will get EJBObject A and a bean A and for client B an EJBObjectB and a bean B.

so when we use isIdentical() method for checking whether two EJB Object is refering to the same bean it should result false always.But in the spec i found the following line which confuses me.

"The following example illustrates the use of the isIdentical method for a stateless session object.

FooHome fooHome = ...; // obtain home of a stateless session bean
Foo foo1 = fooHome.create();
Foo foo2 = fooHome.create();
if (foo1.isIdentical(foo1)) {// this test returns true
...
}
if (foo1.isIdentical(foo2)) {// this test returns true
...
}"

My question is how in the second if statement the test returns true ?
If i have understood wrongly , pls correct me.


SCJP 1.4<br />SCWCD 1.4<br />SCBCD 1.3
Ramakrishnan Viswanathan
Ranch Hand

Joined: Aug 24, 2005
Posts: 90
For stateless beans, the bean-client association happens only during a business method invocation. When an isIdentical() operation is performed, although the client can assume that it is comparing two EJBObject instances, the actual implementation (which is vendor independent) would just result in a comparison of their respective EJBHome-s.


Regards<br />Ram<br /> <br />SCJP 1.4, SCBCD 1.3, (SCEA)
Shanmugam Karthikeyan
Ranch Hand

Joined: Aug 02, 2002
Posts: 58
Hi,

Thanks for your reply.

Did you mean to say that for a stateless session bean, The isIdentical method compared the Home Object rather than the EJBObject since the EJBObject is create only when a client invokes the business method ?


So in this case it will always return true because a single Home Object
will be created and shared no matter how many EJBObject or session bean instances are created.
Ramakrishnan Viswanathan
Ranch Hand

Joined: Aug 24, 2005
Posts: 90
It is the container's discretion whether to create one or two EJBObject(s). And each container may do this differently, so this is purely a vendor implementation. There is no guarantee that you have 2 instances created from the same home. What is guaranteed is that calling isIdentical() would return true no matter how the container handles the creation. So you wouldn't really have to know whether the server created two different objects or is just using one.
 
jQuery in Action, 2nd edition
 
subject: Doubt from Spec
 
Similar Threads
how many EJBObjects
isIdentical()
can some one explain
question about multiple instances of same ejb..
isIdentical() clarification......