KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > SynchronizedStateManagerProxy


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdo;
13
14 import com.versant.core.common.OID;
15
16 import javax.jdo.spi.PersistenceCapable;
17 import javax.jdo.spi.StateManager;
18 import javax.jdo.PersistenceManager;
19
20
21
22 /**
23  * Wraps a VersantStateManager adding synchronizing all methods on a lock
24  * object. This is used for thread safe PMs.
25  */

26 public final class SynchronizedStateManagerProxy
27         implements VersantStateManager
28  {
29
30     private final Object JavaDoc lock;
31     private final PCStateMan sm;
32
33     public SynchronizedStateManagerProxy(Object JavaDoc lock, PCStateMan sm) {
34         this.lock = lock;
35         this.sm = sm;
36     }
37
38     public OID getOID() {
39         return sm.getOID();
40     }
41
42     public PersistenceCapable getPersistenceCapable() {
43         return sm.getPersistenceCapable();
44     }
45
46     public void makeDirty(PersistenceCapable persistenceCapable,
47             int managedFieldNo) {
48         synchronized (lock) {
49             sm.makeDirty(persistenceCapable, managedFieldNo);
50         }
51     }
52
53     public byte replacingFlags(PersistenceCapable pc) {
54         synchronized (lock) {
55             return sm.replacingFlags(pc);
56         }
57     }
58
59     public StateManager replacingStateManager(PersistenceCapable pc,
60             StateManager smp) {
61         synchronized (lock) {
62             return sm.replacingStateManager(pc, smp);
63         }
64     }
65
66     public boolean isDirty(PersistenceCapable pc) {
67         synchronized (lock) {
68             return sm.isDirty(pc);
69         }
70     }
71
72     public boolean isTransactional(PersistenceCapable pc) {
73         synchronized (lock) {
74             return sm.isTransactional(pc);
75         }
76     }
77
78     public boolean isPersistent(PersistenceCapable pc) {
79         synchronized (lock) {
80             return sm.isPersistent(pc);
81         }
82     }
83
84     public boolean isNew(PersistenceCapable pc) {
85         synchronized (lock) {
86             return sm.isNew(pc);
87         }
88     }
89
90     public boolean isDeleted(PersistenceCapable pc) {
91         synchronized (lock) {
92             return sm.isDeleted(pc);
93         }
94     }
95
96     public PersistenceManager getPersistenceManager(PersistenceCapable pc) {
97         synchronized (lock) {
98             return sm.getPersistenceManager(pc);
99         }
100     }
101
102     public void makeDirty(PersistenceCapable pc, String JavaDoc fieldName) {
103         synchronized (lock) {
104             sm.makeDirty(pc, fieldName);
105         }
106     }
107
108     public Object JavaDoc getObjectId(PersistenceCapable pc) {
109         synchronized (lock) {
110             return sm.getObjectId(pc);
111         }
112     }
113
114     public Object JavaDoc getTransactionalObjectId(PersistenceCapable pc) {
115         synchronized (lock) {
116             return sm.getTransactionalObjectId(pc);
117         }
118     }
119
120     public boolean isLoaded(PersistenceCapable pc, int field) {
121         synchronized (lock) {
122             return sm.isLoaded(pc, field);
123         }
124     }
125
126     public void preSerialize(PersistenceCapable pc) {
127         synchronized (lock) {
128             sm.preSerialize(pc);
129         }
130     }
131
132     public synchronized boolean getBooleanField(PersistenceCapable pc, int field,
133             boolean currentValue) {
134         synchronized (lock) {
135             return sm.getBooleanField(pc, field, currentValue);
136         }
137     }
138
139     public char getCharField(PersistenceCapable pc, int field,
140             char currentValue) {
141         synchronized (lock) {
142             return sm.getCharField(pc, field, currentValue);
143         }
144     }
145
146     public byte getByteField(PersistenceCapable pc, int field,
147             byte currentValue) {
148         synchronized (lock) {
149             return sm.getByteField(pc, field, currentValue);
150         }
151     }
152
153     public short getShortField(PersistenceCapable pc, int field,
154             short currentValue) {
155         synchronized (lock) {
156             return sm.getShortField(pc, field, currentValue);
157         }
158     }
159
160     public int getIntField(PersistenceCapable pc, int field, int currentValue) {
161         synchronized (lock) {
162             return sm.getIntField(pc, field, currentValue);
163         }
164     }
165
166     public long getLongField(PersistenceCapable pc, int field,
167             long currentValue) {
168         synchronized (lock) {
169             return sm.getLongField(pc, field, currentValue);
170         }
171     }
172
173     public float getFloatField(PersistenceCapable pc, int field,
174             float currentValue) {
175         synchronized (lock) {
176             return sm.getFloatField(pc, field, currentValue);
177         }
178     }
179
180     public double getDoubleField(PersistenceCapable pc, int field,
181             double currentValue) {
182         synchronized (lock) {
183             return sm.getDoubleField(pc, field, currentValue);
184         }
185     }
186
187     public String JavaDoc getStringField(PersistenceCapable pc, int field,
188             String JavaDoc currentValue) {
189         synchronized (lock) {
190             return sm.getStringField(pc, field,
191                     currentValue);
192         }
193     }
194
195     public Object JavaDoc getObjectField(PersistenceCapable pc, int field,
196             Object JavaDoc currentValue) {
197         synchronized (lock) {
198             return sm.getObjectField(pc, field,
199                     currentValue);
200         }
201     }
202
203     public void setBooleanField(PersistenceCapable pc, int field,
204             boolean currentValue, boolean newValue) {
205         synchronized (lock) {
206             sm.setBooleanField(pc, field, currentValue, newValue);
207         }
208     }
209
210     public void setCharField(PersistenceCapable pc, int field, char currentValue,
211             char newValue) {
212         synchronized (lock) {
213             sm.setCharField(pc, field, currentValue, newValue);
214         }
215     }
216
217     public void setByteField(PersistenceCapable pc, int field, byte currentValue,
218             byte newValue) {
219         synchronized (lock) {
220             sm.setByteField(pc, field, currentValue,
221                     newValue);
222         }
223     }
224
225     public void setShortField(PersistenceCapable pc, int field, short currentValue,
226             short newValue) {
227         synchronized (lock) {
228             sm.setShortField(pc, field, currentValue,
229                     newValue);
230         }
231     }
232
233     public void setIntField(PersistenceCapable pc, int field, int currentValue,
234             int newValue) {
235         synchronized (lock) {
236             sm.setIntField(pc, field, currentValue,
237                     newValue);
238         }
239     }
240
241     public void setLongField(PersistenceCapable pc, int field, long currentValue,
242             long newValue) {
243         synchronized (lock) {
244             sm.setLongField(pc, field, currentValue,
245                     newValue);
246         }
247     }
248
249     public void setFloatField(PersistenceCapable pc, int field, float currentValue,
250             float newValue) {
251         synchronized (lock) {
252             sm.setFloatField(pc, field, currentValue,
253                     newValue);
254         }
255     }
256
257     public void setDoubleField(PersistenceCapable pc, int field, double currentValue,
258             double newValue) {
259         synchronized (lock) {
260             sm.setDoubleField(pc, field, currentValue,
261                     newValue);
262         }
263     }
264
265     public void setStringField(PersistenceCapable pc, int field, String JavaDoc currentValue,
266             String JavaDoc newValue) {
267         synchronized (lock) {
268             sm.setStringField(pc, field, currentValue,
269                     newValue);
270         }
271     }
272
273     public void setObjectField(PersistenceCapable pc, int field, Object JavaDoc currentValue,
274             Object JavaDoc newValue) {
275         synchronized (lock) {
276             sm.setObjectField(pc, field, currentValue,
277                     newValue);
278         }
279     }
280
281     public void providedBooleanField(PersistenceCapable pc, int field,
282             boolean currentValue) {
283         synchronized (lock) {
284             sm.providedBooleanField(pc, field, currentValue);
285         }
286     }
287
288     public void providedCharField(PersistenceCapable pc, int field,
289             char currentValue) {
290         synchronized (lock) {
291             sm.providedCharField(pc, field, currentValue);
292         }
293     }
294
295     public void providedByteField(PersistenceCapable pc, int field,
296             byte currentValue) {
297         synchronized (lock) {
298             sm.providedByteField(pc, field, currentValue);
299         }
300     }
301
302     public void providedShortField(PersistenceCapable pc, int field,
303             short currentValue) {
304         synchronized (lock) {
305             sm.providedShortField(pc, field, currentValue);
306         }
307     }
308
309     public void providedIntField(PersistenceCapable pc, int field,
310             int currentValue) {
311         synchronized (lock) {
312             sm.providedIntField(pc, field, currentValue);
313         }
314     }
315
316     public void providedLongField(PersistenceCapable pc, int field,
317             long currentValue) {
318         synchronized (lock) {
319             sm.providedLongField(pc, field, currentValue);
320         }
321     }
322
323     public void providedFloatField(PersistenceCapable pc, int field,
324             float currentValue) {
325         synchronized (lock) {
326             sm.providedFloatField(pc, field, currentValue);
327         }
328     }
329
330     public void providedDoubleField(PersistenceCapable pc, int field,
331             double currentValue) {
332         synchronized (lock) {
333             sm.providedDoubleField(pc, field, currentValue);
334         }
335     }
336
337     public void providedStringField(PersistenceCapable pc, int field,
338             String JavaDoc currentValue) {
339         synchronized (lock) {
340             sm.providedStringField(pc, field, currentValue);
341         }
342     }
343
344     public void providedObjectField(PersistenceCapable pc, int field,
345             Object JavaDoc currentValue) {
346         synchronized (lock) {
347             sm.providedObjectField(pc, field, currentValue);
348         }
349     }
350
351     public boolean replacingBooleanField(PersistenceCapable pc, int field) {
352         synchronized (lock) {
353             return sm.replacingBooleanField(pc, field);
354         }
355     }
356
357     public char replacingCharField(PersistenceCapable pc, int field) {
358         synchronized (lock) {
359             return sm.replacingCharField(pc, field);
360         }
361     }
362
363     public byte replacingByteField(PersistenceCapable pc, int field) {
364         synchronized (lock) {
365             return sm.replacingByteField(pc, field);
366         }
367     }
368
369     public short replacingShortField(PersistenceCapable pc, int field) {
370         synchronized (lock) {
371             return sm.replacingShortField(pc, field);
372         }
373     }
374
375     public int replacingIntField(PersistenceCapable pc, int field) {
376         synchronized (lock) {
377             return sm.replacingIntField(pc, field);
378         }
379     }
380
381     public long replacingLongField(PersistenceCapable pc, int field) {
382         synchronized (lock) {
383             return sm.replacingLongField(pc, field);
384         }
385     }
386
387     public float replacingFloatField(PersistenceCapable pc, int field) {
388         synchronized (lock) {
389             return sm.replacingFloatField(pc, field);
390         }
391     }
392
393     public double replacingDoubleField(PersistenceCapable pc, int field) {
394         synchronized (lock) {
395             return sm.replacingDoubleField(pc, field);
396         }
397     }
398
399     public String JavaDoc replacingStringField(PersistenceCapable pc, int field) {
400         synchronized (lock) {
401             return sm.replacingStringField(pc, field);
402         }
403     }
404
405     public Object JavaDoc replacingObjectField(PersistenceCapable pc, int field) {
406         synchronized (lock) {
407             return sm.replacingObjectField(pc, field);
408         }
409     }
410
411     public void fillNewAppPKField(int fieldNo) {
412         synchronized (lock) {
413             sm.fillNewAppPKField(fieldNo);
414         }
415     }
416
417
418
419
420
421
422
423 }
424
425
Popular Tags