|
WebObjects 5.2.3 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eocontrol.EOFaultHandler
EOFaultHandler is an abstract class that defines the mechanisms that create faults and help them to fire. Faults are used as placeholders for an enterprise object's relationship destinations. For example, suppose an Employee object has a department relationship to the employee's department. When an employee is fetched, faults are created for its relationship destinations. In the case of the department relationship, an empty Department object is created. The Department object's data isn't fetched until the Department is accessed, at which time the fault is said to fire.
Subclasses of EOFaultHandler perform the specific steps necessary to get
data for the fault and fire it. The EOAccess layer, for example, uses private
subclasses to fetch data using an EODatabaseContext. Most of EOFaultHandler's
methods are properly defined. Only overriding of completeInitializationOfObject
is needed to provide appropriate behavior.
An EOFaultHandler belongs exclusively to a single fault object, and shouldn't be shared or used by any other object. You also shouldn't send messages directly to a fault handler object, only the fault object should do that.
An EOFaultHandler can be created using the standard constructor. To turn an object
into a fault, the static method EOFaulthandler.makeObjectIntoFault
can be invoked with the object and a fault handler as an argument. Alternatively,
you can send a newly created object a turnIntoFault
message (defined
in the EOFaulting interface which must be implemented by all objects which can be
faults) and provide an EOFaultHandler as argument that will help the fault to fire.
When a fault receives a message that requires it to fire, it sends a
completeInitializationOfObject
method to its EOFaultHandler. This method
is responsible for invoking the clearFault
method to revert the fault to
its original state, and then do whatever is necessary to complete
initialization of the object. Doing so typically involves fetching data
from an external data source and passing it to the object.
completeInitializationOfObject(Object)
,
makeObjectIntoFault(Object, EOFaultHandler)
,
clearFault(Object)
,
EOFaulting.turnIntoFault(EOFaultHandler)
Constructor Summary | |
EOFaultHandler()
|
Method Summary | |
static void |
clearFault(Object object)
Restores object to its status prior to the makeObjectIntoFault
message that turned it into a fault. |
abstract void |
completeInitializationOfObject(Object object)
Implemented by subclasses to revert object to its original state
(to fire the fault) and complete its initialization in whatever means is
appropriate to the subclass. |
Object |
createFaultForDeferredFault(Object fault,
EOEnterpriseObject sourceEO)
Invoked by willReadRelationship to ensure that fault
isn't a deferred fault, or to replace it with a normal fault if it is. |
String |
descriptionForObject(Object object)
Returns a String that describes object . |
static String |
eoShallowDescription(Object object)
Returns a String that describes object in a short form. |
abstract void |
faultWillFire(Object object)
Informs the receiver that object is about to be reverted
to its original state. |
static EOFaultHandler |
handlerForFault(Object object)
Returns the EOFaultHandler that will help object to fire. |
static boolean |
isFault(Object object)
Returns true if object is a fault, false otherwise. |
static void |
makeObjectIntoFault(Object object,
EOFaultHandler handler)
Converts object into a fault, assigning handler
as the object that stores how to retrieve its original state and later
converts the fault back into a normal object (typically by fetching data
from an external data source). |
Class |
targetClass()
Returns the target class of the receiver's fault. |
String |
toString()
Returns a String containing a string representation of the receiver. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public EOFaultHandler()
Method Detail |
public static void clearFault(Object object)
object
to its status prior to the makeObjectIntoFault
message that turned it into a fault. Throws an IllegalArgumentException
if object
isn't a fault. Faults typically fire automatically when accessed,
using the completeInitializationOfObject
method.
object
- the fault to be restored to its pre-fault-creation object
IllegalArgumentException
completeInitializationOfObject(Object)
,
makeObjectIntoFault(Object, EOFaultHandler)
public abstract void completeInitializationOfObject(Object object)
object
to its original state
(to fire the fault) and complete its initialization in whatever means is
appropriate to the subclass. For example, the EOAccess layer's subclasses
of EOFaultHandler fetch data from the database and pass it to the object.
This method is invoked automatically by a fault when it's sent a message it
can't handle without fetching its data.
object
- the fault object to be initialized (fired)public Object createFaultForDeferredFault(Object fault, EOEnterpriseObject sourceEO)
willReadRelationship
to ensure that fault
isn't a deferred fault, or to replace it with a normal fault if it is.
EOFaultHandler's implementation simply returns its fault. A private
subclass that handles deferred faulting implements this method to
return a normal fault if fault
is a deferred fault.
You should never need to override this method.
fault
- the fault object to replacesourceEO
- the enterprise object instance, using deferred faulting
EODeferredFaulting.willReadRelationship(Object object)
public String descriptionForObject(Object object)
object
.
object
- the object whose description is to be generated
EOEnterpriseObject.eoShallowDescription()
,
EOEnterpriseObject.eoDescription()
public static String eoShallowDescription(Object object)
object
in a short form.
object
- the object whose description is to be generated
EOEnterpriseObject.eoShallowDescription()
,
EOEnterpriseObject.eoDescription()
public abstract void faultWillFire(Object object)
object
is about to be reverted
to its original state. EOFaultHandler's implementation does nothing.
object
- the fault object which will firepublic static EOFaultHandler handlerForFault(Object object)
object
to fire.
Returns null
if object
isn't a fault.
object
- the object to return the fault handler for
null
if the object isn't a faultmakeObjectIntoFault(Object, EOFaultHandler)
,
isFault(Object object)
public static boolean isFault(Object object)
true
if object
is a fault, false
otherwise.
object
- the object to test for a fault
true
if the object is a fault; false
otherwiseEOFaulting.isFault()
public static void makeObjectIntoFault(Object object, EOFaultHandler handler)
object
into a fault, assigning handler
as the object that stores how to retrieve its original state and later
converts the fault back into a normal object (typically by fetching data
from an external data source). The new fault becomes the owner of
handler
.
object
- the object to turn into a faulthandler
- the fault handlercompleteInitializationOfObject(Object)
,
handlerForFault(Object)
,
isFault(Object)
,
clearFault(Object)
public Class targetClass()
public String toString()
|
Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |