First page Back Continue Last page Graphics

Using Bean References


Notes:

getEJBObject( )
When working with EJBs you will often need to refer to a bean generically. For local objects we are used to using this as a generic reference to the current instance of the current class. But in bean class code, the critical object is the EJBObject (the skeleton), not the bean instance itself. Using this in a bean class refers to the latter, not the former. To get a reference to the skeleton that this bean instance is currently serving, use the getEJBObject( ) method of the context object.
isIdentical( )
Similarly, comparing two remote objects is not the same as comparing two local ones. For the latter we use the equals operator (==) or equals( ) method. For EJBs, use the isIdentical( ) method of EJBObject.
When are two skeletons identical? Assuming they belong to the same class, it depends on the type of bean:
Any two stateless session bean skeletons are always identical, since the beans themselves are.
Stateful session beans are unique to their client, so two of them are identical only if they are the same physical object.
Two entity beans are identical if they have equivalent primary keys.