001: /*
002: * Copyright (c) 1998 - 2005 Versant Corporation
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * Versant Corporation - initial API and implementation
010: */
011: package com.versant.core.jdo;
012:
013: import com.versant.core.server.QueryResultWrapper;
014: import com.versant.core.server.CompiledQuery;
015:
016: import javax.jdo.Transaction;
017: import javax.jdo.PersistenceManager;
018: import javax.jdo.Query;
019: import javax.jdo.PersistenceManagerFactory;
020: import javax.jdo.Extent;
021: import javax.jdo.spi.PersistenceCapable;
022:
023: import javax.transaction.Synchronization;
024: import javax.transaction.xa.XAException;
025: import javax.transaction.xa.XAResource;
026: import javax.transaction.xa.Xid;
027:
028: import java.sql.Connection;
029: import java.util.Collection;
030: import java.util.List;
031:
032: import com.versant.core.common.BindingSupportImpl;
033: import com.versant.core.common.OID;
034: import com.versant.core.common.State;
035: import com.versant.core.common.*;
036: import com.versant.core.storagemanager.ExecuteQueryReturn;
037:
038: /**
039: * This is a unsynchronized proxy to VersantPersistenceManagerImp.
040: *
041: * @see PMProxy
042: * @see SynchronizedPMProxy
043: */
044: public final class UnsynchronizedPMProxy extends PMProxy {
045:
046: private VersantPersistenceManagerImp realPM;
047:
048: public UnsynchronizedPMProxy(VersantPersistenceManagerImp realPM) {
049: this .realPM = realPM;
050: }
051:
052: public void flushIfDepOn(int[] bits) {
053: realPM.flushIfDepOn(bits);
054: }
055:
056: public void processLocalCacheReferenceQueue() {
057: realPM.processLocalCacheReferenceQueue();
058: }
059:
060: public QueryResultWrapper executeQuery(CompiledQuery cq,
061: Object[] params) {
062: return realPM.getStorageManager().executeQuery(realPM, null,
063: cq, params);
064: }
065:
066: public QueryResultContainer getNextQueryResult(
067: QueryResultWrapper aQrs, int skipAmount) {
068: return realPM.getStorageManager().fetchNextQueryResult(realPM,
069: ((ExecuteQueryReturn) aQrs).getRunningQuery(),
070: skipAmount);
071: }
072:
073: public void addToCache(StatesReturned container) {
074: realPM.addToCache(container);
075: }
076:
077: public void closeQuery(QueryResultWrapper qrw) {
078: realPM.getStorageManager().closeQuery(
079: ((ExecuteQueryReturn) qrw).getRunningQuery());
080: }
081:
082: public QueryResultContainer getAbsolute(QueryResultWrapper qrsIF,
083: int index, int fetchAmount) {
084: return realPM.getStorageManager().fetchRandomAccessQueryResult(
085: realPM, ((ExecuteQueryReturn) qrsIF).getRunningQuery(),
086: index, fetchAmount);
087: }
088:
089: public int getResultCount(QueryResultWrapper qrsIF) {
090: return realPM.getStorageManager().getRandomAccessQueryCount(
091: realPM, ((ExecuteQueryReturn) qrsIF).getRunningQuery());
092: }
093:
094: public QueryResultContainer getAllQueryResults(CompiledQuery cq,
095: Object[] params) {
096: return realPM.getStorageManager().executeQueryAll(realPM, null,
097: cq, params);
098: }
099:
100: public void setMasterOnDetail(PersistenceCapable detail,
101: int managedFieldNo, PersistenceCapable master,
102: boolean removeFromCurrentMaster) {
103: realPM.setMasterOnDetail(detail, managedFieldNo, master,
104: removeFromCurrentMaster);
105: }
106:
107: public Object getObjectField(PersistenceCapable pc, int fieldNo) {
108: return realPM.getObjectField(pc, fieldNo);
109: }
110:
111: public int getQueryRowCount(CompiledQuery cq, Object[] params) {
112: return realPM.getStorageManager().executeQueryCount(null, cq,
113: params);
114: }
115:
116: public Object getOptimisticLockingValue(Object o) {
117: checkClosed();
118: return realPM.getOptimisticLockingValue(o);
119: }
120:
121: public void setPmCacheRefType(Object pc, int type) {
122: checkClosed();
123: realPM.setPmCacheRefType(pc, type);
124: }
125:
126: public void setPmCacheRefType(Object[] pcs, int type) {
127: checkClosed();
128: realPM.setPmCacheRefType(pcs, type);
129: }
130:
131: public void setPmCacheRefType(Collection col, int type) {
132: checkClosed();
133: realPM.setPmCacheRefType(col, type);
134: }
135:
136: public void setPmCacheRefType(int type) {
137: checkClosed();
138: realPM.setPmCacheRefType(type);
139: }
140:
141: public int getPmCacheRefType() {
142: checkClosed();
143: return realPM.getPmCacheRefType();
144: }
145:
146: /**
147: * If default fetch group fields will be intercepted on a
148: * Persistent-Non-Transaction instance. If this is disabled then such a
149: * instance will not be 'refreshed' if accessed in a datastore transaction.
150: */
151: public boolean isInterceptDfgFieldAccess() {
152: return realPM.isInterceptDfgFieldAccess();
153: }
154:
155: public void setInterceptDfgFieldAccess(
156: boolean interceptDfgFieldAccess) {
157: realPM.setInterceptDfgFieldAccess(interceptDfgFieldAccess);
158: }
159:
160: public VersantPersistenceManagerImp getRealPM() {
161: checkClosed();
162: return realPM;
163: }
164:
165: VersantPersistenceManagerImp getRealPMNoCheck() {
166: return realPM;
167: }
168:
169: public void resetPM() {
170: realPM = null;
171: }
172:
173: public boolean isRealPMNull() {
174: return realPM == null;
175: }
176:
177: public List versantAllDirtyInstances() {
178: checkClosed();
179: return realPM.versantAllDirtyInstances();
180: }
181:
182: private void checkClosed() {
183: if (realPM == null) {
184: throw BindingSupportImpl.getInstance().invalidOperation(
185: "The pm is closed");
186: }
187: }
188:
189: public boolean isDirty() {
190: checkClosed();
191: return realPM.isDirty();
192: }
193:
194: public void cancelQueryExecution() {
195: checkClosed();
196: realPM.cancelQueryExecution();
197: }
198:
199: public Object getObjectByIDString(String value, boolean toValidate) {
200: checkClosed();
201: return realPM.getObjectByIDString(value, toValidate);
202: }
203:
204: public void loadFetchGroup(Object pc, String name) {
205: checkClosed();
206: realPM.loadFetchGroup(pc, name);
207: }
208:
209: public void flush() {
210: checkClosed();
211: realPM.flush();
212: }
213:
214: public void flush(boolean retainState) {
215: checkClosed();
216: realPM.flush(retainState);
217: }
218:
219: public void makeTransientRecursive(Object pc) {
220: checkClosed();
221: realPM.makeTransientRecursive(pc);
222: }
223:
224: public Connection getJdbcConnection(String datastore) {
225: checkClosed();
226: return realPM.getJdbcConnection(datastore);
227: }
228:
229: public String getConnectionURL(String dataStore) {
230: checkClosed();
231: return realPM.getConnectionURL(dataStore);
232: }
233:
234: public String getConnectionDriverName(String dataStore) {
235: checkClosed();
236: return realPM.getConnectionDriverName(dataStore);
237: }
238:
239: public boolean isClosed() {
240: return realPM == null;
241: }
242:
243: public void close() {
244: if (realPM == null) {
245: return;
246: }
247: realPM.close();
248: }
249:
250: public Transaction currentTransaction() {
251: checkClosed();
252: return this ;
253: }
254:
255: public void evict(Object o) {
256: checkClosed();
257: realPM.evict(o);
258: }
259:
260: public void evictAll(Object[] objects) {
261: checkClosed();
262: realPM.evictAll(objects);
263: }
264:
265: public void evictAll(Collection collection) {
266: checkClosed();
267: realPM.evictAll(collection);
268: }
269:
270: public void evictAll() {
271: checkClosed();
272: realPM.evictAll();
273: }
274:
275: public void refresh(Object o) {
276: checkClosed();
277: realPM.refresh(o);
278: }
279:
280: public void refreshAll(Object[] objects) {
281: checkClosed();
282: realPM.refreshAll(objects);
283: }
284:
285: public void refreshAll(Collection collection) {
286: checkClosed();
287: realPM.refreshAll(collection);
288: }
289:
290: public void refreshAll() {
291: checkClosed();
292: realPM.refreshAll();
293: }
294:
295: public Query newQuery() {
296: checkClosed();
297: return realPM.newQuery();
298: }
299:
300: public Query newQuery(Object o) {
301: checkClosed();
302: return realPM.newQuery(o);
303: }
304:
305: public Query newQuery(String s, Object o) {
306: checkClosed();
307: return realPM.newQuery(s, o);
308: }
309:
310: public Query newQuery(Class aClass) {
311: checkClosed();
312: return realPM.newQuery(aClass);
313: }
314:
315: public Query newQuery(Extent extent) {
316: checkClosed();
317: return realPM.newQuery(extent);
318: }
319:
320: public Query newQuery(Class aClass, Collection collection) {
321: checkClosed();
322: return realPM.newQuery(aClass, collection);
323: }
324:
325: public Query newQuery(Class aClass, String s) {
326: checkClosed();
327: return realPM.newQuery(aClass, s);
328: }
329:
330: public Query newQuery(Class aClass, Collection collection, String s) {
331: checkClosed();
332: return realPM.newQuery(aClass, collection, s);
333: }
334:
335: public Query newQuery(Extent extent, String s) {
336: checkClosed();
337: return realPM.newQuery(extent, s);
338: }
339:
340: public Extent getExtent(Class aClass, boolean b) {
341: checkClosed();
342: return realPM.getExtent(aClass, b);
343: }
344:
345: public Object getObjectById(Object o, boolean b) {
346: checkClosed();
347: return realPM.getObjectById(o, b);
348: }
349:
350: public Object getObjectId(Object o) {
351: checkClosed();
352: return realPM.getObjectId(o);
353: }
354:
355: public Object getTransactionalObjectId(Object o) {
356: checkClosed();
357: return realPM.getTransactionalObjectId(o);
358: }
359:
360: public Object newObjectIdInstance(Class aClass, String s) {
361: checkClosed();
362: return realPM.newObjectIdInstance(aClass, s);
363: }
364:
365: public void makePersistent(Object o) {
366: checkClosed();
367: realPM.makePersistent(o);
368: }
369:
370: public void makePersistentAll(Object[] objects) {
371: checkClosed();
372: realPM.makePersistentAll(objects);
373: }
374:
375: public void makePersistentAll(Collection collection) {
376: checkClosed();
377: realPM.makePersistentAll(collection);
378: }
379:
380: public void deletePersistent(Object o) {
381: checkClosed();
382: realPM.deletePersistent(o);
383: }
384:
385: public void deletePersistentAll(Object[] objects) {
386: checkClosed();
387: realPM.deletePersistentAll(objects);
388: }
389:
390: public void deletePersistentAll(Collection collection) {
391: checkClosed();
392: realPM.deletePersistentAll(collection);
393: }
394:
395: public void makeTransient(Object o) {
396: checkClosed();
397: realPM.makeTransient(o);
398: }
399:
400: public void makeTransientAll(Object[] objects) {
401: checkClosed();
402: realPM.makeTransientAll(objects);
403: }
404:
405: public void makeTransientAll(Collection collection) {
406: checkClosed();
407: realPM.makeTransientAll(collection);
408: }
409:
410: public void makeTransactional(Object o) {
411: checkClosed();
412: realPM.makeTransactional(o);
413: }
414:
415: public void makeTransactionalAll(Object[] objects) {
416: checkClosed();
417: realPM.makeTransactionalAll(objects);
418: }
419:
420: public void makeTransactionalAll(Collection collection) {
421: checkClosed();
422: realPM.makeTransactionalAll(collection);
423: }
424:
425: public void makeNontransactional(Object o) {
426: checkClosed();
427: realPM.makeNontransactional(o);
428: }
429:
430: public void makeNontransactionalAll(Object[] objects) {
431: checkClosed();
432: realPM.makeNontransactionalAll(objects);
433: }
434:
435: public void makeNontransactionalAll(Collection collection) {
436: checkClosed();
437: realPM.makeNontransactionalAll(collection);
438: }
439:
440: public void retrieve(Object o) {
441: checkClosed();
442: realPM.retrieve(o);
443: }
444:
445: public void retrieveAll(Collection pcs, boolean DFGOnly) {
446: checkClosed();
447: realPM.retrieveAll(pcs, DFGOnly);
448: }
449:
450: public void retrieveAll(Object[] pcs, boolean DFGOnly) {
451: checkClosed();
452: realPM.retrieveAll(pcs, DFGOnly);
453: }
454:
455: public void retrieveAll(Collection collection) {
456: checkClosed();
457: realPM.retrieveAll(collection);
458: }
459:
460: public void retrieveAll(Object[] objects) {
461: checkClosed();
462: realPM.retrieveAll(objects);
463: }
464:
465: public void setUserObject(Object o) {
466: checkClosed();
467: realPM.setUserObject(o);
468: }
469:
470: public Object getUserObject() {
471: checkClosed();
472: return realPM.getUserObject();
473: }
474:
475: public PersistenceManagerFactory getPersistenceManagerFactory() {
476: checkClosed();
477: return realPM.getPersistenceManagerFactory();
478: }
479:
480: public Class getObjectIdClass(Class aClass) {
481: checkClosed();
482: return realPM.getObjectIdClass(aClass);
483: }
484:
485: public void setMultithreaded(boolean b) {
486: checkClosed();
487: realPM.setMultithreaded(b);
488: }
489:
490: public boolean getMultithreaded() {
491: checkClosed();
492: return realPM.getMultithreaded();
493: }
494:
495: public void setIgnoreCache(boolean b) {
496: checkClosed();
497: realPM.setIgnoreCache(b);
498: }
499:
500: public boolean getIgnoreCache() {
501: checkClosed();
502: return realPM.getIgnoreCache();
503: }
504:
505: public void commit(Xid xid, boolean b) throws XAException {
506: checkClosed();
507: realPM.commit(xid, b);
508: }
509:
510: public void end(Xid xid, int i) throws XAException {
511: checkClosed();
512: realPM.end(xid, i);
513: }
514:
515: public void forget(Xid xid) throws XAException {
516: checkClosed();
517: realPM.forget(xid);
518: }
519:
520: public int getTransactionTimeout() throws XAException {
521: checkClosed();
522: return realPM.getTransactionTimeout();
523: }
524:
525: public boolean isSameRM(XAResource xaResource) throws XAException {
526: if (realPM == null)
527: return false;
528: return realPM.isSameRM(xaResource);
529: }
530:
531: public int prepare(Xid xid) throws XAException {
532: checkClosed();
533: return realPM.prepare(xid);
534: }
535:
536: public Xid[] recover(int i) throws XAException {
537: checkClosed();
538: return realPM.recover(i);
539: }
540:
541: public void rollback(Xid xid) throws XAException {
542: checkClosed();
543: realPM.rollback(xid);
544: }
545:
546: public boolean setTransactionTimeout(int i) throws XAException {
547: checkClosed();
548: return realPM.setTransactionTimeout(i);
549: }
550:
551: public void start(Xid xid, int i) throws XAException {
552: checkClosed();
553: realPM.start(xid, i);
554: }
555:
556: public void afterCompletion(int i) {
557: checkClosed();
558: realPM.afterCompletion(i);
559: }
560:
561: public void beforeCompletion() {
562: checkClosed();
563: realPM.beforeCompletion();
564: }
565:
566: public OID getInternalOID(final PersistenceCapable pc) {
567: checkClosed();
568: return realPM.getInternalOID(pc);
569: }
570:
571: public PCStateMan getInternalSM(final PersistenceCapable pc) {
572: checkClosed();
573: return realPM.getInternalSM(pc);
574: }
575:
576: public PCStateMan getInternalSM(OID oid) {
577: checkClosed();
578: return realPM.getInternalSM(oid);
579: }
580:
581: public State getInternaleState(PersistenceCapable pc) {
582: checkClosed();
583: return realPM.getInternaleState(pc);
584: }
585:
586: public void addTxStateObject(PCStateMan stateObject) {
587: checkClosed();
588: realPM.addTxStateObject(stateObject);
589: }
590:
591: public void removeTxStateObject(PCStateMan stateObject) {
592: checkClosed();
593: realPM.removeTxStateObject(stateObject);
594: }
595:
596: public boolean isOptimistic() {
597: checkClosed();
598: return realPM.getOptimistic();
599: }
600:
601: public boolean isRetainValues() {
602: checkClosed();
603: return realPM.getRetainValues();
604: }
605:
606: public boolean isRestoreValues() {
607: checkClosed();
608: return realPM.getRestoreValues();
609: }
610:
611: public boolean isActive() {
612: checkClosed();
613: return realPM.isActive();
614: }
615:
616: public void begin() {
617: checkClosed();
618: realPM.begin();
619: }
620:
621: public void commit() {
622: checkClosed();
623: realPM.commit();
624: }
625:
626: public boolean getNontransactionalRead() {
627: checkClosed();
628: return realPM.getNontransactionalRead();
629: }
630:
631: public boolean getNontransactionalWrite() {
632: checkClosed();
633: return realPM.getNontransactionalWrite();
634: }
635:
636: public boolean getOptimistic() {
637: checkClosed();
638: return realPM.getOptimistic();
639: }
640:
641: public PersistenceManager getPersistenceManager() {
642: checkClosed();
643: return this ;
644: }
645:
646: public boolean getRestoreValues() {
647: checkClosed();
648: return realPM.getRestoreValues();
649: }
650:
651: public boolean getRetainValues() {
652: checkClosed();
653: return realPM.getRetainValues();
654: }
655:
656: public Synchronization getSynchronization() {
657: checkClosed();
658: return realPM.getSynchronization();
659: }
660:
661: public void rollback() {
662: checkClosed();
663: realPM.rollback();
664: }
665:
666: public void setNontransactionalRead(boolean b) {
667: checkClosed();
668: realPM.setNontransactionalRead(b);
669: }
670:
671: public void setNontransactionalWrite(boolean b) {
672: checkClosed();
673: realPM.setNontransactionalWrite(b);
674: }
675:
676: public void setOptimistic(boolean b) {
677: checkClosed();
678: realPM.setOptimistic(b);
679: }
680:
681: public void setRestoreValues(boolean b) {
682: checkClosed();
683: realPM.setRestoreValues(b);
684: }
685:
686: public void setRetainValues(boolean b) {
687: checkClosed();
688: realPM.setRetainValues(b);
689: }
690:
691: public void setSynchronization(Synchronization synchronization) {
692: checkClosed();
693: realPM.setSynchronization(synchronization);
694: }
695:
696: public void setDatastoreTxLocking(int mode) {
697: checkClosed();
698: realPM.setDatastoreTxLocking(mode);
699: }
700:
701: public int getDatastoreTxLocking() {
702: checkClosed();
703: return realPM.getDatastoreTxLocking();
704: }
705:
706: public void setRetainConnectionInOptTx(boolean on) {
707: checkClosed();
708: realPM.setRetainConnectionInOptTx(on);
709: }
710:
711: public Object getObjectByIdFromCache(Object oid) {
712: checkClosed();
713: return realPM.getObjectByIdFromCache(oid);
714: }
715:
716: public boolean isHollow(Object pc) {
717: checkClosed();
718: return realPM.isHollow(pc);
719: }
720:
721: public boolean hasIdentity(Object pc) {
722: checkClosed();
723: return realPM.hasIdentity(pc);
724: }
725:
726: public Object newObjectIdInstance(Class pcClass, String str,
727: boolean resolved) {
728: checkClosed();
729: return realPM.newObjectIdInstance(pcClass, str, resolved);
730: }
731:
732: public Object getObjectByIDString(String value, boolean toValidate,
733: boolean resolved) {
734: checkClosed();
735: return realPM.getObjectByIDString(value, toValidate, resolved);
736: }
737:
738: public void logEvent(int level, String description, int ms) {
739: checkClosed();
740: realPM.logEvent(level, description, ms);
741: }
742:
743: public Query versantNewNamedQuery(Class cls, String queryName) {
744: checkClosed();
745: return realPM.versantNewNamedQuery(cls, queryName);
746: }
747:
748: public boolean isCheckModelConsistencyOnCommit() {
749: checkClosed();
750: return realPM.isCheckModelConsistencyOnCommit();
751: }
752:
753: public void setCheckModelConsistencyOnCommit(boolean on) {
754: checkClosed();
755: realPM.setCheckModelConsistencyOnCommit(on);
756: }
757:
758: public void checkModelConsistency() {
759: checkClosed();
760: realPM.checkModelConsistency();
761: }
762:
763: public int getObjectsById(Object[] oids, int length, Object[] data,
764: int stateFieldNo, int classMetaDataIndex) {
765: checkClosed();
766: return realPM.getObjectsById(oids, length, data, stateFieldNo,
767: classMetaDataIndex);
768: }
769:
770: public Collection versantDetachCopy(Collection pcs,
771: String fetchGroup) {
772: checkClosed();
773: return realPM.versantDetachCopy(pcs, fetchGroup);
774: }
775:
776: public Collection versantAttachCopy(Collection detached,
777: boolean makeTransactional) {
778: checkClosed();
779: return realPM.versantAttachCopy(detached, makeTransactional);
780: }
781:
782: public Collection versantAttachCopy(Collection detached,
783: boolean makeTransactional, boolean shallow) {
784: return realPM.versantAttachCopy(detached, makeTransactional,
785: shallow);
786: }
787:
788: public void evictFromL2CacheAfterCommit(Object o) {
789: checkClosed();
790: realPM.evictFromL2CacheAfterCommit(o);
791: }
792:
793: public void evictAllFromL2CacheAfterCommit(Object[] a) {
794: checkClosed();
795: realPM.evictAllFromL2CacheAfterCommit(a);
796: }
797:
798: public void evictAllFromL2CacheAfterCommit(Collection c) {
799: checkClosed();
800: realPM.evictAllFromL2CacheAfterCommit(c);
801: }
802:
803: public void evictAllFromL2CacheAfterCommit(Class cls,
804: boolean includeSubclasses) {
805: checkClosed();
806: realPM.evictAllFromL2CacheAfterCommit(cls, includeSubclasses);
807: }
808:
809: public void evictAllFromL2CacheAfterCommit() {
810: checkClosed();
811: realPM.evictAllFromL2CacheAfterCommit();
812: }
813:
814: public void addLifecycleListener(LifecycleListener listener,
815: Class[] classes) {
816: checkClosed();
817: realPM.addLifecycleListener(listener, classes);
818: }
819:
820: public void removeLifecycleListener(LifecycleListener listener) {
821: checkClosed();
822: realPM.removeLifecycleListener(listener);
823: }
824:
825: }
|