EJB.5.8 Object Identity


EJB.5.8.1 Stateful Session Beans

A stateful session object has a unique identity that is assigned by the container at create time.

A client can determine if two object references refer to the same session object by invoking the isIdentical(EJBObject otherEJBObject) method on one of the references.

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     ...  } 

EJB.5.8.2 Stateless Session Beans

All session objects of the same stateless session bean within the same home have the same object identity, which is assigned by the container. If a stateless session bean is deployed multiple times (each deployment results in the creation of a distinct home), session objects from different homes will have a different identity.

The isIdentical(EJBObject otherEJBObject) method always returns true when used to compare object references of two session objects of the same stateless session bean.

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     ...  } 

EJB.5.8.3 getPrimaryKey()

The object identifier of a session object is, in general, opaque to the client. The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException .



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net