NopDirtyShareContext.java
1 |
package com.goldencode.p2j.persist.dirty; |
---|---|
2 |
|
3 |
import com.goldencode.p2j.persist.*; |
4 |
import com.goldencode.p2j.persist.event.*; |
5 |
import com.goldencode.p2j.persist.lock.*; |
6 |
import com.goldencode.p2j.util.*; |
7 |
|
8 |
import java.util.*; |
9 |
|
10 |
public class NopDirtyShareContext |
11 |
extends DirtyShareContext
|
12 |
{ |
13 |
/**
|
14 |
* Default constructor.
|
15 |
*/
|
16 |
NopDirtyShareContext() |
17 |
{ |
18 |
super(null); |
19 |
} |
20 |
|
21 |
/**
|
22 |
* NOP in this implementation.
|
23 |
*
|
24 |
* Register with a global event clearinghouse an interest in insert,
|
25 |
* delete, and update events which affect the given DMO entity.
|
26 |
*
|
27 |
* @param entity
|
28 |
* DMO entity for which the caller is interested in tracking
|
29 |
* change.
|
30 |
*
|
31 |
* @return always <code>null</code> in this implementation.
|
32 |
*
|
33 |
* @see #getGlobalEvents(long, long)
|
34 |
* @see #deregisterForGlobalEvents(long)
|
35 |
*/
|
36 |
@Override
|
37 |
public Long registerForGlobalEvents(String entity) |
38 |
{ |
39 |
return null; |
40 |
} |
41 |
|
42 |
/**
|
43 |
* NOP in this implementation.
|
44 |
*
|
45 |
* Deregister with a global event clearinghouse an interest in insert,
|
46 |
* delete, and update events which affect a particular DMO type.
|
47 |
*
|
48 |
* @param registerID
|
49 |
* A unique identifier for the registrant being deregistered.
|
50 |
*
|
51 |
* @see #getGlobalEvents(long, long)
|
52 |
* @see #registerForGlobalEvents(String)
|
53 |
*/
|
54 |
@Override
|
55 |
public void deregisterForGlobalEvents(long registerID) |
56 |
{ |
57 |
} |
58 |
|
59 |
/**
|
60 |
* NOP in this implementation.
|
61 |
*
|
62 |
* Retrieve any new events that have been collected by a global event
|
63 |
* clearinghouse, representing inserts, deletes, and updates made to
|
64 |
* record types for which the caller previously has registered interest.
|
65 |
*
|
66 |
* @param registerID
|
67 |
* A unique identifier for an object which has registered interest
|
68 |
* in record-changing events.
|
69 |
* @param lastID
|
70 |
* A unique identifier representing the last event retrieved by
|
71 |
* the caller. If less than 0, it is assumed no events have yet
|
72 |
* been retrieved since the caller registered interest in these
|
73 |
* events.
|
74 |
*
|
75 |
* @return always <code>null</code> in this implementation.
|
76 |
*/
|
77 |
@Override
|
78 |
public GlobalChangeEvent[] getGlobalEvents(long registerID, long lastID) |
79 |
{ |
80 |
return null; |
81 |
} |
82 |
|
83 |
/**
|
84 |
* NOP in this implementation.
|
85 |
*
|
86 |
* Lock or unlock all indexes associated with the given DMO entity.
|
87 |
*
|
88 |
* @param entity
|
89 |
* Name of an entity, which is the name of the DMO implementation
|
90 |
* class associated with a table being tracked for uncommitted
|
91 |
* changes.
|
92 |
* @param lockType
|
93 |
* Type of lock to acquire, or <code>NONE</code> to release
|
94 |
* existing locks. <code>NO_WAIT</code> variants will be treated
|
95 |
* as regular, blocking variants.
|
96 |
*/
|
97 |
@Override
|
98 |
public void lockAllIndexes(String entity, LockType lockType) |
99 |
{ |
100 |
} |
101 |
|
102 |
/**
|
103 |
* NOP in this implementation.
|
104 |
*
|
105 |
* Begin tracking a newly inserted record in the dirty database.
|
106 |
* <p>
|
107 |
* This record is removed when the adding context's current transaction is committed or rolled back.
|
108 |
*
|
109 |
* @param buffer
|
110 |
* Record buffer responsible for the insert.
|
111 |
* @param dmo
|
112 |
* Record to be tracked.
|
113 |
* @param lock
|
114 |
* {@code true} to acquire write locks to insert the record;
|
115 |
* {@code false} to assume write locks are acquired by calling code.
|
116 |
*/
|
117 |
@Override
|
118 |
public void insert(RecordBuffer buffer, Record dmo, boolean lock) |
119 |
{ |
120 |
} |
121 |
|
122 |
/**
|
123 |
* NOP in this implementation.
|
124 |
*
|
125 |
* Indicate whether the specified record is being tracked as newly inserted
|
126 |
* by this context.
|
127 |
*
|
128 |
* @param ident
|
129 |
* Record identifier of the record to be checked.
|
130 |
*
|
131 |
* @return always {@code false} in this implementation.
|
132 |
*/
|
133 |
@Override
|
134 |
public boolean isTracked(RecordIdentifier<String> ident) |
135 |
{ |
136 |
return false; |
137 |
} |
138 |
|
139 |
/**
|
140 |
* NOP in this implementation.
|
141 |
*
|
142 |
* If the specified record is an unvalidated insert created by a buffer local to this context,
|
143 |
* get the buffer which created it.
|
144 |
*
|
145 |
* @param ident
|
146 |
* Record identifier of the record to be checked.
|
147 |
*
|
148 |
* @return always <code>null</code> in this implementation.
|
149 |
*/
|
150 |
@Override
|
151 |
public RecordBuffer getCreatingBuffer(RecordIdentifier<String> ident) |
152 |
{ |
153 |
return null; |
154 |
} |
155 |
|
156 |
/**
|
157 |
* NOP in this implementation.
|
158 |
*
|
159 |
* Rollback the insert of a record previously introduced with the {@link
|
160 |
* #insert(RecordBuffer, Record, boolean)} method.
|
161 |
*
|
162 |
* @param ident
|
163 |
* Identifier for the target record, which encapsulates its entity
|
164 |
* name and primary key.
|
165 |
* @param lock
|
166 |
* <code>true</code> to acquire write locks;
|
167 |
* <code>false</code> to assume write locks are acquired by
|
168 |
* calling code.
|
169 |
*/
|
170 |
@Override
|
171 |
public void rollbackInsert(RecordIdentifier<String> ident, boolean lock) |
172 |
{ |
173 |
} |
174 |
|
175 |
/**
|
176 |
* NOP in this implementation.
|
177 |
*
|
178 |
* Notify this object that a record was inserted into database and should not be tracked any more in
|
179 |
* {@code earlyInserts}.
|
180 |
*
|
181 |
* @param id
|
182 |
* The identifier of the record.
|
183 |
*/
|
184 |
@Override
|
185 |
public void recordInserted(RecordIdentifier<String> id) |
186 |
{ |
187 |
} |
188 |
|
189 |
/**
|
190 |
* NOP in this implementation.
|
191 |
*
|
192 |
* Track an update to one or more indexed, DMO properties, as indicated by the
|
193 |
* {@code properties}, {@code extIndexes} and {@code values} arguments.
|
194 |
* <p>
|
195 |
* Any record added to the dirty database as a result of this method is removed when the adding
|
196 |
* context's current transaction is committed or rolled back.
|
197 |
* <p>
|
198 |
* Assumes appropriate indexes have been locked by the caller.
|
199 |
*
|
200 |
* @param buffer
|
201 |
* Record buffer responsible for the update.
|
202 |
* @param properties
|
203 |
* Array of names of those DMO properties which were updated. These should represent
|
204 |
* columns which participate in one or more indexes.
|
205 |
* @param extIndexes
|
206 |
* In case of EXTENT fields this array contains their index. Otherwise -1.
|
207 |
* @param values
|
208 |
* Updated DMO property values. Each value in the array corresponds positionally with
|
209 |
* its matching property name in the {@code properties} array.
|
210 |
* @param transientIndexValidated
|
211 |
* {@code true} if the update was caused by an index validation of a transient record.
|
212 |
*/
|
213 |
@Override
|
214 |
public void update(RecordBuffer buffer, |
215 |
String[] properties, |
216 |
int[] extIndexes, |
217 |
BaseDataType[] values,
|
218 |
boolean transientIndexValidated)
|
219 |
{ |
220 |
} |
221 |
|
222 |
/**
|
223 |
* NOP in this implementation.
|
224 |
*
|
225 |
* Mark a record as having been deleted in an uncommitted transaction, or
|
226 |
* unmark a record which previously was so marked.
|
227 |
* <p>
|
228 |
* If marking a record as deleted, that was earlier inserted by the current
|
229 |
* context, rollback the insert, but do not mark the record as deleted.
|
230 |
* <p>
|
231 |
* A record is unmarked when the adding context's current transaction is
|
232 |
* committed or rolled back.
|
233 |
*
|
234 |
* @param entity
|
235 |
* Name of an entity, which is the name of the DMO implementation
|
236 |
* class associated with a table being tracked for uncommitted
|
237 |
* changes.
|
238 |
* @param id
|
239 |
* Primary key of deleted record.
|
240 |
* @param rollback
|
241 |
* If <code>false</code>, the target record is marked as deleted;
|
242 |
* if <code>true</code>, it is unmarked.
|
243 |
* @param lock
|
244 |
* <code>true</code> to acquire write locks to delete the record;
|
245 |
* <code>false</code> to assume write locks are acquired by
|
246 |
* calling code.
|
247 |
*/
|
248 |
@Override
|
249 |
public void delete(String entity, Long id, boolean rollback, boolean lock) |
250 |
{ |
251 |
} |
252 |
|
253 |
/**
|
254 |
* NOP in this implementation.
|
255 |
*
|
256 |
* Indicate whether there are currently any uncommitted changes (inserts,
|
257 |
* updates, or deletes) in the table represented by the given DMO entity
|
258 |
* name.
|
259 |
*
|
260 |
* @param entity
|
261 |
* Fully qualified name of the DMO entity to be checked.
|
262 |
*
|
263 |
* @return always {@code false} in this implementation.
|
264 |
*/
|
265 |
@Override
|
266 |
public boolean isEntityDirty(String entity) |
267 |
{ |
268 |
return false; |
269 |
} |
270 |
|
271 |
/**
|
272 |
* NOP in this implementation.
|
273 |
*
|
274 |
* Indicate whether the record specified by the given entity and primary key has
|
275 |
* been deleted within an uncommitted transaction within a context, optionally
|
276 |
* ignoring deletes in the current context.
|
277 |
*
|
278 |
* @param entity
|
279 |
* Name of an entity, which is the name of the DMO implementation
|
280 |
* class associated with a table being tracked for uncommitted
|
281 |
* changes.
|
282 |
* @param id
|
283 |
* Primary key of the record to be checked.
|
284 |
* @param ignoreLocal
|
285 |
* Ignore a delete if it occurred in the current context and only report
|
286 |
* whether a delete of the given record occurred in a different context.
|
287 |
*
|
288 |
* @return always {@code false} in this implementation.
|
289 |
*/
|
290 |
@Override
|
291 |
public boolean isDirtyDelete(String entity, Long id, boolean ignoreLocal) |
292 |
{ |
293 |
return false; |
294 |
} |
295 |
|
296 |
/**
|
297 |
* NOP in this implementation.
|
298 |
*
|
299 |
* Retrieve from the dirty database the record specified by the given
|
300 |
* entity and primary key, if it exists, and if it was not put there by the
|
301 |
* current context.
|
302 |
*
|
303 |
* @param entity
|
304 |
* Name of an entity, which is the name of the DMO implementation
|
305 |
* class associated with a table being tracked for uncommitted
|
306 |
* changes.
|
307 |
* @param id
|
308 |
* Primary key of the record to be retrieved.
|
309 |
*
|
310 |
* @return always {@code null} in this implementation.
|
311 |
*/
|
312 |
@Override
|
313 |
public Record getDirtyDMO(String entity, Long id) |
314 |
{ |
315 |
return null; |
316 |
} |
317 |
|
318 |
/**
|
319 |
* NOP in this implementation.
|
320 |
*
|
321 |
* Execute an HQL query and return the results as a list. If the query returns multiple
|
322 |
* results per row, each element in the list will be an array of {@code Object}s.
|
323 |
* <p>
|
324 |
* No locking is attempted.
|
325 |
*
|
326 |
* @param entity
|
327 |
* Name of an entity, which is the name of the DMO implementation class associated
|
328 |
* with a table being tracked for uncommitted changes. Should be {@code null}
|
329 |
* for a multi-table query.
|
330 |
* @param fql
|
331 |
* FQL query statement. This method makes no assumptions as to the types of object(s) returned.
|
332 |
* @param params
|
333 |
* Substitution values for the query. If none, this should be an empty array.
|
334 |
* @param maxResults
|
335 |
* The maximum number of elements to be returned in the list. If this value is
|
336 |
* non-positive, no upper limit is applied.
|
337 |
* @param startOffset
|
338 |
* The 0-based offset of the first record to retrieve. If this value is non-positive,
|
339 |
* an offset of 0 is used by default.
|
340 |
* @param readOnly
|
341 |
* {@code true} to execute the query in read-only mode, else {@code false}.
|
342 |
*
|
343 |
* @return always {@code null} in this implementation.
|
344 |
*/
|
345 |
@Override
|
346 |
public <T> List<T> list(String entity, |
347 |
String fql,
|
348 |
Object[] params, |
349 |
int maxResults,
|
350 |
int startOffset,
|
351 |
boolean readOnly)
|
352 |
{ |
353 |
return null; |
354 |
} |
355 |
|
356 |
/**
|
357 |
* NOP in this implementation.
|
358 |
*
|
359 |
* Given certain search criteria and possibly a potential DMO match in the primary database,
|
360 |
* report any significant information currently being tracked for uncommitted transactions,
|
361 |
* which might override data (or the lack thereof) found in the primary database.
|
362 |
* <p>
|
363 |
* If a {@link DirtyInfo} object is returned by this method, it will contain overriding
|
364 |
* information, such as a dirty DMO which matched the search criteria, whether that record was
|
365 |
* newly inserted, or the fact that the candidate record found in the primary search has been
|
366 |
* deleted or modified in an uncommitted transaction. A {@code null} return indicates no
|
367 |
* overriding information was available.
|
368 |
*
|
369 |
* @param buffer
|
370 |
* Record buffer associated with the current query.
|
371 |
* @param index
|
372 |
* UID of index which governs the ordering of data in the current query.
|
373 |
* @param queryType
|
374 |
* Type of query.
|
375 |
* @param bundle
|
376 |
* An object containing one or more FQL statements to be executed against the dirty
|
377 |
* database to find a record which matches the current query criteria. The list is in
|
378 |
* order of most specific to least specific search criteria.
|
379 |
* @param params
|
380 |
* Query substitution parameters which match placeholders in the most specific FQL
|
381 |
* statement.
|
382 |
* @param found
|
383 |
* DMO, if any, found in the primary database, which matches the current query criteria.
|
384 |
* @param byRowid
|
385 |
* The predicate of the query does a lookup for ROWID/RECID of the table. In case of
|
386 |
* transient records they are accessible without the need of having a full matched
|
387 |
* index.
|
388 |
*
|
389 |
* @return always {@code null} in this implementation.
|
390 |
*/
|
391 |
@Override
|
392 |
public DirtyInfo getDirtyInfo(RecordBuffer buffer,
|
393 |
int index,
|
394 |
int queryType,
|
395 |
FQLBundle bundle, |
396 |
Object[] params, |
397 |
Record found, |
398 |
boolean byRowid)
|
399 |
{ |
400 |
return null; |
401 |
} |
402 |
|
403 |
/**
|
404 |
* NOP in this implementation.
|
405 |
*
|
406 |
* Clean up all information contributed to the dirty share manager by this context for the current
|
407 |
* transaction. This method is called when a full database transaction has been committed or rolled back
|
408 |
* against the primary database. It is also invoked when the client context ends. It removes all records
|
409 |
* it added to the dirty database for new inserts, updates, and deletes.
|
410 |
*/
|
411 |
@Override
|
412 |
public void cleanup() |
413 |
{ |
414 |
} |
415 |
} |