001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.openjpa.kernel;
020:
021: import java.util.BitSet;
022: import java.util.Collection;
023:
024: import org.apache.openjpa.lib.rop.ResultObjectProvider;
025: import org.apache.openjpa.meta.ClassMetaData;
026: import org.apache.openjpa.meta.FieldMetaData;
027:
028: /**
029: * Base class for store manager decorators that delegate to another
030: * store manager for some operations.
031: *
032: * @author Abe White
033: */
034: public abstract class DelegatingStoreManager implements StoreManager {
035:
036: private final StoreManager _store;
037: private final DelegatingStoreManager _del;
038:
039: /**
040: * Constructor. Supply delegate.
041: */
042: public DelegatingStoreManager(StoreManager store) {
043: _store = store;
044: if (store instanceof DelegatingStoreManager)
045: _del = (DelegatingStoreManager) _store;
046: else
047: _del = null;
048: }
049:
050: /**
051: * Return the wrapped store manager.
052: */
053: public StoreManager getDelegate() {
054: return _store;
055: }
056:
057: /**
058: * Return the base underlying native store manager.
059: */
060: public StoreManager getInnermostDelegate() {
061: return (_del == null) ? _store : _del.getInnermostDelegate();
062: }
063:
064: public int hashCode() {
065: return getInnermostDelegate().hashCode();
066: }
067:
068: public boolean equals(Object other) {
069: if (other == this )
070: return true;
071: if (other instanceof DelegatingStoreManager)
072: other = ((DelegatingStoreManager) other)
073: .getInnermostDelegate();
074: return getInnermostDelegate().equals(other);
075: }
076:
077: public void setContext(StoreContext ctx) {
078: _store.setContext(ctx);
079: }
080:
081: public void beginOptimistic() {
082: _store.beginOptimistic();
083: }
084:
085: public void rollbackOptimistic() {
086: _store.rollbackOptimistic();
087: }
088:
089: public void begin() {
090: _store.begin();
091: }
092:
093: public void commit() {
094: _store.commit();
095: }
096:
097: public void rollback() {
098: _store.rollback();
099: }
100:
101: public boolean exists(OpenJPAStateManager sm, Object context) {
102: return _store.exists(sm, context);
103: }
104:
105: public boolean syncVersion(OpenJPAStateManager sm, Object context) {
106: return _store.syncVersion(sm, context);
107: }
108:
109: public boolean initialize(OpenJPAStateManager sm, PCState state,
110: FetchConfiguration fetch, Object context) {
111: return _store.initialize(sm, state, fetch, context);
112: }
113:
114: public boolean load(OpenJPAStateManager sm, BitSet fields,
115: FetchConfiguration fetch, int lockLevel, Object context) {
116: return _store.load(sm, fields, fetch, lockLevel, context);
117: }
118:
119: public Collection loadAll(Collection sms, PCState state, int load,
120: FetchConfiguration fetch, Object context) {
121: return _store.loadAll(sms, state, load, fetch, context);
122: }
123:
124: public void beforeStateChange(OpenJPAStateManager sm,
125: PCState fromState, PCState toState) {
126: _store.beforeStateChange(sm, fromState, toState);
127: }
128:
129: public Collection flush(Collection sms) {
130: return _store.flush(sms);
131: }
132:
133: public boolean assignObjectId(OpenJPAStateManager sm,
134: boolean preFlush) {
135: return _store.assignObjectId(sm, preFlush);
136: }
137:
138: public boolean assignField(OpenJPAStateManager sm, int field,
139: boolean preFlush) {
140: return _store.assignField(sm, field, preFlush);
141: }
142:
143: public Class getManagedType(Object oid) {
144: return _store.getManagedType(oid);
145: }
146:
147: public Class getDataStoreIdType(ClassMetaData meta) {
148: return _store.getDataStoreIdType(meta);
149: }
150:
151: public Object copyDataStoreId(Object oid, ClassMetaData meta) {
152: return _store.copyDataStoreId(oid, meta);
153: }
154:
155: public Object newDataStoreId(Object oidVal, ClassMetaData meta) {
156: return _store.newDataStoreId(oidVal, meta);
157: }
158:
159: public Object getClientConnection() {
160: return _store.getClientConnection();
161: }
162:
163: public void retainConnection() {
164: _store.retainConnection();
165: }
166:
167: public void releaseConnection() {
168: _store.releaseConnection();
169: }
170:
171: public ResultObjectProvider executeExtent(ClassMetaData meta,
172: boolean subclasses, FetchConfiguration fetch) {
173: return _store.executeExtent(meta, subclasses, fetch);
174: }
175:
176: public StoreQuery newQuery(String language) {
177: return _store.newQuery(language);
178: }
179:
180: public FetchConfiguration newFetchConfiguration() {
181: return _store.newFetchConfiguration();
182: }
183:
184: public void close() {
185: _store.close();
186: }
187:
188: public int compareVersion(OpenJPAStateManager state, Object v1,
189: Object v2) {
190: return _store.compareVersion(state, v1, v2);
191: }
192:
193: public Seq getDataStoreIdSequence(ClassMetaData forClass) {
194: return _store.getDataStoreIdSequence(forClass);
195: }
196:
197: public Seq getValueSequence(FieldMetaData fmd) {
198: return _store.getValueSequence(fmd);
199: }
200:
201: public boolean cancelAll() {
202: return _store.cancelAll();
203: }
204: }
|