KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jdo > InstanceCallbacks


1 /*
2  * Copyright 2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 /*
18  * InstanceCallbacks.java
19  *
20  */

21  
22 package javax.jdo;
23
24 /** A <code>PersistenceCapable</code> class that provides callback methods for life
25  * cycle events implements this interface.
26  *
27  * <P>For JDO 2.0, <code>InstanceCallbacks</code> has been refactored to extend
28  * four other interfaces, without changing any of the methods or semantics.
29  * This allows fine-grained control over callbacks, for
30  * example to allow a class to implement the load callback without
31  * implementing any of the other callbacks. For backward compatibility
32  * with JDO 1.0, the <code>InstanceCallbacks</code> interface is preserved.
33  *
34  * <P>Classes which include non-persistent fields whose values depend
35  * on the values of persistent fields require callbacks on specific
36  * JDO instance life cycle events in order to correctly populate the
37  * values in these fields.
38  *
39  * <P>The callbacks might also be used if the persistent instances
40  * need to be put into the runtime infrastructure of the application.
41  * For example, a persistent instance might notify other instances
42  * on changes to state. The persistent instance might be in a list of
43  * managed instances. When the persistent instance is made hollow,
44  * it can no longer generate change events, and the persistent
45  * instance should be removed from the list of managed instances.
46  *
47  * <P>To implement this, the application programmer would implement
48  * <code>jdoPostLoad</code> to put itself into the list of managed
49  * instances, and implement <code>jdoPreClear</code> to remove itself from
50  * the list. With JDO 1.0, the domain class would be declared to implement
51  * <code>InstanceCallbacks</code>. With JDO 2.0, the domain class
52  * would be declared to implement
53  * <code>javax.jdo.listener.LoadCallback</code> and
54  * <code>javax.jdo.listener.ClearCallback</code>.
55  *
56  * <P>Note that JDO does not manage the state of non-persistent
57  * fields, and when a JDO instance transitions to hollow, JDO clears
58  * the persistent fields. It is the programmer's responsibility to
59  * clear non-persistent fields so that garbage collection of
60  * referred instances can occur.
61  *
62  * @since 1.0
63  * @version 2.0
64  */

65 public interface InstanceCallbacks
66     extends javax.jdo.listener.ClearCallback,
67         javax.jdo.listener.DeleteCallback,
68         javax.jdo.listener.LoadCallback,
69         javax.jdo.listener.StoreCallback {
70 }
71
Popular Tags