001    package org.apache.ojb.broker.locking;
002    
003    /* Copyright 2002-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    /**
019     * This interface defines the lock isolation level constants used by
020     * OJB locking api. It contains numeric constants and literal constants
021     * representing all known isolation levels.
022     * <p/>
023     * NOTE: The lock isolation levels are labeled like the database transaction level but
024     * the definition of the levels is different - take care of that.
025     *
026     * @version $Id: IsolationLevels.java,v 1.1 2007-08-24 22:17:41 ewestfal Exp $
027     */
028    public interface IsolationLevels
029    {
030        /**
031         * Numeric constant representing an no-op isolation level.
032         * <p/>
033         * The lock manager completely ignores locking.
034         * <p/>
035         * Allows:<br/>
036         * all possible concurrent side-effects<br/>
037         */
038        public final static int IL_NONE = -1;
039    
040        /**
041         * Numeric constant representing the uncommited read isolation level.
042         *  <p/>
043         * Obtaining two concurrent write locks on a given object is not
044         * allowed. Obtaining read locks is allowed even if
045         * another transaction is writing to that object
046         * (Thats why this level is also called "dirty reads").
047         * <p/>
048         * Allows:<br/>
049         * Dirty Reads<br/>
050         * Non-Repeatable Reads<br/>
051         * Phantom Reads<br/>
052         */
053        public final static int IL_READ_UNCOMMITTED = 2;
054    
055        /**
056         * Numeric constant representing the commited read isolation level.
057         * <p/>
058         * Obtaining two concurrent write locks on a given object is not allowed.
059         * Obtaining read locks is allowed only if there is no write lock on
060         * the given object.
061         * <p/>
062         * Allows:<br/>
063         * Non-Repeatable Reads<br/>
064         * Phantom Reads<br/>
065         */
066        public final static int IL_READ_COMMITTED = 3;
067    
068        /**
069         * Numeric constant representing the repeatable read isolation level.
070         * <p/>
071         * As commited reads, but obtaining a write lock on an object that has
072         * been locked for reading by another transaction is not allowed.
073         * <p/>
074         * Allows:<br/>
075         * Phantom Reads<br/>
076         */
077        public final static int IL_REPEATABLE_READ = 5;
078    
079        /**
080         * Numeric constant representing the serializable transactions isolation level.
081         * <p/>
082         * As Repeatable Reads, but it is even not allowed to have multiple
083         * read locks on a given object.
084         * <p/>
085         * Allows:<br/>
086         * -<br/>
087         */
088        public final static int IL_SERIALIZABLE = 7;
089    
090        /**
091         * Numeric constant representing the optimistic locking isolation level.
092         * <p/>
093         * The lock manager does not perform any pessimistic locking action. Normally
094         * it's not needed to declare this isolation level in persistent object metadata,
095         * because OJB will automatically detect an enabled optimistic locking.
096         * <br/>
097         * NOTE: Usage of this isolation level needs an specific optimistic locking
098         * declaration for the specified object. This declaration is <strong>not</strong>
099         * automatically handled by OJB and need setting of configuration properties - see OJB docs.
100         */
101        public final static int IL_OPTIMISTIC = 4;
102    
103        /**
104         * Numeric constant representing the default isolation level used by
105         * OJB - current used default level is {@link #IL_READ_UNCOMMITTED}.
106         */
107        public final static int IL_DEFAULT = IL_READ_UNCOMMITTED;
108    
109        /**
110         * Literal constant representing the uncommited read isolation level.
111         */
112        public final static String LITERAL_IL_NONE = "none";
113    
114        /**
115         * Literal constant representing the uncommited read isolation level.
116         */
117        public final static String LITERAL_IL_READ_UNCOMMITTED = "read-uncommitted";
118    
119        /**
120         * Literal constant representing the commited read isolation level.
121         */
122        public final static String LITERAL_IL_READ_COMMITTED = "read-committed";
123    
124        /**
125         * Literal constant representing the repeatable read isolation level.
126         */
127        public final static String LITERAL_IL_REPEATABLE_READ = "repeatable-read";
128    
129        /**
130         * Literal constant representing the serializable transactions isolation level.
131         */
132        public final static String LITERAL_IL_SERIALIZABLE = "serializable";
133    
134        /**
135         * Literal constant representing the optimistic locking isolation level.
136         */
137        public final static String LITERAL_IL_OPTIMISTIC = "optimistic";
138    }