com.odi
Interface IPersistentHooks
- All Known Implementing Classes:
- Attribute, OSAbstractSet, OSHashBag, OSHashtable, OSSmallMap, OSTreeMap, OSVector, Persistent, Type
- public interface IPersistentHooks
The IPersistentHooks interface declares
serveral "hook" methods which allow PSE/PSE Pro to notify
a class instance of calls to certain methods defined in the IPersistent
interface which are normally defined by the class file post-processor.
This allows a user to take action upon these calls without requiring the
user to implement the methods.
As with any interface, every method defined in the
IPersistentHooks interface must be defined in your class
definition. There are several ways you can accomplish this.
- In your class definition, do not specify that it implements
IPersistentHooks and do not define any
IPersistentHooks methods.
Run the postprocessor on the class file. The postprocessor
annotates the class so that it only implements IPersistent and
not IPersistentHooks.
- In your class definition, do not specify that it implements
IPersistentHooks, but define those IPersistentHooks
methods that you want to define. For example, you might define a
hook method such as preFlushContents().
Run the postprocessor on the class file. The postprocessor annotates
the class so that it implements both IPersistent and
IPersistentHooks and defines the IPersistent and
IPersistentHooks methods that you did not explicitly
define, in addition to the methods that you did explicitly define.
- In your class definition, explicitly implement
IPersistentHooks. You must define every method defined
by IPersistentHooks. Any of those method definitions may
have an empty method body if you do not have any particular need
for that hook function. If you do not provide definitions for all
of the hook methods, you receive a compilation error.
Method Summary |
void |
postInitializeContents()
Called by PSE/PSE Pro immediately after calling the
initializeContents() method, which changes the state of
a persistent object from hollow to active and clean.
|
void |
preClearContents()
Called by PSE/PSE Pro immediately before calling the clearContents()
method, which changes the state of an object from active and clean to
hollow. |
void |
preDestroyPersistent()
Called by ObjectStore.destroy(object) before destruction
of the specified object. |
void |
preFlushContents()
Called by PSE/PSE Pro immediately before calling the flushContents()
method, which changes the state of a persistent object from active and clean or dirty
to active and clean. |
postInitializeContents
public void postInitializeContents()
- Called by PSE/PSE Pro immediately after calling the
initializeContents() method, which changes the state of
a persistent object from hollow to active and clean.
Implement this method when you want to
customize behavior.
For example, you can use this method to copy some
persistent fields to transient state.
If you provide an implementation of this
method, you should be sure to call super.postInitializeContents()
for any super classes.
If you do not define this method, you can run the postprocessor, which
inserts a definition of this method as a null operation.
Example
preFlushContents
public void preFlushContents()
- Called by PSE/PSE Pro immediately before calling the flushContents()
method, which changes the state of a persistent object from active and clean or dirty
to active and clean. Implement this method when you want to customize behavior.
For example, you can use this method to to copy any transient state to
persistent fields before values are stored in the database as the result
of an evict or commit operation.
If you provide an implementation of this method, you should be
sure to call super.preFlushContents() for any super classes.
If you do not define this method, you can run the postprocessor, which
inserts a definition of this method as a null operation.
Example
preClearContents
public void preClearContents()
- Called by PSE/PSE Pro immediately before calling the clearContents()
method, which changes the state of an object from active and clean to
hollow. Implement this method when you want to customize behavior.
For example, you can use this method to copy any persistent fields to
transient state before the persistent state is cleared. Or, you can
make transient pointers null so that the referenced objects can be
garbage collected.
If you provide an implementation of this method, you should be
sure to call super.preClearContents() for any super classes.
If you do not define this method, you can run the postprocessor, which
inserts a definition of this method as a null operation.
Example
preDestroyPersistent
public void preDestroyPersistent()
- Called by ObjectStore.destroy(object) before destruction
of the specified object. A user-defined class can override this method
to destroy any internal persistent data structures that it
references. For example, if a user "Btree" class has internal
persistent types that represent the leaves of the tree that are
not visible through its API, the
Btree.preDestroyPersistent() method can be defined to remove
those leaves from the database. Btree.preDestroyPersistent
should not call ObjectStore.destroy(this).
If you do not define this method, you can run the postprocessor,
which inserts a definition of this method as a null operation.
Copyright 2005 Progress Software Corporation. All rights reserved.