001: /**********************************************************************
002: Copyright (c) 2006 Erik Bengtson and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015: Contributors:
016: 2007 Andy Jefferson - added prePersist
017: ...
018: **********************************************************************/package org.jpox.state;
019:
020: /**
021: * CallBack handlers receive notification of events on persistent objects.
022: * Handlers are responsible for invoking event listeners/callback methods on Callback or Listener
023: * implementations.
024: *
025: * @version $Revision: 1.6 $
026: */
027: public interface CallbackHandler {
028: /**
029: * Callback after the object has been created.
030: * @param pc The Object
031: */
032: void postCreate(Object pc);
033:
034: /**
035: * Callback before the object is persisted (just before the lifecycle state change).
036: * @param pc The Object
037: */
038: void prePersist(Object pc);
039:
040: /**
041: * Callback before the object is stored.
042: * @param pc The Object
043: */
044: void preStore(Object pc);
045:
046: /**
047: * Callback after the object is stored.
048: * @param pc The Object
049: */
050: void postStore(Object pc);
051:
052: /**
053: * Callback before the fields of the object are cleared.
054: * @param pc The Object
055: */
056: void preClear(Object pc);
057:
058: /**
059: * Callback after the fields of the object are cleared.
060: * @param pc The Object
061: */
062: void postClear(Object pc);
063:
064: /**
065: * Callback before the object is deleted.
066: * @param pc The Object
067: */
068: void preDelete(Object pc);
069:
070: /**
071: * Callback after the object is deleted.
072: * @param pc The Object
073: */
074: void postDelete(Object pc);
075:
076: /**
077: * Callback before the object is made dirty.
078: * @param pc The Object
079: */
080: void preDirty(Object pc);
081:
082: /**
083: * Callback after the object is made dirty.
084: * @param pc The Object
085: */
086: void postDirty(Object pc);
087:
088: /**
089: * Callback after the fields of the object are loaded.
090: * @param pc The Object
091: */
092: void postLoad(Object pc);
093:
094: /**
095: * Callback after the fields of the object are refreshed.
096: * @param pc The Object
097: */
098: void postRefresh(Object pc);
099:
100: /**
101: * Callback before the object is detached.
102: * @param pc The Object
103: */
104: void preDetach(Object pc);
105:
106: /**
107: * Callback after the object is detached.
108: * @param pc The Object
109: * @param detachedPC The detached object
110: */
111: void postDetach(Object pc, Object detachedPC);
112:
113: /**
114: * Callback before the object is attached.
115: * @param detachedPC The Object
116: */
117: void preAttach(Object detachedPC);
118:
119: /**
120: * Callback after the object is attached.
121: * @param pc The attached Object
122: * @param detachedPC The detached object
123: */
124: void postAttach(Object pc, Object detachedPC);
125:
126: /**
127: * Adds a new listener to this handler.
128: * @param listener the listener instance
129: * @param classes the persistent classes which events are fired for the listener
130: */
131: void addListener(Object listener, Class[] classes);
132:
133: /**
134: * Remove a listener for this handler.
135: * @param listener the listener instance
136: */
137: void removeListener(Object listener);
138:
139: /**
140: * Clear any objects to release resources.
141: */
142: void close();
143: }
|