001 package org.apache.ojb.otm;
002
003 /* Copyright 2003-2005 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 import org.apache.ojb.broker.Identity;
019 import org.apache.ojb.broker.PBKey;
020 import org.apache.ojb.otm.copy.ObjectCopyStrategy;
021 import org.apache.ojb.otm.core.Transaction;
022 import org.apache.ojb.otm.lock.map.LockMap;
023 import org.apache.ojb.otm.lock.wait.LockWaitStrategy;
024 import org.apache.ojb.otm.swizzle.Swizzling;
025 import org.apache.ojb.otm.transaction.TransactionFactory;
026
027 /**
028 *
029 * OTMKit implementations provide the initial point of entry
030 * into the OTM layer.
031 *
032 * @author <a href="mailto:rraghuram@hotmail.com">Raghu Rajah</a>
033 *
034 */
035 public abstract class OTMKit implements Kit
036 {
037 /**
038 * Obtain an OTMConnection for the given persistence broker key
039 */
040 public OTMConnection acquireConnection(PBKey pbKey)
041 {
042 TransactionFactory txFactory = getTransactionFactory();
043 return txFactory.acquireConnection(pbKey);
044 }
045
046 /**
047 * Obtain the transaction which <code>conn</code> is currently
048 * bound to.
049 */
050 public Transaction getTransaction(OTMConnection conn)
051 {
052 TransactionFactory txFactory = getTransactionFactory();
053 Transaction tx = txFactory.getTransactionForConnection(conn);
054 tx.setKit(this);
055 return tx;
056 }
057
058 ////////////////////////////
059 // Abstract Methods
060 ////////////////////////////
061
062 protected abstract TransactionFactory getTransactionFactory();
063
064 public abstract Swizzling getSwizzlingStrategy();
065
066 public abstract LockWaitStrategy getLockWaitStrategy();
067
068 public abstract LockMap getLockMap();
069
070 public abstract ObjectCopyStrategy getCopyStrategy(Identity oid);
071
072 /**
073 * Should OTM implicitely read lock all objects that are reachable
074 * from the explicitely locked object? The updates to the read locked
075 * objects are automatically stored to the database at the end
076 * of transaction.
077 **/
078 public abstract boolean isImplicitLockingUsed();
079
080 /**
081 * Should OTM verify each inserted object for presence in the database?
082 **/
083 public abstract boolean isInsertVerified();
084
085 /**
086 * Should OTM perform INSERTs for the given object eagerly or during commit?
087 **/
088 public abstract boolean isEagerInsert(Object obj);
089
090 }