Home » apache-openjpa-1.1.0-source » org.apache.openjpa » kernel » [javadoc | source]
    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   
   24   import org.apache.openjpa.lib.rop.ResultObjectProvider;
   25   import org.apache.openjpa.meta.ClassMetaData;
   26   import org.apache.openjpa.meta.FieldMetaData;
   27   
   28   /**
   29    * Base class for store manager decorators that delegate to another
   30    * store manager for some operations.
   31    *
   32    * @author Abe White
   33    */
   34   public abstract class DelegatingStoreManager
   35       implements StoreManager {
   36   
   37       private final StoreManager _store;
   38       private final DelegatingStoreManager _del;
   39   
   40       /**
   41        * Constructor. Supply delegate.
   42        */
   43       public DelegatingStoreManager(StoreManager store) {
   44           _store = store;
   45           if (store instanceof DelegatingStoreManager)
   46               _del = (DelegatingStoreManager) _store;
   47           else
   48               _del = null;
   49       }
   50   
   51       /**
   52        * Return the wrapped store manager.
   53        */
   54       public StoreManager getDelegate() {
   55           return _store;
   56       }
   57   
   58       /**
   59        * Return the base underlying native store manager.
   60        */
   61       public StoreManager getInnermostDelegate() {
   62           return (_del == null) ? _store : _del.getInnermostDelegate();
   63       }
   64   
   65       public int hashCode() {
   66           return getInnermostDelegate().hashCode();
   67       }
   68   
   69       public boolean equals(Object other) {
   70           if (other == this)
   71               return true;
   72           if (other instanceof DelegatingStoreManager)
   73               other = ((DelegatingStoreManager) other).getInnermostDelegate();
   74           return getInnermostDelegate().equals(other);
   75       }
   76   
   77       public void setContext(StoreContext ctx) {
   78           _store.setContext(ctx);
   79       }
   80   
   81       public void beginOptimistic() {
   82           _store.beginOptimistic();
   83       }
   84   
   85       public void rollbackOptimistic() {
   86           _store.rollbackOptimistic();
   87       }
   88   
   89       public void begin() {
   90           _store.begin();
   91       }
   92   
   93       public void commit() {
   94           _store.commit();
   95       }
   96   
   97       public void rollback() {
   98           _store.rollback();
   99       }
  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, PCState fromState,
  125           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, boolean preFlush) {
  134           return _store.assignObjectId(sm, preFlush);
  135       }
  136   
  137       public boolean assignField(OpenJPAStateManager sm, int field,
  138           boolean preFlush) {
  139           return _store.assignField(sm, field, preFlush);
  140       }
  141   
  142       public Class getManagedType(Object oid) {
  143           return _store.getManagedType(oid);
  144       }
  145   
  146       public Class getDataStoreIdType(ClassMetaData meta) {
  147           return _store.getDataStoreIdType(meta);
  148       }
  149   
  150       public Object copyDataStoreId(Object oid, ClassMetaData meta) {
  151           return _store.copyDataStoreId(oid, meta);
  152       }
  153   
  154       public Object newDataStoreId(Object oidVal, ClassMetaData meta) {
  155           return _store.newDataStoreId(oidVal, meta);
  156       }
  157   
  158       public Object getClientConnection() {
  159           return _store.getClientConnection();
  160       }
  161   
  162       public void retainConnection() {
  163           _store.retainConnection();
  164       }
  165   
  166       public void releaseConnection() {
  167           _store.releaseConnection();
  168       }
  169   
  170       public ResultObjectProvider executeExtent(ClassMetaData meta,
  171           boolean subclasses, FetchConfiguration fetch) {
  172           return _store.executeExtent(meta, subclasses, fetch);
  173       }
  174   
  175       public StoreQuery newQuery(String language) {
  176           return _store.newQuery(language);
  177       }
  178   
  179       public FetchConfiguration newFetchConfiguration() {
  180           return _store.newFetchConfiguration();
  181       }
  182   
  183       public void close() {
  184           _store.close();
  185       }
  186   
  187       public int compareVersion(OpenJPAStateManager state, Object v1, Object v2) {
  188           return _store.compareVersion(state, v1, v2);
  189       }
  190   
  191       public Seq getDataStoreIdSequence(ClassMetaData forClass) {
  192           return _store.getDataStoreIdSequence(forClass);
  193       }
  194   
  195       public Seq getValueSequence(FieldMetaData fmd) {
  196           return _store.getValueSequence(fmd);
  197       }
  198   
  199       public boolean cancelAll() {
  200           return _store.cancelAll();
  201   	}
  202   }

Save This Page
Home » apache-openjpa-1.1.0-source » org.apache.openjpa » kernel » [javadoc | source]