KickJava   Java API By Example, From Geeks To Geeks.

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


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.Utils;
15
16 import javax.jdo.Transaction;
17 import javax.jdo.PersistenceManager;
18 import javax.jdo.Query;
19 import javax.jdo.PersistenceManagerFactory;
20 import javax.jdo.Extent;
21 import javax.jdo.spi.PersistenceCapable;
22
23 import javax.transaction.Synchronization JavaDoc;
24 import javax.transaction.xa.XAException JavaDoc;
25 import javax.transaction.xa.XAResource JavaDoc;
26 import javax.transaction.xa.Xid JavaDoc;
27  
28 import java.sql.Connection JavaDoc;
29 import java.util.Collection JavaDoc;
30 import java.util.List JavaDoc;
31
32
33
34 import com.versant.core.common.OID;
35 import com.versant.core.common.*;
36
37 /**
38  * Base class for proxies for VersantPersistenceManagerImp. This solves the case
39  * where a client closes the pm and it returns to the pool, but the client
40  * keeps a pc instance from the closed pm around. Synchronization is also
41  * provided by a synchronized subclass.
42  *
43  * Note that all the methods from the interfaces are repeated here as abstract
44  * because the IBM VMs barf otherwise.
45  *
46  * @see SynchronizedPMProxy
47  * @see UnsynchronizedPMProxy
48  */

49 public abstract class PMProxy implements VersantPersistenceManager, Transaction, VersantPMInternal
50
51         , XAResource JavaDoc, Synchronization JavaDoc
52  
53  {
54
55     public abstract void setPmCacheRefType(Object JavaDoc pc, int type);
56
57     public abstract void setPmCacheRefType(Object JavaDoc[] pcs, int type);
58
59     public abstract void setPmCacheRefType(Collection JavaDoc col, int type);
60
61     public abstract void setPmCacheRefType(int type);
62
63     public abstract int getPmCacheRefType();
64
65     public abstract boolean isInterceptDfgFieldAccess();
66
67     public abstract void setInterceptDfgFieldAccess(boolean interceptDfgFieldAccess);
68
69     public abstract VersantPersistenceManagerImp getRealPM();
70
71     /**
72      * Do not check to see if the PM has been closed.
73      */

74     abstract VersantPersistenceManagerImp getRealPMNoCheck();
75
76     public abstract void resetPM();
77
78     public abstract List JavaDoc versantAllDirtyInstances();
79
80     public abstract boolean isDirty();
81
82     public abstract void cancelQueryExecution();
83
84     public abstract Object JavaDoc getObjectByIDString(String JavaDoc value, boolean toValidate);
85
86     public abstract void loadFetchGroup(Object JavaDoc pc, String JavaDoc name);
87
88     public abstract void flush();
89
90     public abstract void flush(boolean retainState);
91
92     public abstract void makeTransientRecursive(Object JavaDoc pc);
93
94     public abstract Connection JavaDoc getJdbcConnection(String JavaDoc datastore);
95
96     public abstract String JavaDoc getConnectionURL(String JavaDoc dataStore);
97
98     public abstract String JavaDoc getConnectionDriverName(String JavaDoc dataStore);
99
100     public abstract boolean isClosed();
101
102     public abstract void close();
103
104     public abstract Transaction currentTransaction();
105
106     public abstract void evict(Object JavaDoc o);
107
108     public abstract void evictAll(Object JavaDoc[] objects);
109
110     public abstract void evictAll(Collection JavaDoc collection);
111
112     public abstract void evictAll();
113
114     public abstract void refresh(Object JavaDoc o);
115
116     public abstract void refreshAll(Object JavaDoc[] objects);
117
118     public abstract void refreshAll(Collection JavaDoc collection);
119
120     public abstract void refreshAll();
121
122     public abstract Query newQuery();
123
124     public abstract Query newQuery(Object JavaDoc o);
125
126     public abstract Query newQuery(String JavaDoc s, Object JavaDoc o);
127
128     public abstract Query newQuery(Class JavaDoc aClass);
129
130     public abstract Query newQuery(Extent extent);
131
132     public abstract Query newQuery(Class JavaDoc aClass, Collection JavaDoc collection);
133
134     public abstract Query newQuery(Class JavaDoc aClass, String JavaDoc s);
135
136     public abstract Query newQuery(Class JavaDoc aClass, Collection JavaDoc collection, String JavaDoc s);
137
138     public abstract Query newQuery(Extent extent, String JavaDoc s);
139
140     public abstract Extent getExtent(Class JavaDoc aClass, boolean b);
141
142     public abstract Object JavaDoc getObjectById(Object JavaDoc o, boolean b);
143
144     public abstract Object JavaDoc getObjectId(Object JavaDoc o);
145
146     public abstract Object JavaDoc getTransactionalObjectId(Object JavaDoc o);
147
148     public abstract Object JavaDoc newObjectIdInstance(Class JavaDoc aClass, String JavaDoc s);
149
150     public abstract void makePersistent(Object JavaDoc o);
151
152     public abstract void makePersistentAll(Object JavaDoc[] objects);
153
154     public abstract void makePersistentAll(Collection JavaDoc collection);
155
156     public abstract void deletePersistent(Object JavaDoc o);
157
158     public abstract void deletePersistentAll(Object JavaDoc[] objects);
159
160     public abstract void deletePersistentAll(Collection JavaDoc collection);
161
162     public abstract void makeTransient(Object JavaDoc o);
163
164     public abstract void makeTransientAll(Object JavaDoc[] objects);
165
166     public abstract void makeTransientAll(Collection JavaDoc collection);
167
168     public abstract void makeTransactional(Object JavaDoc o);
169
170     public abstract void makeTransactionalAll(Object JavaDoc[] objects);
171
172     public abstract void makeTransactionalAll(Collection JavaDoc collection);
173
174     public abstract void makeNontransactional(Object JavaDoc o);
175
176     public abstract void makeNontransactionalAll(Object JavaDoc[] objects);
177
178     public abstract void makeNontransactionalAll(Collection JavaDoc collection);
179
180     public abstract void retrieve(Object JavaDoc o);
181
182     public abstract void retrieveAll(Collection JavaDoc pcs, boolean DFGOnly);
183
184     public abstract void retrieveAll(Object JavaDoc[] pcs, boolean DFGOnly);
185
186     public abstract void retrieveAll(Collection JavaDoc collection);
187
188     public abstract void retrieveAll(Object JavaDoc[] objects);
189
190     public abstract void setUserObject(Object JavaDoc o);
191
192     public abstract Object JavaDoc getUserObject();
193
194     public abstract PersistenceManagerFactory getPersistenceManagerFactory();
195
196     public abstract Class JavaDoc getObjectIdClass(Class JavaDoc aClass);
197
198     public abstract void setMultithreaded(boolean b);
199
200     public abstract boolean getMultithreaded();
201
202     public abstract void setIgnoreCache(boolean b);
203
204     public abstract boolean getIgnoreCache();
205
206
207     public abstract void commit(Xid JavaDoc xid, boolean b) throws XAException JavaDoc;
208
209     public abstract void end(Xid JavaDoc xid, int i) throws XAException JavaDoc;
210
211     public abstract void forget(Xid JavaDoc xid) throws XAException JavaDoc;
212
213     public abstract int getTransactionTimeout() throws XAException JavaDoc;
214
215     public abstract boolean isSameRM(XAResource JavaDoc xaResource) throws XAException JavaDoc;
216
217     public abstract int prepare(Xid JavaDoc xid) throws XAException JavaDoc;
218
219     public abstract Xid JavaDoc[] recover(int i) throws XAException JavaDoc;
220
221     public abstract void rollback(Xid JavaDoc xid) throws XAException JavaDoc;
222
223     public abstract boolean setTransactionTimeout(int i) throws XAException JavaDoc;
224
225     public abstract void start(Xid JavaDoc xid, int i) throws XAException JavaDoc;
226
227     public abstract void afterCompletion(int i);
228
229     public abstract void beforeCompletion();
230
231
232     public abstract OID getInternalOID(final PersistenceCapable pc);
233
234     public abstract PCStateMan getInternalSM(final PersistenceCapable pc);
235
236     public abstract boolean isActive();
237
238     public abstract void begin();
239
240     public abstract void commit();
241
242     public abstract boolean getNontransactionalRead();
243
244     public abstract boolean getNontransactionalWrite();
245
246     public abstract boolean getOptimistic();
247
248     public abstract PersistenceManager getPersistenceManager();
249
250     public abstract boolean getRestoreValues();
251
252     public abstract boolean getRetainValues();
253
254
255     public abstract Synchronization JavaDoc getSynchronization();
256
257
258     public abstract void rollback();
259
260     public abstract void setNontransactionalRead(boolean b);
261
262     public abstract void setNontransactionalWrite(boolean b);
263
264     public abstract void setOptimistic(boolean b);
265
266     public abstract void setRestoreValues(boolean b);
267
268     public abstract void setRetainValues(boolean b);
269
270
271     public abstract void setSynchronization(Synchronization JavaDoc synchronization);
272
273
274     public abstract void setDatastoreTxLocking(int mode);
275
276     public abstract int getDatastoreTxLocking();
277
278     public abstract void setRetainConnectionInOptTx(boolean on);
279
280     public abstract Object JavaDoc getObjectByIdFromCache(Object JavaDoc oid);
281
282     public abstract boolean isHollow(Object JavaDoc pc);
283
284     public abstract boolean hasIdentity(Object JavaDoc pc);
285
286     public abstract Object JavaDoc newObjectIdInstance(Class JavaDoc pcClass, String JavaDoc str,
287             boolean resolved);
288
289     public abstract Object JavaDoc getObjectByIDString(String JavaDoc value, boolean toValidate,
290             boolean resolved);
291
292     public abstract void logEvent(int level, String JavaDoc description, int ms);
293
294     public abstract Query versantNewNamedQuery(Class JavaDoc cls, String JavaDoc queryName);
295
296     public abstract boolean isCheckModelConsistencyOnCommit();
297
298     public abstract void setCheckModelConsistencyOnCommit(boolean on);
299
300     public abstract void checkModelConsistency();
301
302     /**
303      * Get a user friendly string identifying this PM for use in error
304      * messages and so on.
305      */

306     public String JavaDoc toMsgString() {
307         StringBuffer JavaDoc s = new StringBuffer JavaDoc();
308         s.append("0x");
309         s.append(Integer.toHexString(System.identityHashCode(this)));
310         VersantPersistenceManagerImp realPM = getRealPMNoCheck();
311         if (realPM == null) {
312             s.append(" CLOSED");
313         } else {
314             Object JavaDoc userObject = realPM.getUserObject();
315             if (userObject != null) {
316                 s.append(' ');
317                 s.append(Utils.toString(userObject));
318             }
319         }
320         return s.toString();
321     }
322
323     /**
324      * Include identity hashcode to help clients identify the PM they are
325      * using.
326      */

327     public String JavaDoc toString() {
328         return "PM " + toMsgString();
329     }
330
331     public abstract int getObjectsById(Object JavaDoc[] oids, int length, Object JavaDoc[] data,
332             int stateFieldNo, int classMetaDataIndex);
333
334     public abstract Collection JavaDoc versantDetachCopy(Collection JavaDoc pcs, String JavaDoc fetchGroup);
335
336     public abstract Collection JavaDoc versantAttachCopy(Collection JavaDoc detached,
337             boolean makeTransactional);
338
339     public abstract Collection JavaDoc versantAttachCopy(Collection JavaDoc detached,
340             boolean makeTransactional, boolean shallow);
341
342     public abstract void evictFromL2CacheAfterCommit(Object JavaDoc o);
343
344     public abstract void evictAllFromL2CacheAfterCommit(Object JavaDoc[] a);
345
346     public abstract void evictAllFromL2CacheAfterCommit(Collection JavaDoc c);
347
348     public abstract void evictAllFromL2CacheAfterCommit(Class JavaDoc cls,
349             boolean includeSubclasses);
350
351     public abstract void evictAllFromL2CacheAfterCommit();
352
353     public final PersistenceCapable cast2persistent(Object JavaDoc o)
354     { // see VersantPersistenceManagerImp.checkPersCapable
355
try {
356             return (PersistenceCapable)o;
357         } catch (ClassCastException JavaDoc e) {
358             throw BindingSupportImpl.getInstance().invalidOperation("The supplied instance is not of type " +
359                     PersistenceCapable.class.getName() +
360                     " (" + o.getClass().getName() + ")");
361         }
362     }
363
364
365 }
366
Popular Tags