KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > descriptors > changetracking > ObjectChangePolicy


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.descriptors.changetracking;
23
24 import java.io.Serializable JavaDoc;
25 import oracle.toplink.essentials.internal.sessions.ObjectChangeSet;
26 import oracle.toplink.essentials.internal.descriptors.*;
27 import oracle.toplink.essentials.internal.sessions.AbstractSession;
28 import oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl;
29 import oracle.toplink.essentials.descriptors.ClassDescriptor;
30 import oracle.toplink.essentials.internal.helper.IdentityHashtable;
31
32 /**
33  * INTERNAL:
34  * Implementers of ObjectChangePolicy implement the code which computes changes sets
35  * for TopLink's UnitOfWork commit process. An ObjectChangePolicy is stored on an
36  * Object's descriptor.
37  * @see DeferredChangeDetectionPolicy
38  * @see ObjectChangeTrackingPolicy
39  * @see AttributeChangeTrackingPolicy
40  * @author Tom Ware
41  */

42 public interface ObjectChangePolicy extends Serializable JavaDoc {
43
44     /**
45      * INTERNAL:
46      * calculateChanges creates a change set for a particular object
47      * @return oracle.toplink.essentials.changesets.ObjectChangeSet an object change set describing
48      * the changes to this object
49      * @param clone the Object to compute a change set for
50      * @param backUp the old version of the object to use for comparison
51      * @param changes the change set to add changes to
52      * @param session the current session
53      * @param descriptor the descriptor for this object
54      * @param shouldRiseEvent indicates whether PreUpdate event should be risen (usually true)
55      */

56     public ObjectChangeSet calculateChanges(Object JavaDoc clone, Object JavaDoc backUp, oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet changes, AbstractSession session, ClassDescriptor descriptor, boolean shouldRiseEvent);
57
58     /**
59      * INTERNAL:
60      * Create ObjectChangeSet through comparison. Used in cases where we need to force change calculation (ie aggregates)
61      */

62     public ObjectChangeSet createObjectChangeSetThroughComparison(Object JavaDoc clone, Object JavaDoc backUp, oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet changeSet, boolean isNew, AbstractSession session, ClassDescriptor descriptor);
63
64     /**
65      * INTERNAL:
66      * This method is used to dissable changetracking temporarily
67      */

68     public void dissableEventProcessing(Object JavaDoc changeTracker);
69
70     /**
71      * INTERNAL:
72      * This method is used to enable changetracking temporarily
73      */

74     public void enableEventProcessing(Object JavaDoc changeTracker);
75     
76     /**
77      * INTERNAL:
78      * This may cause a property change event to be raised to a listner in the case that a listener exists.
79      * If there is no listener then this call is a no-op
80      */

81     public void raiseInternalPropertyChangeEvent(Object JavaDoc source, String JavaDoc propertyName, Object JavaDoc oldValue, Object JavaDoc newValue);
82     
83     /**
84      * INTERNAL:
85      * This method is used to revert an object within the unit of work
86      */

87     public void revertChanges(Object JavaDoc clone, ClassDescriptor descriptor, UnitOfWorkImpl uow, IdentityHashtable cloneMapping);
88
89     /**
90      * INTERNAL:
91      * This is a place holder for reseting the listener on one of the subclasses
92      */

93     public void clearChanges(Object JavaDoc object, UnitOfWorkImpl uow, ClassDescriptor descriptor);
94     
95     /**
96      * INTERNAL:
97      * This method is used internally to rest the policies back to original state
98      * This is used when the clones are to be reused.
99      */

100     public void updateWithChanges(Object JavaDoc clone, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow, ClassDescriptor descriptor);
101
102     /**
103      * INTERNAL:
104      * Return true if the Object should be compared, false otherwise. This method is implemented to allow
105      * run time determination of whether a change set should be computed for an object. In general, calculateChanges()
106      * will only be executed in a UnitOfWork if this method returns true.
107      * @param object the object that will be compared
108      * @param unitOfWork the active unitOfWork
109      * @param descriptor the descriptor for the current object
110      */

111     public boolean shouldCompareForChange(Object JavaDoc object, UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor);
112
113     /**
114      * INTERNAL:
115      * Assign Changelistner to an aggregate object
116      */

117     public void setAggregateChangeListener(Object JavaDoc parent, Object JavaDoc aggregate, UnitOfWorkImpl uow, ClassDescriptor descriptor, String JavaDoc mappingAttribute);
118
119     /**
120      * INTERNAL:
121      * Assign appropriate ChangeListener to PropertyChangeListener based on the policy.
122      */

123     public void setChangeListener(Object JavaDoc clone, UnitOfWorkImpl uow, ClassDescriptor descriptor);
124
125     /**
126      * INTERNAL:
127      * Set the ObjectChangeSet on the Listener, initially used for aggregate support
128      */

129     public void setChangeSetOnListener(ObjectChangeSet objectChangeSet, Object JavaDoc clone);
130     
131     /**
132      * INTERNAL:
133      * Build back up clone.
134      */

135     public Object JavaDoc buildBackupClone(Object JavaDoc clone, ObjectBuilder builder, UnitOfWorkImpl uow);
136
137     /**
138      * INTERNAL:
139      * initialize the Policy
140      */

141     public void initialize(AbstractSession session, ClassDescriptor descriptor);
142
143     /**
144      * Used to track instances of the change policies without doing an instance of check
145      */

146     public boolean isDeferredChangeDetectionPolicy();
147
148     /**
149      * Used to track instances of the change policies without doing an instance of check
150      */

151     public boolean isObjectChangeTrackingPolicy();
152
153     /**
154      * Used to track instances of the change policies without doing an instance of check
155      */

156     public boolean isAttributeChangeTrackingPolicy();
157 }
158
Popular Tags