1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.openjpa.kernel;
20
21 import java.util.BitSet;
22 import java.util.Collection;
23 import java.util.Iterator;
24
25 import org.apache.openjpa.conf.OpenJPAConfiguration;
26 import org.apache.openjpa.ee.ManagedRuntime;
27 import org.apache.openjpa.event.LifecycleEventManager;
28 import org.apache.openjpa.meta.ClassMetaData;
29 import org.apache.openjpa.meta.FieldMetaData;
30 import org.apache.openjpa.meta.ValueMetaData;
31 import org.apache.openjpa.util.RuntimeExceptionTranslator;
32
33 ///////////////////////////////////////////////////////////////
34 // NOTE: when adding a public API method, be sure to add it to
35 // JDO and JPA facades!
36 ///////////////////////////////////////////////////////////////
37
38 /**
39 * Delegating broker that can also perform exception translation
40 * for use in facades.
41 *
42 * @since 0.4.0
43 * @author Abe White
44 * @nojavadoc
45 */
46 public class DelegatingBroker
47 implements Broker {
48
49 private final Broker _broker;
50 private final DelegatingBroker _del;
51 private final RuntimeExceptionTranslator _trans;
52
53 /**
54 * Constructor; supply delegate.
55 */
56 public DelegatingBroker(Broker broker) {
57 this(broker, null);
58 }
59
60 /**
61 * Constructor; supply delegate and exception translator.
62 */
63 public DelegatingBroker(Broker broker, RuntimeExceptionTranslator trans) {
64 _broker = broker;
65 if (broker instanceof DelegatingBroker)
66 _del = (DelegatingBroker) broker;
67 else
68 _del = null;
69 _trans = trans;
70 }
71
72 /**
73 * Return the direct delegate.
74 */
75 public Broker getDelegate() {
76 return _broker;
77 }
78
79 /**
80 * Return the native delegate.
81 */
82 public Broker getInnermostDelegate() {
83 return (_del == null) ? _broker : _del.getInnermostDelegate();
84 }
85
86 public int hashCode() {
87 return getInnermostDelegate().hashCode();
88 }
89
90 public boolean equals(Object other) {
91 if (other == this)
92 return true;
93 if (other instanceof DelegatingBroker)
94 other = ((DelegatingBroker) other).getInnermostDelegate();
95 return getInnermostDelegate().equals(other);
96 }
97
98 /**
99 * Translate the OpenJPA exception.
100 */
101 protected RuntimeException translate(RuntimeException re) {
102 return (_trans == null) ? re : _trans.translate(re);
103 }
104
105 public Broker getBroker() {
106 return this;
107 }
108
109 public OpenJPAConfiguration getConfiguration() {
110 try {
111 return _broker.getConfiguration();
112 } catch (RuntimeException re) {
113 throw translate(re);
114 }
115 }
116
117 public FetchConfiguration getFetchConfiguration() {
118 try {
119 return _broker.getFetchConfiguration();
120 } catch (RuntimeException re) {
121 throw translate(re);
122 }
123 }
124
125 public FetchConfiguration pushFetchConfiguration() {
126 try {
127 return _broker.pushFetchConfiguration();
128 } catch (RuntimeException re) {
129 throw translate(re);
130 }
131 }
132
133 public void popFetchConfiguration() {
134 try {
135 _broker.popFetchConfiguration();
136 } catch (RuntimeException re) {
137 throw translate(re);
138 }
139 }
140
141 public ClassLoader getClassLoader() {
142 try {
143 return _broker.getClassLoader();
144 } catch (RuntimeException re) {
145 throw translate(re);
146 }
147 }
148
149 public LockManager getLockManager() {
150 try {
151 return _broker.getLockManager();
152 } catch (RuntimeException re) {
153 throw translate(re);
154 }
155 }
156
157 public DelegatingStoreManager getStoreManager() {
158 try {
159 return _broker.getStoreManager();
160 } catch (RuntimeException re) {
161 throw translate(re);
162 }
163 }
164
165 public String getConnectionUserName() {
166 try {
167 return _broker.getConnectionUserName();
168 } catch (RuntimeException re) {
169 throw translate(re);
170 }
171 }
172
173 public String getConnectionPassword() {
174 try {
175 return _broker.getConnectionPassword();
176 } catch (RuntimeException re) {
177 throw translate(re);
178 }
179 }
180
181 public Object find(Object oid, boolean validate, FindCallbacks call) {
182 try {
183 return _broker.find(oid, validate, call);
184 } catch (RuntimeException re) {
185 throw translate(re);
186 }
187 }
188
189 public Object[] findAll(Collection oids, boolean validate,
190 FindCallbacks call) {
191 try {
192 return _broker.findAll(oids, validate, call);
193 } catch (RuntimeException re) {
194 throw translate(re);
195 }
196 }
197
198 public Object findCached(Object oid, FindCallbacks call) {
199 try {
200 return _broker.findCached(oid, call);
201 } catch (RuntimeException re) {
202 throw translate(re);
203 }
204 }
205
206 public Object find(Object oid, FetchConfiguration fetch, BitSet exclude,
207 Object edata, int flags) {
208 try {
209 return _broker.find(oid, fetch, exclude, edata, flags);
210 } catch (RuntimeException re) {
211 throw translate(re);
212 }
213 }
214
215 public Object[] findAll(Collection oids, FetchConfiguration fetch,
216 BitSet exclude, Object edata, int flags) {
217 try {
218 return _broker.findAll(oids, fetch, exclude, edata, flags);
219 } catch (RuntimeException re) {
220 throw translate(re);
221 }
222 }
223
224 public Iterator extentIterator(Class cls, boolean subs,
225 FetchConfiguration fetch, boolean ignoreChanges) {
226 try {
227 return _broker.extentIterator(cls, subs, fetch, ignoreChanges);
228 } catch (RuntimeException re) {
229 throw translate(re);
230 }
231 }
232
233 public void retrieve(Object obj, boolean fgOnly, OpCallbacks call) {
234 try {
235 _broker.retrieve(obj, fgOnly, call);
236 } catch (RuntimeException re) {
237 throw translate(re);
238 }
239 }
240
241 public void retrieveAll(Collection objs, boolean fgOnly, OpCallbacks call) {
242 try {
243 _broker.retrieveAll(objs, fgOnly, call);
244 } catch (RuntimeException re) {
245 throw translate(re);
246 }
247 }
248
249 public OpenJPAStateManager embed(Object obj, Object id,
250 OpenJPAStateManager owner, ValueMetaData ownerMeta) {
251 try {
252 return _broker.embed(obj, id, owner, ownerMeta);
253 } catch (RuntimeException re) {
254 throw translate(re);
255 }
256 }
257
258 public Class getObjectIdType(Class cls) {
259 try {
260 return _broker.getObjectIdType(cls);
261 } catch (RuntimeException re) {
262 throw translate(re);
263 }
264 }
265
266 public Object newObjectId(Class cls, Object val) {
267 try {
268 return _broker.newObjectId(cls, val);
269 } catch (RuntimeException re) {
270 throw translate(re);
271 }
272 }
273
274 public Collection getManagedObjects() {
275 try {
276 return _broker.getManagedObjects();
277 } catch (RuntimeException re) {
278 throw translate(re);
279 }
280 }
281
282 public Collection getTransactionalObjects() {
283 try {
284 return _broker.getTransactionalObjects();
285 } catch (RuntimeException re) {
286 throw translate(re);
287 }
288 }
289
290 public Collection getPendingTransactionalObjects() {
291 try {
292 return _broker.getPendingTransactionalObjects();
293 } catch (RuntimeException re) {
294 throw translate(re);
295 }
296 }
297
298 public Collection getDirtyObjects() {
299 try {
300 return _broker.getDirtyObjects();
301 } catch (RuntimeException re) {
302 throw translate(re);
303 }
304 }
305
306 public boolean getOrderDirtyObjects() {
307 try {
308 return _broker.getOrderDirtyObjects();
309 } catch (RuntimeException re) {
310 throw translate(re);
311 }
312 }
313
314 public void setOrderDirtyObjects(boolean order) {
315 try {
316 _broker.setOrderDirtyObjects(order);
317 } catch (RuntimeException re) {
318 throw translate(re);
319 }
320 }
321
322 public Collection getPersistedTypes() {
323 try {
324 return _broker.getPersistedTypes();
325 } catch (RuntimeException re) {
326 throw translate(re);
327 }
328 }
329
330 public Collection getUpdatedTypes() {
331 try {
332 return _broker.getUpdatedTypes();
333 } catch (RuntimeException re) {
334 throw translate(re);
335 }
336 }
337
338 public Collection getDeletedTypes() {
339 try {
340 return _broker.getDeletedTypes();
341 } catch (RuntimeException re) {
342 throw translate(re);
343 }
344 }
345
346 public OpenJPAStateManager getStateManager(Object obj) {
347 try {
348 return _broker.getStateManager(obj);
349 } catch (RuntimeException re) {
350 throw translate(re);
351 }
352 }
353
354 public int getLockLevel(Object obj) {
355 try {
356 return _broker.getLockLevel(obj);
357 } catch (RuntimeException re) {
358 throw translate(re);
359 }
360 }
361
362 public Object getVersion(Object obj) {
363 try {
364 return _broker.getVersion(obj);
365 } catch (RuntimeException re) {
366 throw translate(re);
367 }
368 }
369
370 public boolean isDirty(Object obj) {
371 try {
372 return _broker.isDirty(obj);
373 } catch (RuntimeException re) {
374 throw translate(re);
375 }
376 }
377
378 public boolean isTransactional(Object obj) {
379 try {
380 return _broker.isTransactional(obj);
381 } catch (RuntimeException re) {
382 throw translate(re);
383 }
384 }
385
386 public boolean isPersistent(Object obj) {
387 try {
388 return _broker.isPersistent(obj);
389 } catch (RuntimeException re) {
390 throw translate(re);
391 }
392 }
393
394 public boolean isNew(Object obj) {
395 try {
396 return _broker.isNew(obj);
397 } catch (RuntimeException re) {
398 throw translate(re);
399 }
400 }
401
402 public boolean isDeleted(Object obj) {
403 try {
404 return _broker.isDeleted(obj);
405 } catch (RuntimeException re) {
406 throw translate(re);
407 }
408 }
409
410 public Object getObjectId(Object obj) {
411 try {
412 return _broker.getObjectId(obj);
413 } catch (RuntimeException re) {
414 throw translate(re);
415 }
416 }
417
418 public boolean isManaged() {
419 try {
420 return _broker.isManaged();
421 } catch (RuntimeException re) {
422 throw translate(re);
423 }
424 }
425
426 public boolean isActive() {
427 try {
428 return _broker.isActive();
429 } catch (RuntimeException re) {
430 throw translate(re);
431 }
432 }
433
434 public boolean isStoreActive() {
435 try {
436 return _broker.isStoreActive();
437 } catch (RuntimeException re) {
438 throw translate(re);
439 }
440 }
441
442 public boolean hasConnection() {
443 try {
444 return _broker.hasConnection();
445 } catch (RuntimeException re) {
446 throw translate(re);
447 }
448 }
449
450 public Object getConnection() {
451 try {
452 return _broker.getConnection();
453 } catch (RuntimeException re) {
454 throw translate(re);
455 }
456 }
457
458 public void lock() {
459 try {
460 _broker.lock();
461 } catch (RuntimeException re) {
462 throw translate(re);
463 }
464 }
465
466 public void unlock() {
467 try {
468 _broker.unlock();
469 } catch (RuntimeException re) {
470 throw translate(re);
471 }
472 }
473
474 public boolean beginOperation(boolean read) {
475 try {
476 return _broker.beginOperation(read);
477 } catch (RuntimeException re) {
478 throw translate(re);
479 }
480 }
481
482 public boolean endOperation() {
483 try {
484 return _broker.endOperation();
485 } catch (RuntimeException re) {
486 throw translate(re);
487 }
488 }
489
490 public void setImplicitBehavior(OpCallbacks call,
491 RuntimeExceptionTranslator ex) {
492 try {
493 _broker.setImplicitBehavior(call, ex);
494 } catch (RuntimeException re) {
495 throw translate(re);
496 }
497 }
498
499 public BrokerFactory getBrokerFactory() {
500 try {
501 return _broker.getBrokerFactory();
502 } catch (RuntimeException re) {
503 throw translate(re);
504 }
505 }
506
507 public int getConnectionRetainMode() {
508 try {
509 return _broker.getConnectionRetainMode();
510 } catch (RuntimeException re) {
511 throw translate(re);
512 }
513 }
514
515 public ManagedRuntime getManagedRuntime() {
516 try {
517 return _broker.getManagedRuntime();
518 } catch (RuntimeException re) {
519 throw translate(re);
520 }
521 }
522
523 public InverseManager getInverseManager() {
524 try {
525 return _broker.getInverseManager();
526 } catch (RuntimeException re) {
527 throw translate(re);
528 }
529 }
530
531 public boolean getMultithreaded() {
532 try {
533 return _broker.getMultithreaded();
534 } catch (RuntimeException re) {
535 throw translate(re);
536 }
537 }
538
539 public void setMultithreaded(boolean multi) {
540 try {
541 _broker.setMultithreaded(multi);
542 } catch (RuntimeException re) {
543 throw translate(re);
544 }
545 }
546
547 public boolean getIgnoreChanges() {
548 try {
549 return _broker.getIgnoreChanges();
550 } catch (RuntimeException re) {
551 throw translate(re);
552 }
553 }
554
555 public void setIgnoreChanges(boolean ignore) {
556 try {
557 _broker.setIgnoreChanges(ignore);
558 } catch (RuntimeException re) {
559 throw translate(re);
560 }
561 }
562
563 public boolean getNontransactionalRead() {
564 try {
565 return _broker.getNontransactionalRead();
566 } catch (RuntimeException re) {
567 throw translate(re);
568 }
569 }
570
571 public void setNontransactionalRead(boolean read) {
572 try {
573 _broker.setNontransactionalRead(read);
574 } catch (RuntimeException re) {
575 throw translate(re);
576 }
577 }
578
579 public boolean getNontransactionalWrite() {
580 try {
581 return _broker.getNontransactionalWrite();
582 } catch (RuntimeException re) {
583 throw translate(re);
584 }
585 }
586
587 public void setNontransactionalWrite(boolean write) {
588 try {
589 _broker.setNontransactionalWrite(write);
590 } catch (RuntimeException re) {
591 throw translate(re);
592 }
593 }
594
595 public int getRestoreState() {
596 try {
597 return _broker.getRestoreState();
598 } catch (RuntimeException re) {
599 throw translate(re);
600 }
601 }
602
603 public void setRestoreState(int restore) {
604 try {
605 _broker.setRestoreState(restore);
606 } catch (RuntimeException re) {
607 throw translate(re);
608 }
609 }
610
611 public boolean getOptimistic() {
612 try {
613 return _broker.getOptimistic();
614 } catch (RuntimeException re) {
615 throw translate(re);
616 }
617 }
618
619 public void setOptimistic(boolean opt) {
620 try {
621 _broker.setOptimistic(opt);
622 } catch (RuntimeException re) {
623 throw translate(re);
624 }
625 }
626
627 public boolean getRetainState() {
628 try {
629 return _broker.getRetainState();
630 } catch (RuntimeException re) {
631 throw translate(re);
632 }
633 }
634
635 public void setRetainState(boolean retain) {
636 try {
637 _broker.setRetainState(retain);
638 } catch (RuntimeException re) {
639 throw translate(re);
640 }
641 }
642
643 public int getAutoClear() {
644 try {
645 return _broker.getAutoClear();
646 } catch (RuntimeException re) {
647 throw translate(re);
648 }
649 }
650
651 public void setAutoClear(int clear) {
652 try {
653 _broker.setAutoClear(clear);
654 } catch (RuntimeException re) {
655 throw translate(re);
656 }
657 }
658
659 public int getAutoDetach() {
660 try {
661 return _broker.getAutoDetach();
662 } catch (RuntimeException re) {
663 throw translate(re);
664 }
665 }
666
667 public void setAutoDetach(int flags) {
668 try {
669 _broker.setAutoDetach(flags);
670 } catch (RuntimeException re) {
671 throw translate(re);
672 }
673 }
674
675 public void setAutoDetach(int flag, boolean on) {
676 try {
677 _broker.setAutoDetach(flag, on);
678 } catch (RuntimeException re) {
679 throw translate(re);
680 }
681 }
682
683 public int getDetachState() {
684 try {
685 return _broker.getDetachState();
686 } catch (RuntimeException re) {
687 throw translate(re);
688 }
689 }
690
691 public void setDetachState(int mode) {
692 try {
693 _broker.setDetachState(mode);
694 } catch (RuntimeException re) {
695 throw translate(re);
696 }
697 }
698
699 public boolean isDetachedNew() {
700 try {
701 return _broker.isDetachedNew();
702 } catch (RuntimeException re) {
703 throw translate(re);
704 }
705 }
706
707 public void setDetachedNew(boolean isNew) {
708 try {
709 _broker.setDetachedNew(isNew);
710 } catch (RuntimeException re) {
711 throw translate(re);
712 }
713 }
714
715 public boolean getSyncWithManagedTransactions() {
716 try {
717 return _broker.getSyncWithManagedTransactions();
718 } catch (RuntimeException re) {
719 throw translate(re);
720 }
721 }
722
723 public void setSyncWithManagedTransactions(boolean sync) {
724 try {
725 _broker.setSyncWithManagedTransactions(sync);
726 } catch (RuntimeException re) {
727 throw translate(re);
728 }
729 }
730
731 public boolean getEvictFromDataCache() {
732 try {
733 return _broker.getEvictFromDataCache();
734 } catch (RuntimeException re) {
735 throw translate(re);
736 }
737 }
738
739 public void setEvictFromDataCache(boolean evict) {
740 try {
741 _broker.setEvictFromDataCache(evict);
742 } catch (RuntimeException re) {
743 throw translate(re);
744 }
745 }
746
747 public boolean getPopulateDataCache() {
748 try {
749 return _broker.getPopulateDataCache();
750 } catch (RuntimeException re) {
751 throw translate(re);
752 }
753 }
754
755 public void setPopulateDataCache(boolean cache) {
756 try {
757 _broker.setPopulateDataCache(cache);
758 } catch (RuntimeException re) {
759 throw translate(re);
760 }
761 }
762
763 public boolean isTrackChangesByType() {
764 try {
765 return _broker.isTrackChangesByType();
766 } catch (RuntimeException re) {
767 throw translate(re);
768 }
769 }
770
771 public void setTrackChangesByType(boolean largeTransaction) {
772 try {
773 _broker.setTrackChangesByType(largeTransaction);
774 } catch (RuntimeException re) {
775 throw translate(re);
776 }
777 }
778
779 public Object putUserObject(Object key, Object val) {
780 try {
781 return _broker.putUserObject(key, val);
782 } catch (RuntimeException re) {
783 throw translate(re);
784 }
785 }
786
787 public Object getUserObject(Object key) {
788 try {
789 return _broker.getUserObject(key);
790 } catch (RuntimeException re) {
791 throw translate(re);
792 }
793 }
794
795 public void addTransactionListener(Object listener) {
796 try {
797 _broker.addTransactionListener(listener);
798 } catch (RuntimeException re) {
799 throw translate(re);
800 }
801 }
802
803 public void removeTransactionListener(Object listener) {
804 try {
805 _broker.removeTransactionListener(listener);
806 } catch (RuntimeException re) {
807 throw translate(re);
808 }
809 }
810
811 public int getTransactionListenerCallbackMode() {
812 try {
813 return _broker.getTransactionListenerCallbackMode();
814 } catch (RuntimeException re) {
815 throw translate(re);
816 }
817 }
818
819 public void setTransactionListenerCallbackMode(int mode) {
820 try {
821 _broker.setTransactionListenerCallbackMode(mode);
822 } catch (RuntimeException re) {
823 throw translate(re);
824 }
825 }
826
827 public void addLifecycleListener(Object listener, Class[] classes) {
828 try {
829 _broker.addLifecycleListener(listener, classes);
830 } catch (RuntimeException re) {
831 throw translate(re);
832 }
833 }
834
835 public void removeLifecycleListener(Object listener) {
836 try {
837 _broker.removeLifecycleListener(listener);
838 } catch (RuntimeException re) {
839 throw translate(re);
840 }
841 }
842
843 public int getLifecycleListenerCallbackMode() {
844 try {
845 return _broker.getLifecycleListenerCallbackMode();
846 } catch (RuntimeException re) {
847 throw translate(re);
848 }
849 }
850
851 public void setLifecycleListenerCallbackMode(int mode) {
852 try {
853 _broker.setLifecycleListenerCallbackMode(mode);
854 } catch (RuntimeException re) {
855 throw translate(re);
856 }
857 }
858
859 public LifecycleEventManager getLifecycleEventManager() {
860 try {
861 return _broker.getLifecycleEventManager();
862 } catch (RuntimeException re) {
863 throw translate(re);
864 }
865 }
866
867 public void begin() {
868 try {
869 _broker.begin();
870 } catch (RuntimeException re) {
871 throw translate(re);
872 }
873 }
874
875 public void commit() {
876 try {
877 _broker.commit();
878 } catch (RuntimeException re) {
879 throw translate(re);
880 }
881 }
882
883 public void rollback() {
884 try {
885 _broker.rollback();
886 } catch (RuntimeException re) {
887 throw translate(re);
888 }
889 }
890
891 public boolean syncWithManagedTransaction() {
892 try {
893 return _broker.syncWithManagedTransaction();
894 } catch (RuntimeException re) {
895 throw translate(re);
896 }
897 }
898
899 public void commitAndResume() {
900 try {
901 _broker.commitAndResume();
902 } catch (RuntimeException re) {
903 throw translate(re);
904 }
905 }
906
907 public void rollbackAndResume() {
908 try {
909 _broker.rollbackAndResume();
910 } catch (RuntimeException re) {
911 throw translate(re);
912 }
913 }
914
915 public void setRollbackOnly() {
916 try {
917 _broker.setRollbackOnly();
918 } catch (RuntimeException re) {
919 throw translate(re);
920 }
921 }
922
923 public void setRollbackOnly(Throwable cause) {
924 try {
925 _broker.setRollbackOnly(cause);
926 } catch (RuntimeException re) {
927 throw translate(re);
928 }
929 }
930
931 public Throwable getRollbackCause() {
932 try {
933 return _broker.getRollbackCause();
934 } catch (RuntimeException re) {
935 throw translate(re);
936 }
937 }
938
939 public boolean getRollbackOnly() {
940 try {
941 return _broker.getRollbackOnly();
942 } catch (RuntimeException re) {
943 throw translate(re);
944 }
945 }
946
947 public void setSavepoint(String name) {
948 try {
949 _broker.setSavepoint(name);
950 } catch (RuntimeException re) {
951 throw translate(re);
952 }
953 }
954
955 public void rollbackToSavepoint() {
956 try {
957 _broker.rollbackToSavepoint();
958 } catch (RuntimeException re) {
959 throw translate(re);
960 }
961 }
962
963 public void rollbackToSavepoint(String name) {
964 try {
965 _broker.rollbackToSavepoint(name);
966 } catch (RuntimeException re) {
967 throw translate(re);
968 }
969 }
970
971 public void releaseSavepoint() {
972 try {
973 _broker.releaseSavepoint();
974 } catch (RuntimeException re) {
975 throw translate(re);
976 }
977 }
978
979 public void releaseSavepoint(String name) {
980 try {
981 _broker.releaseSavepoint(name);
982 } catch (RuntimeException re) {
983 throw translate(re);
984 }
985 }
986
987 public void flush() {
988 try {
989 _broker.flush();
990 } catch (RuntimeException re) {
991 throw translate(re);
992 }
993 }
994
995 public void preFlush() {
996 try {
997 _broker.preFlush();
998 } catch (RuntimeException re) {
999 throw translate(re);
1000 }
1001 }
1002
1003 public void validateChanges() {
1004 try {
1005 _broker.validateChanges();
1006 } catch (RuntimeException re) {
1007 throw translate(re);
1008 }
1009 }
1010
1011 public void beginStore() {
1012 try {
1013 _broker.beginStore();
1014 } catch (RuntimeException re) {
1015 throw translate(re);
1016 }
1017 }
1018
1019 public void persist(Object obj, OpCallbacks call) {
1020 try {
1021 _broker.persist(obj, call);
1022 } catch (RuntimeException re) {
1023 throw translate(re);
1024 }
1025 }
1026
1027 public void persistAll(Collection objs, OpCallbacks call) {
1028 try {
1029 _broker.persistAll(objs, call);
1030 } catch (RuntimeException re) {
1031 throw translate(re);
1032 }
1033 }
1034
1035 public OpenJPAStateManager persist(Object obj, Object id,
1036 OpCallbacks call) {
1037 try {
1038 return _broker.persist(obj, id, call);
1039 } catch (RuntimeException re) {
1040 throw translate(re);
1041 }
1042 }
1043
1044 public void delete(Object obj, OpCallbacks call) {
1045 try {
1046 _broker.delete(obj, call);
1047 } catch (RuntimeException re) {
1048 throw translate(re);
1049 }
1050 }
1051
1052 public void deleteAll(Collection objs, OpCallbacks call) {
1053 try {
1054 _broker.deleteAll(objs, call);
1055 } catch (RuntimeException re) {
1056 throw translate(re);
1057 }
1058 }
1059
1060 public void release(Object obj, OpCallbacks call) {
1061 try {
1062 _broker.release(obj, call);
1063 } catch (RuntimeException re) {
1064 throw translate(re);
1065 }
1066 }
1067
1068 public void releaseAll(Collection objs, OpCallbacks call) {
1069 try {
1070 _broker.releaseAll(objs, call);
1071 } catch (RuntimeException re) {
1072 throw translate(re);
1073 }
1074 }
1075
1076 public void refresh(Object obj, OpCallbacks call) {
1077 try {
1078 _broker.refresh(obj, call);
1079 } catch (RuntimeException re) {
1080 throw translate(re);
1081 }
1082 }
1083
1084 public void refreshAll(Collection objs, OpCallbacks call) {
1085 try {
1086 _broker.refreshAll(objs, call);
1087 } catch (RuntimeException re) {
1088 throw translate(re);
1089 }
1090 }
1091
1092 public void evict(Object obj, OpCallbacks call) {
1093 try {
1094 _broker.evict(obj, call);
1095 } catch (RuntimeException re) {
1096 throw translate(re);
1097 }
1098 }
1099
1100 public void evictAll(Collection objs, OpCallbacks call) {
1101 try {
1102 _broker.evictAll(objs, call);
1103 } catch (RuntimeException re) {
1104 throw translate(re);
1105 }
1106 }
1107
1108 public void evictAll(OpCallbacks call) {
1109 try {
1110 _broker.evictAll(call);
1111 } catch (RuntimeException re) {
1112 throw translate(re);
1113 }
1114 }
1115
1116 public void evictAll(Extent extent, OpCallbacks call) {
1117 try {
1118 _broker.evictAll(extent, call);
1119 } catch (RuntimeException re) {
1120 throw translate(re);
1121 }
1122 }
1123
1124 public Object detach(Object obj, OpCallbacks call) {
1125 try {
1126 return _broker.detach(obj, call);
1127 } catch (RuntimeException re) {
1128 throw translate(re);
1129 }
1130 }
1131
1132 public Object[] detachAll(Collection objs, OpCallbacks call) {
1133 try {
1134 return _broker.detachAll(objs, call);
1135 } catch (RuntimeException re) {
1136 throw translate(re);
1137 }
1138 }
1139
1140 public void detachAll(OpCallbacks call) {
1141 try {
1142 _broker.detachAll(call);
1143 } catch (RuntimeException re) {
1144 throw translate(re);
1145 }
1146 }
1147
1148 public void detachAll(OpCallbacks call, boolean flush) {
1149 try {
1150 _broker.detachAll(call, flush);
1151 } catch (RuntimeException re) {
1152 throw translate(re);
1153 }
1154 }
1155
1156 public Object attach(Object obj, boolean copyNew, OpCallbacks call) {
1157 try {
1158 return _broker.attach(obj, copyNew, call);
1159 } catch (RuntimeException re) {
1160 throw translate(re);
1161 }
1162 }
1163
1164 public Object[] attachAll(Collection objs, boolean copyNew,
1165 OpCallbacks call) {
1166 try {
1167 return _broker.attachAll(objs, copyNew, call);
1168 } catch (RuntimeException re) {
1169 throw translate(re);
1170 }
1171 }
1172
1173 public void transactional(Object pc, boolean updateVersion, OpCallbacks
1174 call) {
1175 try {
1176 _broker.transactional(pc, updateVersion, call);
1177 } catch (RuntimeException re) {
1178 throw translate(re);
1179 }
1180 }
1181
1182 public void transactionalAll(Collection objs, boolean updateVersion,
1183 OpCallbacks call) {
1184 try {
1185 _broker.transactionalAll(objs, updateVersion, call);
1186 } catch (RuntimeException re) {
1187 throw translate(re);
1188 }
1189 }
1190
1191 public void nontransactional(Object pc, OpCallbacks call) {
1192 try {
1193 _broker.nontransactional(pc, call);
1194 } catch (RuntimeException re) {
1195 throw translate(re);
1196 }
1197 }
1198
1199 public void nontransactionalAll(Collection objs, OpCallbacks call) {
1200 try {
1201 _broker.nontransactionalAll(objs, call);
1202 } catch (RuntimeException re) {
1203 throw translate(re);
1204 }
1205 }
1206
1207 public Extent newExtent(Class cls, boolean subs) {
1208 try {
1209 return _broker.newExtent(cls, subs);
1210 } catch (RuntimeException re) {
1211 throw translate(re);
1212 }
1213 }
1214
1215 public Query newQuery(String language, Class cls, Object query) {
1216 try {
1217 return _broker.newQuery(language, cls, query);
1218 } catch (RuntimeException re) {
1219 throw translate(re);
1220 }
1221 }
1222
1223 public Query newQuery(String language, Object query) {
1224 try {
1225 return _broker.newQuery(language, query);
1226 } catch (RuntimeException re) {
1227 throw translate(re);
1228 }
1229 }
1230
1231 public Seq getIdentitySequence(ClassMetaData meta) {
1232 try {
1233 return _broker.getIdentitySequence(meta);
1234 } catch (RuntimeException re) {
1235 throw translate(re);
1236 }
1237 }
1238
1239 public Seq getValueSequence(FieldMetaData fmd) {
1240 try {
1241 return _broker.getValueSequence(fmd);
1242 } catch (RuntimeException re) {
1243 throw translate(re);
1244 }
1245 }
1246
1247 public void lock(Object obj, int level, int timeout, OpCallbacks call) {
1248 try {
1249 _broker.lock(obj, level, timeout, call);
1250 } catch (RuntimeException re) {
1251 throw translate(re);
1252 }
1253 }
1254
1255 public void lock(Object obj, OpCallbacks call) {
1256 try {
1257 _broker.lock(obj, call);
1258 } catch (RuntimeException re) {
1259 throw translate(re);
1260 }
1261 }
1262
1263 public void lockAll(Collection objs, int level, int timeout,
1264 OpCallbacks call) {
1265 try {
1266 _broker.lockAll(objs, level, timeout, call);
1267 } catch (RuntimeException re) {
1268 throw translate(re);
1269 }
1270 }
1271
1272 public void lockAll(Collection objs, OpCallbacks call) {
1273 try {
1274 _broker.lockAll(objs, call);
1275 } catch (RuntimeException re) {
1276 throw translate(re);
1277 }
1278 }
1279
1280 public boolean cancelAll() {
1281 try {
1282 return _broker.cancelAll();
1283 } catch (RuntimeException re) {
1284 throw translate(re);
1285 }
1286 }
1287
1288 public void dirtyType(Class cls) {
1289 try {
1290 _broker.dirtyType(cls);
1291 } catch (RuntimeException re) {
1292 throw translate(re);
1293 }
1294 }
1295
1296 public void close() {
1297 try {
1298 _broker.close();
1299 } catch (RuntimeException re) {
1300 throw translate(re);
1301 }
1302 }
1303
1304 public boolean isClosed() {
1305 try {
1306 return _broker.isClosed();
1307 } catch (RuntimeException re) {
1308 throw translate(re);
1309 }
1310 }
1311
1312 public boolean isCloseInvoked() {
1313 try {
1314 return _broker.isCloseInvoked();
1315 } catch (RuntimeException re) {
1316 throw translate(re);
1317 }
1318 }
1319
1320 public void assertOpen() {
1321 try {
1322 _broker.assertOpen();
1323 } catch (RuntimeException re) {
1324 throw translate(re);
1325 }
1326 }
1327
1328 public void assertActiveTransaction() {
1329 try {
1330 _broker.assertActiveTransaction();
1331 } catch (RuntimeException re) {
1332 throw translate(re);
1333 }
1334 }
1335
1336 public void assertNontransactionalRead() {
1337 try {
1338 _broker.assertNontransactionalRead();
1339 } catch (RuntimeException re) {
1340 throw translate(re);
1341 }
1342 }
1343
1344 public void assertWriteOperation() {
1345 try {
1346 _broker.assertWriteOperation();
1347 } catch (RuntimeException re) {
1348 throw translate(re);
1349 }
1350 }
1351
1352 ///////////////////////////////////////////////
1353 // Implementation of Synchronization interface
1354 ///////////////////////////////////////////////
1355
1356 public void beforeCompletion() {
1357 try {
1358 _broker.beforeCompletion();
1359 } catch (RuntimeException re) {
1360 throw translate(re);
1361 }
1362 }
1363
1364 public void afterCompletion(int status) {
1365 try {
1366 _broker.afterCompletion(status);
1367 } catch (RuntimeException re) {
1368 throw translate(re);
1369 }
1370 }
1371
1372 public Object newInstance(Class cls) {
1373 try {
1374 return _broker.newInstance(cls);
1375 } catch (RuntimeException re) {
1376 throw translate(re);
1377 }
1378 }
1379
1380 public boolean isDetached(Object obj) {
1381 try {
1382 return _broker.isDetached(obj);
1383 } catch (RuntimeException re) {
1384 throw translate(re);
1385 }
1386 }
1387 }