KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > mim > api > SpeedoAccessor


1 /**
2  * Speedo: an implementation of JDO compliant personality on top of JORM generic
3  * I/O sub-system.
4  * Copyright (C) 2001-2004 France Telecom R&D
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  *
21  *
22  * Contact: speedo@objectweb.org
23  *
24  * Authors: S.Chassande-Barrioz.
25  *
26  */

27
28 package org.objectweb.speedo.mim.api;
29
30 import org.objectweb.perseus.persistence.api.State;
31 import org.objectweb.speedo.pm.api.ProxyManager;
32 import org.objectweb.jorm.api.PAccessor;
33 import java.io.Serializable JavaDoc;
34 import java.util.Collection JavaDoc;
35 import java.util.Map JavaDoc;
36
37 /**
38  * This interface a state of an user instance.
39  *
40  * @author S.Chassande-Barrioz
41  */

42 public interface SpeedoAccessor extends PAccessor, State, Serializable JavaDoc {
43
44     /**
45      * Changes the status of this object
46      *
47      * @see org.objectweb.speedo.mim.api.LifeCycle
48      * @param action the action that may change the status
49      */

50     void jdoChangeStatus(byte action);
51
52     /**
53      * Gets the current status of this object
54      *
55      * @see org.objectweb.speedo.mim.api.LifeCycle
56      * @return the current state in the life cycle
57      */

58     byte jdoGetStatus();
59
60     /**
61      * Forces the new value of the status
62      *
63      * @see org.objectweb.speedo.mim.api.LifeCycle
64      * @param newValue the new status of this object
65      */

66     void jdoSetStatus(byte newValue);
67
68     /**
69      * Version management:
70      * strategies supported are:
71      * - date-time
72      * - version-number
73      *
74      */

75     
76     /**
77      * change the version of this only if needed
78      * The version is computed by this method
79      * A call to changeVersion can have no effect.
80      */

81     void changeVersion();
82     
83     /**
84      * Return the version of the object as a long
85      */

86     long getVersion();
87     
88     /**
89      * check the validity of the version of sa compared to the persistent object this.
90      */

91     boolean checkVersion(SpeedoAccessor sa);
92     
93     /**
94      * Gets the current status of this detached object
95      *
96      * @return the current state in the life cycle
97      */

98     byte getDetachedStatus();
99
100     /**
101      * Forces the new value of the detached status
102      *
103      * @param newValue the new status of this object
104      */

105     void setDetachedStatus(byte newValue);
106       
107     /**
108      * @return The SpeedoProxy attached to this state representation.
109      */

110     SpeedoProxy getSpeedoProxy();
111
112     /**
113      * Assignes the SpeedoProxy attached to this state representation.
114      */

115     void setSpeedoProxy(SpeedoProxy sp);
116
117     /**
118      * Prepare to write (relations consistency management)
119      */

120     void prepareWrite();
121
122     /**
123      * The context has been closed (ex: transaction end).
124      */

125     void workingSetClosed();
126
127     /**
128      * indicates if the object has been flushed on the support in a writing
129      * before the end of the working set (commit | rollback | close).
130      */

131     boolean hasBeenFlush();
132
133     /**
134      * Assignates a boolean value to indicate if the object has been flushed
135      * on the support in a writing before the end of the working
136      * set (commit | rollback | close).
137      * @param val is the boolean which must be assigned.
138      */

139     void setFlushed(boolean val);
140     
141     /**
142      * Makes persistent all inner elements of the persistent instance. For a
143      * class, it means making persistent all objects referenced by a persistent
144      * field. For a genclass it means making persistent element of the genclass.
145      * This method is called when a makePersistent is called on the persistent
146      * class (Proxy) linked to this accessor.
147      * @param pm is the proxy manager for making persistent inner element.
148      */

149     void makePersistent(ProxyManager pm);
150     
151     /**
152      * Deletes persistent all inner elements of the persistent instance. For a
153      * class, it means deleting persistent all objects referenced by a persistent
154      * field. For a genclass it means deleting persistent element of the genclass.
155      * This method is called when a deletePersistent is called on the persistent
156      * class (Proxy) linked to this accessor.
157      * @param pm is the proxy manager for making persistent inner element.
158      */

159     void deletePersistent(ProxyManager pm);
160     
161     /**
162      * Askes the loading of the some fields identified by the long array.
163      * @param pm is the Proxy manager to use to load references
164      * @param fields is an array of long. Each long is a bit mask indicating
165      * fields to load. As a long is stored over 64 bits, each long of the array
166      * can represent only 64 persistent fields. If the class has 70 persistent
167      * field, the parameter could be a long array size is 2. This parameter
168      * can be null if no field loading is required.
169      */

170     void loadFields(ProxyManager pm, long[] fields);
171     
172     /**
173      * This method is used during the detach operation. A call to this method
174      * copy the field of the state into the the cloned state. When a field
175      * references a persistent object, according to the fetch plan, the
176      * referenced can be detached too.
177      * @param pm is the proxy manager used during the detach operation
178      * @param map is the map of the detached object. The use of this map permits
179      * to support cycle in the object graph.
180      * @param clone is a clone of the current state
181      * @param fgHints represents the fetch plan.
182      */

183     void detachCopy(ProxyManager pm,
184             Map JavaDoc map,
185             SpeedoAccessor clone,
186             Collection JavaDoc fgHints);
187
188     /**
189      * This method is used during the attach operation. A call to this method
190      * copy the field of the cloned state into the the current state. When a field
191      * references a persistent object, according to the fetch plan, the
192      * referenced can be attached too.
193      * @param pm is the proxy manager used during the attach operation
194      * @param map is the map of the atttached object. The use of this map permits
195      * to support cycle in the object graph.
196      * @param detached is the detached state used to update the current state
197      * @param makeTransactional ??? TODO comment the parameter
198      */

199     void attachCopy(ProxyManager pm,
200             Map JavaDoc map,
201             SpeedoAccessor detached,
202             boolean makeTransactional);
203     
204     /**
205      * This method is used during the refresh operation. A call to this method
206      * refreshes the fields of the current state. When a field
207      * references a persistent object, according to the fetch plan, the
208      * referenced can be refreshed too.
209      * @param pm is the proxy manager used during the refresh operation
210      * @param map is the map of the refreshed object. The use of this map permits
211      * to support cycle in the object graph.
212      * @param fgHints represents the fetch plan.
213      */

214     void refresh(ProxyManager pm, Map JavaDoc map, Collection JavaDoc fgHints);
215     
216     /**
217      * This method is used during the retrieve operation. A call to this method
218      * retrieves the fields of the current state. When a field
219      * references a persistent object, according to the fetch plan, the
220      * referenced can be retrieved too.
221      * @param pm is the proxy manager used during the retrieve operation
222      * @param map is the map of the retrieved object. The use of this map permits
223      * to support cycle in the object graph.
224      * @param fgHints represents the fetch plan.
225      */

226     void retrieve(ProxyManager pm, Map JavaDoc map, Collection JavaDoc fgHints);
227     
228     /**
229      * Force the detached status to DETACHED_DIRTY and
230      * all the xxxLoaded to true
231      */

232     void forceDetachedDirty();
233     
234     /**
235      * Restore the detached status to DETACHED_NONE and
236      * all the xxxLoaded to false
237      */

238     void restoreDetachedNone();
239     
240     /**
241      * indicates if the State has to be merge with the reference state at commit
242      * time.
243      */

244     boolean isToMerge();
245     
246     /**
247      * Mark the current state with the flag 'toMerge'. This status means at
248      * commit time this state has to be merge with the referenceState (cache).
249      * Since this method call and until the transaction end, the implementation
250      * could register the change for the merge.
251      *
252      * @param thinLock is an object representing the thin lock
253      */

254     void makeToMerge(Object JavaDoc thinLock);
255     
256     /**
257      * This action updates the old state with the change (delta) done in the
258      * transaction on this state.
259      * @param oldState is the state which has to be updated
260      * @return the updated state.
261      */

262     State merge(State oldState);
263     
264     void unSwizzle();
265     
266     /**
267      * The field uses in user cache, has been modified.
268      * @param cacheId is the cache identifier. The value Integer.MAX_VALUE
269      * means that all user cache must be updated.
270      * @param rebind if true, the speedoAcessor is rebound
271      */

272     void indexFieldModified(int cacheId, boolean rebind);
273 }
274
275
Popular Tags