com.sun.sgs.app
Interface ManagedReference<T>

Type Parameters:
T - the type of the referenced object

public interface ManagedReference<T>

Represents a reference to a managed object. Classes that implement ManagedReference must also implement Serializable. Applications should create instances of this interface using the DataManager.createReference method. These ManagedReference instances should be used to store references to instances of ManagedObject referred to by other managed objects or by the non-managed objects they refer to.

Applications should not use instances of ManagedReference as the values of static fields or in other locations not managed by the DataManager. There is no guarantee that objects only reachable through these external references will continue to be managed by the DataManager.

Some implementations may need to be notified when managed objects and the objects they refer to are modified, while other implementations may be configurable to detect these modifications automatically. Applications are always permitted to mark objects that have been modified, and doing so may produce performance improvements regardless of whether modifications are detected automatically.

See Also:
DataManager.createReference

Method Summary
 boolean equals(Object object)
          Compares the specified object with this reference.
 T get()
          Obtains the object associated with this reference.
 T getForUpdate()
          Obtains the managed object associated with this reference, and notifies the system that the object is going to be modified.
 BigInteger getId()
          Returns a unique identifier for the object associated with this reference.
 int hashCode()
          Returns an appropriate hash code value for the object.
 

Method Detail

get

T get()
Obtains the object associated with this reference. The object returned will implement ManagedObject and Serializable. For implementations that need to be notified of object modifications, applications should call getForUpdate or DataManager.markForUpdate before modifying the returned object or any of the non-managed objects it refers to.

Returns:
the associated object
Throws:
ObjectNotFoundException - if the object associated with this reference is not found
TransactionException - if the operation failed because of a problem with the current transaction
See Also:
getForUpdate, DataManager.markForUpdate

getForUpdate

T getForUpdate()
Obtains the managed object associated with this reference, and notifies the system that the object is going to be modified. The object returned will implement ManagedObject and Serializable.

Returns:
the associated object
Throws:
ObjectNotFoundException - if the object associated with this reference is not found
TransactionException - if the operation failed because of a problem with the current transaction
See Also:
DataManager.markForUpdate

getId

BigInteger getId()
Returns a unique identifier for the object associated with this reference. Two references have equal identifiers if and only if they refer to the same object.

Returns:
a unique identifier for this reference

equals

boolean equals(Object object)
Compares the specified object with this reference. Returns true if the argument is a ManagedReference that refers to the same object as this reference, otherwise false.

Overrides:
equals in class Object
Parameters:
object - the object to be compared with
Returns:
if object refers to the same object

hashCode

int hashCode()
Returns an appropriate hash code value for the object.

Overrides:
hashCode in class Object
Returns:
the hash code for this object

Project Darkstar, Version 0.9.9.6
2009-05-08 15:39:40

Copyright © 2007-2009 Sun Microsystems, Inc. All rights reserved