db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/otm/lock IsolationFactory.java
Date Wed, 31 Aug 2005 17:38:51 GMT
arminw      2005/08/31 10:38:51

  Modified:    src/java/org/apache/ojb/broker/locking
                        CommonsOJBLockManager.java IsolationLevels.java
                        LockIsolation.java LockIsolationManager.java
                        LockManager.java LockManagerCommonsImpl.java
                        LockManagerInMemoryImpl.java
                        LockManagerRemoteImpl.java LockManagerServlet.java
               src/java/org/apache/ojb/broker/metadata ClassDescriptor.java
                        DescriptorRepository.java RepositoryPersistor.java
                        RepositoryXmlHandler.java
               src/java/org/apache/ojb/odmg/locking
                        LockManagerOdmgImpl.java
               src/java/org/apache/ojb/otm/lock IsolationFactory.java
  Removed:     src/java/org/apache/ojb/broker/locking LockHelper.java
               src/java/org/apache/ojb/broker/metadata IsolationLevels.java
  Log:
  (re-)introduce typesafe isolation level handling, use commons-lang enums instead of int values
  
  Revision  Changes    Path
  1.3       +32 -32    db-ojb/src/java/org/apache/ojb/broker/locking/CommonsOJBLockManager.java
  
  Index: CommonsOJBLockManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/CommonsOJBLockManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CommonsOJBLockManager.java	27 Aug 2005 12:13:37 -0000	1.2
  +++ CommonsOJBLockManager.java	31 Aug 2005 17:38:50 -0000	1.3
  @@ -26,10 +26,10 @@
    * support all locking isolation level defined in OJB locking api and a provider of
    * specific {@link org.apache.commons.transaction.locking.GenericLock} implementation classes
    * representing the isolation levels specified in {@link org.apache.ojb.broker.locking.LockManager}, like
  - * {@link org.apache.ojb.broker.locking.LockManager#IL_READ_COMMITTED}, ... .
  + * {@link IsolationLevels#READ_COMMITTED}, ... .
    * <p/>
    * The specific lock classes will be returned on call of
  - * {@link #createIsolationLevel(Object, Object, org.apache.commons.transaction.util.LoggerFacade)}
  + * {@link #createIsolationLevel(Object, IsolationLevels, org.apache.commons.transaction.util.LoggerFacade)}
    * dependend on the specified isolation level.
    *
    * @author <a href="mailto:arminw@apache.org">Armin Waibel</a>
  @@ -144,17 +144,17 @@
        * This methods guarantees to do this atomically (in none-clustered environment).
        *
        * @param resourceId  the resource to get or create the lock on
  -     * @param isolationId the isolation level identity key. See {@link CommonsOJBLockManager}.
  +     * @param isolationLevel the isolation level identity key. See {@link CommonsOJBLockManager}.
        * @return the lock for the specified resource
        */
  -    public OJBLock atomicGetOrCreateLock(Object resourceId, Object isolationId)
  +    public OJBLock atomicGetOrCreateLock(Object resourceId, Object isolationLevel)
       {
           synchronized(sync)
           {
               MultiLevelLock lock = getLock(resourceId);
               if(lock == null)
               {
  -                lock = createLock(resourceId, isolationId);
  +                lock = createLock(resourceId, (IsolationLevels) isolationLevel);
               }
               return (OJBLock) lock;
           }
  @@ -168,13 +168,13 @@
           return createLock(resourceId, null);
       }
   
  -    protected GenericLock createLock(Object resourceId, Object isolationId)
  +    protected GenericLock createLock(Object resourceId, IsolationLevels isolationLevel)
       {
           synchronized(sync)
           {
  -            if(isolationId != null)
  +            if(isolationLevel != null)
               {
  -                GenericLock lock = createIsolationLevel(resourceId, isolationId, logger);
  +                GenericLock lock = createIsolationLevel(resourceId, isolationLevel, logger);
                   globalLocks.put(resourceId, lock);
                   return lock;
               }
  @@ -192,27 +192,27 @@
        * {@link org.apache.commons.transaction.locking.MultiLevelLock2} instances
        * dependend on the specified isolation identity object.
        */
  -    public OJBLock createIsolationLevel(Object resourceId, Object isolationId, LoggerFacade logger)
  +    public OJBLock createIsolationLevel(Object resourceId, IsolationLevels isolationLevel, LoggerFacade logger)
       {
           OJBLock result;
  -        switch(((Integer) isolationId).intValue())
  +        switch(isolationLevel.getValue())
           {
  -            case LockManager.IL_READ_UNCOMMITTED:
  +            case IsolationLevels.IL_READ_UNCOMMITTED:
                   result = new ReadUncommittedLock(resourceId, logger);
                   break;
  -            case LockManager.IL_READ_COMMITTED:
  +            case IsolationLevels.IL_READ_COMMITTED:
                   result = new ReadCommitedLock(resourceId, logger);
                   break;
  -            case LockManager.IL_REPEATABLE_READ:
  +            case IsolationLevels.IL_REPEATABLE_READ:
                   result = new RepeadableReadsLock(resourceId, logger);
                   break;
  -            case LockManager.IL_SERIALIZABLE:
  +            case IsolationLevels.IL_SERIALIZABLE:
                   result = new SerializeableLock(resourceId, logger);
                   break;
  -            case LockManager.IL_OPTIMISTIC:
  +            case IsolationLevels.IL_OPTIMISTIC:
                   throw new LockRuntimeException("Optimistic locking must be handled on top of this class");
               default:
  -                throw new LockRuntimeException("Unknown lock isolation level specified");
  +                throw new LockRuntimeException("Illegal lock isolation level specified");
           }
           return result;
       }
  @@ -223,30 +223,30 @@
        * on the isolation level to the internal used lock level value by the
        * {@link org.apache.commons.transaction.locking.MultiLevelLock2} implementation.
        *
  -     * @param isolationId
  -     * @param lockLevel
  +     * @param isolationLevel The {@link IsolationLevels} instance to map.
  +     * @param lockLevel The mapped commons-tx lock level.
        */
  -    int mapLockLevelDependendOnIsolationLevel(Integer isolationId, int lockLevel)
  +    int mapLockLevelDependendOnIsolationLevel(IsolationLevels isolationLevel, int lockLevel)
       {
           int result;
  -        switch(isolationId.intValue())
  +        switch(isolationLevel.getValue())
           {
  -            case LockManager.IL_READ_UNCOMMITTED:
  +            case IsolationLevels.IL_READ_UNCOMMITTED:
                   result = ReadUncommittedLock.mapLockLevel(lockLevel);
                   break;
  -            case LockManager.IL_READ_COMMITTED:
  +            case IsolationLevels.IL_READ_COMMITTED:
                   result = ReadCommitedLock.mapLockLevel(lockLevel);
                   break;
  -            case LockManager.IL_REPEATABLE_READ:
  +            case IsolationLevels.IL_REPEATABLE_READ:
                   result = RepeadableReadsLock.mapLockLevel(lockLevel);
                   break;
  -            case LockManager.IL_SERIALIZABLE:
  +            case IsolationLevels.IL_SERIALIZABLE:
                   result = SerializeableLock.mapLockLevel(lockLevel);
                   break;
  -            case LockManager.IL_OPTIMISTIC:
  -                throw new LockRuntimeException("Optimistic locking must be handled on top of this class");
  +            case IsolationLevels.IL_OPTIMISTIC:
  +                throw new LockRuntimeException("Optimistic locking must be handled on top of this class: " + isolationLevel);
               default:
  -                throw new LockRuntimeException("Unknown lock isolation level specified");
  +                throw new LockRuntimeException("Illegal lock isolation level specified: " + isolationLevel);
           }
           return result;
       }
  @@ -315,7 +315,7 @@
       // inner class, commons-tx lock
       //===================================================
       /**
  -     * Implementation of isolation level {@link LockManager#IL_READ_UNCOMMITTED}.
  +     * Implementation of isolation level {@link IsolationLevels#IL_READ_UNCOMMITTED}.
        */
       static class ReadUncommittedLock extends RepeadableReadsLock
       {
  @@ -341,7 +341,7 @@
       // inner class, commons-tx lock
       //===================================================
       /**
  -     * Implementation of isolation level {@link LockManager#IL_READ_COMMITTED}.
  +     * Implementation of isolation level {@link IsolationLevels#IL_READ_COMMITTED}.
        */
       static final class ReadCommitedLock extends RepeadableReadsLock
       {
  @@ -367,7 +367,7 @@
       // inner class, commons-tx lock
       //===================================================
       /**
  -     * Implementation of isolation level {@link LockManager#IL_REPEATABLE_READ}.
  +     * Implementation of isolation level {@link IsolationLevels#IL_REPEATABLE_READ}.
        */
       static class RepeadableReadsLock extends OJBLock
       {
  @@ -437,7 +437,7 @@
       // inner class, commons-tx lock
       //===================================================
       /**
  -     * Implementation of isolation level {@link LockManager#IL_SERIALIZABLE}.
  +     * Implementation of isolation level {@link IsolationLevels#IL_SERIALIZABLE}.
        */
       static final class SerializeableLock extends ReadUncommittedLock
       {
  
  
  
  1.3       +208 -26   db-ojb/src/java/org/apache/ojb/broker/locking/IsolationLevels.java
  
  Index: IsolationLevels.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/IsolationLevels.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IsolationLevels.java	27 Aug 2005 12:13:37 -0000	1.2
  +++ IsolationLevels.java	31 Aug 2005 17:38:50 -0000	1.3
  @@ -1,5 +1,11 @@
   package org.apache.ojb.broker.locking;
   
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Map;
  +
  +import org.apache.commons.lang.enums.ValuedEnum;
  +
   /* Copyright 2002-2004 The Apache Software Foundation
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
  @@ -16,39 +22,92 @@
    */
   
   /**
  - * This interface defines the lock isolation level constants used by
  - * OJB locking api. It contains numeric constants and literal constants
  - * representing all known isolation levels.
  + * This class defines the lock isolation level constants used by
  + * the <em>OJB locking api</em>. It contains numeric constants,
  + * literal constants and <em>IsolationLevel</em> instances representing
  + * all known isolation levels.
    * <p/>
    * NOTE: The lock isolation levels are labeled like the database transaction level but
  - * the definition of the levels is different - take care of that.
  + * the definition of the levels and the possible side-effects are some times a bit
  + * different.
  + * </p>
  + * <p/>
  + * <p/>
  + * <strong>Lock Isolation Levels</strong>
  + * </p>
  + * <p/>
  + * <p/>
  + * <strong>Uncommitted Reads</strong><br/>
  + * Obtaining two concurrent write locks on a given object is not allowed.
  + * Obtaining read locks is allowed even if another transaction is writing to that object.
  + * (Thats why this level is also called <em>dirty reads</em>, because you can read lock objects
  + * with an existing write lock).
  + * </p>
  + * <p/>
  + * <p/>
  + * <strong>Committed Reads</strong><br/>
  + * Obtaining two concurrent write locks on a given object is not allowed.
  + * Obtaining read locks is allowed only if there is no write lock on the given object.
  + * </p>
  + * <p/>
  + * <p/>
  + * <strong>Repeatable Reads</strong><br/>
  + * Same as <em>committed read</em>, but obtaining a write lock on an object that has been locked
  + * for reading by another transaction is not allowed.
  + * </p>
  + * <p/>
  + * <p/>
  + * <strong>Serializable</strong><br/>
  + * Same as <em>repeatable read</em>, but it is even not allowed to have multiple read locks
  + * on a given object. This level make access for each object exclusive and guarantee that an
  + * upgrade from read to write lock is always possible (read and write lock are the same in this case).
  + * </p>
  + * <p/>
  + * <p/>
  + * Description of possible isolation level issues:
  + * </p>
  + * <ul>
  + * <li>Dirty Reads<br/>
  + * If one transaction has a write lock on object A and another transaction could acquire a read lock
  + * on the same object instance A, the changes in A will immediately "seen" by the
  + * second tx (before the first tx commits).
  + * </li>
  + * <li>Non-Repeatable Reads<br/>
  + * If a read lock for an object exists and for another transaction it's allowed to obtain
  + * a write lock for the same object instance, "re-reading" of the read locked object
  + * can return different results.
  + * </li>
  + * </ul>
    *
    * @version $Id$
  + * @see LockManager
    */
  -public interface IsolationLevels
  +public class IsolationLevels extends ValuedEnum
   {
       /**
  -     * Numeric constant signals to use a higher isolation level
  -     * or the default setting.
  +     * Numeric constant signals to use a higher isolation level setting
  +     * or the default setting. This lock level is a "marker" level and must
  +     * not passed to {@link LockManager}.
        * <p/>
        * The lock manager will throw an {@link LockRuntimeException} if this
        * level is specified.
        */
  -    public final static int IL_IGNORE = -2;
  +    public final static int IL_USE_GLOBAL = -2;
   
       /**
  -     * Numeric constant representing an no-op isolation level.
  +     * Numeric constant representing an no-op isolation level
  +     * (no locking is used).
        * <p/>
        * The lock manager completely ignores locking.
        * <p/>
        * Allows:<br/>
        * all possible concurrent side-effects<br/>
        */
  -    public final static int IL_NONE = -1;
  +    public final static int IL_NO_LOCKING = -1;
   
       /**
        * Numeric constant representing the uncommited read isolation level.
  -     *  <p/>
  +     * <p/>
        * Obtaining two concurrent write locks on a given object is not
        * allowed. Obtaining read locks is allowed even if
        * another transaction is writing to that object
  @@ -57,7 +116,6 @@
        * Allows:<br/>
        * Dirty Reads<br/>
        * Non-Repeatable Reads<br/>
  -     * Phantom Reads<br/>
        */
       public final static int IL_READ_UNCOMMITTED = 2;
   
  @@ -70,7 +128,6 @@
        * <p/>
        * Allows:<br/>
        * Non-Repeatable Reads<br/>
  -     * Phantom Reads<br/>
        */
       public final static int IL_READ_COMMITTED = 3;
   
  @@ -81,7 +138,7 @@
        * been locked for reading by another transaction is not allowed.
        * <p/>
        * Allows:<br/>
  -     * Phantom Reads<br/>
  +     * -<br/>
        */
       public final static int IL_REPEATABLE_READ = 5;
   
  @@ -89,7 +146,8 @@
        * Numeric constant representing the serializable transactions isolation level.
        * <p/>
        * As Repeatable Reads, but it is even not allowed to have multiple
  -     * read locks on a given object.
  +     * read locks on a given object, thus only one lock operation (read or write)
  +     * can happen at the same time for one object.
        * <p/>
        * Allows:<br/>
        * -<br/>
  @@ -98,11 +156,11 @@
   
       /**
        * Numeric constant representing the optimistic locking isolation level.
  -     * <p/>
  +     * <br/>
        * The lock manager does not perform any pessimistic locking action. Normally
        * it's not needed to declare this isolation level in persistent object metadata,
        * because OJB will automatically detect an enabled optimistic locking.
  -     * <br/>
  +     * <p/>
        * NOTE: Usage of this isolation level needs an specific optimistic locking
        * declaration for the specified object. This declaration is <strong>not</strong>
        * automatically handled by OJB and need setting of configuration properties - see OJB docs.
  @@ -110,21 +168,15 @@
       public final static int IL_OPTIMISTIC = 4;
   
       /**
  -     * Numeric constant representing the default isolation level used by
  -     * OJB - current used default level is {@link #IL_READ_UNCOMMITTED}.
  -     */
  -    public final static int IL_DEFAULT = IL_READ_UNCOMMITTED;
  -
  -    /**
        * Literal constant signal to ignore the isolation level setting
        * and to use a higher level setting or a default setting.
        */
  -    public final static String LITERAL_IL_IGNORE = "ignore";
  +    public final static String LITERAL_IL_USE_GLOBAL = "global";
   
       /**
        * Literal constant representing that no isolation level is used.
        */
  -    public final static String LITERAL_IL_NONE = "none";
  +    public final static String LITERAL_IL_NO_LOCKING = "no-lock";
   
       /**
        * Literal constant representing the uncommited read isolation level.
  @@ -150,4 +202,134 @@
        * Literal constant representing the optimistic locking isolation level.
        */
       public final static String LITERAL_IL_OPTIMISTIC = "optimistic";
  +
  +    /**
  +     * The uncommited read isolation level.
  +     * More details see {@link #IL_READ_UNCOMMITTED}.
  +     */
  +    public final static IsolationLevels READ_UNCOMMITTED =
  +            new IsolationLevels(LITERAL_IL_READ_UNCOMMITTED, IL_READ_UNCOMMITTED, false);
  +
  +    /**
  +     * The commited read isolation level.
  +     * More details see {@link #IL_READ_COMMITTED}.
  +     */
  +    public final static IsolationLevels READ_COMMITTED =
  +            new IsolationLevels(LITERAL_IL_READ_COMMITTED, IL_READ_COMMITTED, false);
  +
  +    /**
  +     * The repeatable read isolation level.
  +     * More details see {@link #IL_REPEATABLE_READ}.
  +     */
  +    public final static IsolationLevels REPEATABLE_READ =
  +            new IsolationLevels(LITERAL_IL_REPEATABLE_READ, IL_REPEATABLE_READ, false);
  +
  +    /**
  +     * The serializable transactions isolation level.
  +     * More details see {@link #IL_SERIALIZABLE}.
  +     */
  +    public final static IsolationLevels SERIALIZABLE =
  +            new IsolationLevels(LITERAL_IL_SERIALIZABLE, IL_SERIALIZABLE, false);
  +
  +    /**
  +     * The optimistic locking isolation level.
  +     * More details see {@link #IL_OPTIMISTIC}.
  +     */
  +    public final static IsolationLevels OPTIMISTIC =
  +            new IsolationLevels(LITERAL_IL_OPTIMISTIC, IL_OPTIMISTIC, true);
  +
  +    /**
  +     * The  no-lock level.
  +     * More details see {@link #IL_NO_LOCKING}.
  +     */
  +    public final static IsolationLevels NO_LOCKING =
  +            new IsolationLevels(LITERAL_IL_NO_LOCKING, IL_NO_LOCKING, true);
  +
  +    /**
  +     * A "marker" level to signal use of a higher locking level setting.
  +     * More details see {@link #IL_USE_GLOBAL}.
  +     */
  +    public final static IsolationLevels USE_GLOBAL =
  +            new IsolationLevels(LITERAL_IL_USE_GLOBAL, IL_USE_GLOBAL, true);
  +
  +    /**
  +     * Returns the enum value that corresponds to the given integer
  +     * representation.
  +     *
  +     * @param intValue The integer value
  +     * @return The enum value
  +     */
  +    public static IsolationLevels getEnum(int intValue)
  +    {
  +        return (IsolationLevels) getEnum(IsolationLevels.class, intValue);
  +    }
  +
  +    /**
  +     * Returns the enum value that corresponds to the given string
  +     * representation.
  +     *
  +     * @param name The name of the isolation level.
  +     * @return The enum value
  +     */
  +    public static IsolationLevels getEnum(String name)
  +    {
  +        return (IsolationLevels) getEnum(IsolationLevels.class, name);
  +    }
  +
  +    /**
  +     * Returns the map of enum values
  +     *
  +     * @return The map of enum values
  +     */
  +    public static Map getEnumMap()
  +    {
  +        return getEnumMap(IsolationLevels.class);
  +    }
  +
  +    /**
  +     * Returns a list of all enum values
  +     *
  +     * @return The list of enum values
  +     */
  +    public static List getEnumList()
  +    {
  +        return getEnumList(IsolationLevels.class);
  +    }
  +
  +    /**
  +     * Returns an iterator of all enum values
  +     *
  +     * @return The iterator
  +     */
  +    public static Iterator iterator()
  +    {
  +        return iterator(IsolationLevels.class);
  +    }
  +
  +
  +
  +    private boolean ignore;
  +
  +    /**
  +     * Constructor.
  +     * @param name
  +     * @param value
  +     */
  +    private IsolationLevels(String name, int value, boolean ignore)
  +    {
  +        super(name, value);
  +        this.ignore = ignore;
  +    }
  +
  +    /**
  +     * Check if the specified lock level can be ignored by the {@link LockManager}.
  +     * This is the case when the lock level is {@link IsolationLevels#IL_NO_LOCKING}
  +     * or {@link IsolationLevels#IL_OPTIMISTIC}.
  +     *
  +     * @return <em>True</em> if the lock level can be ignored by the {@link LockManager}.
  +     */
  +    public boolean ignoreForLock()
  +    {
  +        return ignore;
  +    }
   }
  
  
  
  1.3       +1 -1      db-ojb/src/java/org/apache/ojb/broker/locking/LockIsolation.java
  
  Index: LockIsolation.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/LockIsolation.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LockIsolation.java	27 Aug 2005 12:13:37 -0000	1.2
  +++ LockIsolation.java	31 Aug 2005 17:38:50 -0000	1.3
  @@ -26,7 +26,7 @@
        * Returns the isolation level identity.
        * @return The isolation level number.
        */
  -    abstract int getIsolationLevel();
  +    abstract IsolationLevels getIsolationLevel();
   
       /**
        * Returns the isolation level identity as string.
  
  
  
  1.3       +20 -20    db-ojb/src/java/org/apache/ojb/broker/locking/LockIsolationManager.java
  
  Index: LockIsolationManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/LockIsolationManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LockIsolationManager.java	27 Aug 2005 12:13:37 -0000	1.2
  +++ LockIsolationManager.java	31 Aug 2005 17:38:50 -0000	1.3
  @@ -41,20 +41,20 @@
        * Obtains a lock isolation for Object obj. The Strategy to be used is
        * selected by evaluating the ClassDescriptor of obj.getClass().
        */
  -    public LockIsolation getStrategyFor(int isolationLevel)
  +    public LockIsolation getStrategyFor(IsolationLevels isolationLevel)
       {
  -        switch(isolationLevel)
  +        switch(isolationLevel.getValue())
           {
  -            case LockManager.IL_READ_UNCOMMITTED:
  +            case IsolationLevels.IL_READ_UNCOMMITTED:
                   return readUncommitedStrategy;
  -            case LockManager.IL_READ_COMMITTED:
  +            case IsolationLevels.IL_READ_COMMITTED:
                   return readCommitedStrategy;
  -            case LockManager.IL_REPEATABLE_READ:
  +            case IsolationLevels.IL_REPEATABLE_READ:
                   return readRepeatableStrategy;
  -            case LockManager.IL_SERIALIZABLE:
  +            case IsolationLevels.IL_SERIALIZABLE:
                   return serializableStrategy;
               default:
  -                return readUncommitedStrategy;
  +                throw new LockRuntimeException("Illegal lock isolation level: " + isolationLevel);
           }
       }
   
  @@ -79,14 +79,14 @@
           {
           }
   
  -        public int getIsolationLevel()
  +        public IsolationLevels getIsolationLevel()
           {
  -            return LockManager.IL_READ_UNCOMMITTED;
  +            return IsolationLevels.READ_UNCOMMITTED;
           }
   
           public String getIsolationLevelAsString()
           {
  -            return LockManager.LITERAL_IL_READ_UNCOMMITTED;
  +            return IsolationLevels.LITERAL_IL_READ_UNCOMMITTED;
           }
   
           public boolean allowMultipleRead()
  @@ -127,14 +127,14 @@
           {
           }
   
  -        public int getIsolationLevel()
  +        public IsolationLevels getIsolationLevel()
           {
  -            return LockManager.IL_READ_COMMITTED;
  +            return IsolationLevels.READ_COMMITTED;
           }
   
           public String getIsolationLevelAsString()
           {
  -            return LockManager.LITERAL_IL_READ_COMMITTED;
  +            return IsolationLevels.LITERAL_IL_READ_COMMITTED;
           }
   
           public boolean allowMultipleRead()
  @@ -171,14 +171,14 @@
           {
           }
   
  -        public int getIsolationLevel()
  +        public IsolationLevels getIsolationLevel()
           {
  -            return LockManager.IL_REPEATABLE_READ;
  +            return IsolationLevels.REPEATABLE_READ;
           }
   
           public String getIsolationLevelAsString()
           {
  -            return LockManager.LITERAL_IL_REPEATABLE_READ;
  +            return IsolationLevels.LITERAL_IL_REPEATABLE_READ;
           }
   
           public boolean allowMultipleRead()
  @@ -211,14 +211,14 @@
           {
           }
   
  -        public int getIsolationLevel()
  +        public IsolationLevels getIsolationLevel()
           {
  -            return LockManager.IL_SERIALIZABLE;
  +            return IsolationLevels.SERIALIZABLE;
           }
   
           public String getIsolationLevelAsString()
           {
  -            return LockManager.LITERAL_IL_SERIALIZABLE;
  +            return IsolationLevels.LITERAL_IL_SERIALIZABLE;
           }
   
           public boolean allowMultipleRead()
  
  
  
  1.5       +10 -9     db-ojb/src/java/org/apache/ojb/broker/locking/LockManager.java
  
  Index: LockManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/LockManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LockManager.java	27 Aug 2005 12:13:37 -0000	1.4
  +++ LockManager.java	31 Aug 2005 17:38:50 -0000	1.5
  @@ -17,12 +17,12 @@
   
   
   /**
  - * This interface declares the functionality of the OJB locking-api for support of
  + * This interface declares the functionality of the <em>OJB locking-api</em> for support of
    * pessimistic locking.
    * <p>
    * OJB allows to provide user defined implementations of this interface.
  - * To activate a user defined LockManager implementation it must be configured in
  - * the OJB.properties file.
  + * To activate a user defined <code>LockManager</code> implementation it must
  + * be configured in the <code>OJB.properties</code> file.
    * </p>
    * <p>
    * All locks have to be reentrant, this means if you already have a lock for
  @@ -33,11 +33,12 @@
    * It's optional to support the <em>lockTimeout</em> and <em>blockTimeout</em> properties.
    * </p>
    *
  + * @see IsolationLevels
    * @see LockManagerInMemoryImpl
    * @see LockManagerCommonsImpl
    * @version $Id$
    */
  -public interface LockManager extends IsolationLevels
  +public interface LockManager
   {
       /**
        * Default lock timeout value - set to 60000 ms.
  @@ -52,7 +53,7 @@
       /**
        * The maximal time to wait for acquire a lock.
        *
  -     * @return
  +     * @return The time to wait for aquire a lock.
        */
       public long getBlockTimeout();
   
  @@ -93,7 +94,7 @@
        * @param isolationLevel The isolation level of the lock.
        * @return <em>True</em> if the lock was successfully acquired.
        */
  -    public boolean readLock(Object key, Object resourceId, int isolationLevel);
  +    public boolean readLock(Object key, Object resourceId, IsolationLevels isolationLevel);
   
       /**
        * Acquires a write lock for lock key on resource object.
  @@ -104,7 +105,7 @@
        * @param isolationLevel The isolation level of the lock.
        * @return <em>True</em> if the lock was successfully acquired.
        */
  -    public boolean writeLock(Object key, Object resourceId, int isolationLevel);
  +    public boolean writeLock(Object key, Object resourceId, IsolationLevels isolationLevel);
   
       /**
        * Acquire an upgrade lock.
  @@ -115,7 +116,7 @@
        * @param isolationLevel The isolation level of the lock.
        * @return <em>True</em> if the lock was successfully acquired.
        */
  -    public boolean upgradeLock(Object key, Object resourceId, int isolationLevel);
  +    public boolean upgradeLock(Object key, Object resourceId, IsolationLevels isolationLevel);
   
       /**
        * Releases a lock for lock key on resource object.
  
  
  
  1.3       +10 -10    db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerCommonsImpl.java
  
  Index: LockManagerCommonsImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerCommonsImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LockManagerCommonsImpl.java	27 Aug 2005 12:13:37 -0000	1.2
  +++ LockManagerCommonsImpl.java	31 Aug 2005 17:38:50 -0000	1.3
  @@ -87,19 +87,19 @@
           return msg.toString();
       }
   
  -    public boolean readLock(Object key, Object resourceId, int isolationLevel)
  +    public boolean readLock(Object key, Object resourceId, IsolationLevels isolationLevel)
       {
  -        return LockHelper.ignore(isolationLevel) || lm.readLock(key, resourceId, new Integer(isolationLevel), blockTimeout);
  +        return isolationLevel.ignoreForLock() || lm.readLock(key, resourceId, isolationLevel, blockTimeout);
       }
   
  -    public boolean writeLock(Object key, Object resourceId, int isolationLevel)
  +    public boolean writeLock(Object key, Object resourceId, IsolationLevels isolationLevel)
       {
  -        return LockHelper.ignore(isolationLevel) || lm.writeLock(key, resourceId, new Integer(isolationLevel), blockTimeout);
  +        return isolationLevel.ignoreForLock() || lm.writeLock(key, resourceId,isolationLevel, blockTimeout);
       }
   
  -    public boolean upgradeLock(Object key, Object resourceId, int isolationLevel)
  +    public boolean upgradeLock(Object key, Object resourceId, IsolationLevels isolationLevel)
       {
  -        return LockHelper.ignore(isolationLevel) || lm.upgradeLock(key, resourceId, new Integer(isolationLevel), blockTimeout);
  +        return isolationLevel.ignoreForLock() || lm.upgradeLock(key, resourceId, isolationLevel, blockTimeout);
       }
   
       public boolean releaseLock(Object key, Object resourceId)
  @@ -166,7 +166,7 @@
               return (CommonsOJBLockManager.OJBLock) getLock(resourceId);
           }
   
  -        boolean readLock(Object key, Object resourceId, Integer isolationLevel, long timeout)
  +        boolean readLock(Object key, Object resourceId, IsolationLevels isolationLevel, long timeout)
           {
               /*
               arminw: Not sure what's the best way to go
  @@ -182,7 +182,7 @@
               return tryLock(key, resourceId, lockLevel, true, isolationLevel);
           }
   
  -        boolean writeLock(Object key, Object resourceId, Integer isolationLevel, long timeout)
  +        boolean writeLock(Object key, Object resourceId, IsolationLevels isolationLevel, long timeout)
           {
               try
               {
  @@ -198,7 +198,7 @@
               }
           }
   
  -        boolean upgradeLock(Object key, Object resourceId, Integer isolationLevel, long timeout)
  +        boolean upgradeLock(Object key, Object resourceId, IsolationLevels isolationLevel, long timeout)
           {
               try
               {
  
  
  
  1.3       +10 -10    db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java
  
  Index: LockManagerInMemoryImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LockManagerInMemoryImpl.java	27 Aug 2005 12:13:37 -0000	1.2
  +++ LockManagerInMemoryImpl.java	31 Aug 2005 17:38:50 -0000	1.3
  @@ -91,11 +91,11 @@
           return msg.toString();
       }
   
  -    public boolean readLock(Object key, Object resourceId, int isolationLevel)
  +    public boolean readLock(Object key, Object resourceId, IsolationLevels isolationLevel)
       {
           if(log.isDebugEnabled()) log.debug("LM.readLock(tx-" + key + ", " + resourceId + ")");
           checkTimedOutLocks();
  -        if(LockHelper.ignore(isolationLevel))
  +        if(isolationLevel.ignoreForLock())
           {
               return true;
           }
  @@ -294,11 +294,11 @@
           }
       }
   
  -    public boolean writeLock(Object key, Object resourceId, int isolationLevel)
  +    public boolean writeLock(Object key, Object resourceId, IsolationLevels isolationLevel)
       {
           if(log.isDebugEnabled()) log.debug("LM.writeLock(tx-" + key + ", " + resourceId + ")");
           checkTimedOutLocks();
  -        if(LockHelper.ignore(isolationLevel))
  +        if(isolationLevel.ignoreForLock())
           {
               return true;
           }
  @@ -399,7 +399,7 @@
           return result;
       }
   
  -    public boolean upgradeLock(Object key, Object resourceId, int isolationLevel)
  +    public boolean upgradeLock(Object key, Object resourceId, IsolationLevels isolationLevel)
       {
           if(log.isDebugEnabled()) log.debug("LM.upgradeLock(tx-" + key + ", " + resourceId + ")");
           return writeLock(key, resourceId, isolationLevel);
  @@ -653,7 +653,7 @@
           /**
            * the isolationlevel for this lock.
            */
  -        private int isolationLevel;
  +        private IsolationLevels isolationLevel;
   
           /**
            * marks if this is a read or a write lock.
  @@ -668,7 +668,7 @@
           public LockEntry(Object resourceId,
                            Object key,
                            long timestamp,
  -                         int isolationLevel,
  +                         IsolationLevels isolationLevel,
                            int lockType)
           {
               this.resourceId = resourceId;
  @@ -706,7 +706,7 @@
           /**
            * returns the isolation level of this lock
            */
  -        public int getIsolationLevel()
  +        public IsolationLevels getIsolationLevel()
           {
               return isolationLevel;
           }
  @@ -746,7 +746,7 @@
            *
            * @param isolationLevel The isolationLevel to set
            */
  -        public void setIsolationLevel(int isolationLevel)
  +        public void setIsolationLevel(IsolationLevels isolationLevel)
           {
               this.isolationLevel = isolationLevel;
           }
  
  
  
  1.3       +10 -10    db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerRemoteImpl.java
  
  Index: LockManagerRemoteImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerRemoteImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LockManagerRemoteImpl.java	27 Aug 2005 12:13:37 -0000	1.2
  +++ LockManagerRemoteImpl.java	31 Aug 2005 17:38:50 -0000	1.3
  @@ -173,15 +173,15 @@
           }
       }
   
  -    public boolean readLock(Object key, Object resourceId, int isolationLevel)
  +    public boolean readLock(Object key, Object resourceId, IsolationLevels isolationLevel)
       {
  -        if(LockHelper.ignore(isolationLevel))
  +        if(isolationLevel.ignoreForLock())
           {
               return true;
           }
           else
           {
  -            LockInfo info = new LockInfo(key, resourceId, isolationLevel, METHOD_READ_LOCK);
  +            LockInfo info = new LockInfo(key, resourceId, isolationLevel.getValue(), METHOD_READ_LOCK);
               try
               {
                   byte[] requestBarr = serialize(info);
  @@ -239,15 +239,15 @@
           }
       }
   
  -    public boolean writeLock(Object key, Object resourceId, int isolationLevel)
  +    public boolean writeLock(Object key, Object resourceId, IsolationLevels isolationLevel)
       {
  -        if(LockHelper.ignore(isolationLevel))
  +        if(isolationLevel.ignoreForLock())
           {
               return true;
           }
           else
           {
  -            LockInfo info = new LockInfo(key, resourceId, isolationLevel, METHOD_WRITE_LOCK);
  +            LockInfo info = new LockInfo(key, resourceId, isolationLevel.getValue(), METHOD_WRITE_LOCK);
               try
               {
                   byte[] requestBarr = serialize(info);
  @@ -261,15 +261,15 @@
           }
       }
   
  -    public boolean upgradeLock(Object key, Object resourceId, int isolationLevel)
  +    public boolean upgradeLock(Object key, Object resourceId, IsolationLevels isolationLevel)
       {
  -        if(LockHelper.ignore(isolationLevel))
  +        if(isolationLevel.ignoreForLock())
           {
               return true;
           }
           else
           {
  -            LockInfo info = new LockInfo(key, resourceId, isolationLevel, METHOD_UPGRADE_LOCK);
  +            LockInfo info = new LockInfo(key, resourceId, isolationLevel.getValue(), METHOD_UPGRADE_LOCK);
               try
               {
                   byte[] requestBarr = serialize(info);
  
  
  
  1.3       +3 -3      db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerServlet.java
  
  Index: LockManagerServlet.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LockManagerServlet.java	27 Aug 2005 12:13:37 -0000	1.2
  +++ LockManagerServlet.java	31 Aug 2005 17:38:50 -0000	1.3
  @@ -154,7 +154,7 @@
                   {
                       case LockManagerRemoteImpl.METHOD_READ_LOCK:
                           {
  -                            result = lockmanager.readLock(info.key, info.resourceId, info.isolationLevel) ? Boolean.TRUE : Boolean.FALSE;
  +                            result = lockmanager.readLock(info.key, info.resourceId, IsolationLevels.getEnum(info.isolationLevel)) ? Boolean.TRUE : Boolean.FALSE;
                               break;
                           }
                       case LockManagerRemoteImpl.METHOD_RELEASE_SINGLE_LOCK:
  @@ -170,12 +170,12 @@
                           }
                       case LockManagerRemoteImpl.METHOD_WRITE_LOCK:
                           {
  -                            result = lockmanager.writeLock(info.key, info.resourceId, info.isolationLevel) ? Boolean.TRUE : Boolean.FALSE;
  +                            result = lockmanager.writeLock(info.key, info.resourceId, IsolationLevels.getEnum(info.isolationLevel)) ? Boolean.TRUE : Boolean.FALSE;
                               break;
                           }
                       case LockManagerRemoteImpl.METHOD_UPGRADE_LOCK:
                           {
  -                            result = lockmanager.upgradeLock(info.key, info.resourceId, info.isolationLevel) ? Boolean.TRUE : Boolean.FALSE;
  +                            result = lockmanager.upgradeLock(info.key, info.resourceId, IsolationLevels.getEnum(info.isolationLevel)) ? Boolean.TRUE : Boolean.FALSE;
                               break;
                           }
                       case LockManagerRemoteImpl.METHOD_CHECK_READ:
  
  
  
  1.109     +20 -11    db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
  
  Index: ClassDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- ClassDescriptor.java	27 Aug 2005 12:16:55 -0000	1.108
  +++ ClassDescriptor.java	31 Aug 2005 17:38:51 -0000	1.109
  @@ -35,7 +35,6 @@
   import org.apache.commons.lang.SystemUtils;
   import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.locking.IsolationLevels;
  -import org.apache.ojb.broker.locking.LockHelper;
   import org.apache.ojb.broker.util.ClassHelper;
   import org.apache.ojb.broker.util.SqlHelper;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  @@ -52,7 +51,7 @@
    * @version $Id$
    */
   public final class ClassDescriptor extends DescriptorBase
  -    implements Serializable, XmlCapable, IsolationLevels
  +    implements Serializable, XmlCapable
   {
   	private boolean useObjectFactory;
   
  @@ -132,7 +131,7 @@
       /**
        * transaction isolation level specified for this class, used in the ODMG server
        */
  -    private int m_IsolationLevel = IL_IGNORE;
  +    private IsolationLevels m_IsolationLevel;
       /**
        * the SQL SCHEMA of the underlying table of this class
        */
  @@ -254,7 +253,6 @@
       public ClassDescriptor(DescriptorRepository pRepository)
       {
           m_repository = pRepository;
  -        m_IsolationLevel = pRepository != null ? pRepository.getDefaultIsolationLevel() : m_IsolationLevel;
       }
   
   
  @@ -1323,18 +1321,29 @@
       }
   
       /**
  -     * returns the transaction isolation level to be used for this class. Used only in the ODMG server
  +     * Returns the specific transaction isolation level
  +     * set for this class - if the isolation level is not
  +     * set for this class, the global isolation level defined
  +     * in the associated {@link DescriptorRepository} is returned.
        */
  -    public int getIsolationLevel()
  +    public IsolationLevels getIsolationLevel()
       {
  -        return m_IsolationLevel;
  +        if((m_IsolationLevel != null
  +                && !m_IsolationLevel.equals(IsolationLevels.USE_GLOBAL)))
  +        {
  +            return m_IsolationLevel;
  +        }
  +        else
  +        {
  +            return (m_repository != null ? m_repository.getGlobalIsolationLevel() : IsolationLevels.USE_GLOBAL);
  +        }
       }
   
       /**
        * Method declaration
        * @param isoLevel
        */
  -    public void setIsolationLevel(int isoLevel)
  +    public void setIsolationLevel(IsolationLevels isoLevel)
       {
           m_IsolationLevel = isoLevel;
       }
  @@ -1992,7 +2001,7 @@
           // isolation level is optional
           if (null != getRepository())
           {
  -            if (getIsolationLevel() != this.getRepository().getDefaultIsolationLevel())
  +            if (getIsolationLevel() != null)
               {
                   result.append( "    ");
                   result.append( RepositoryTags.getAttribute(ISOLATION_LEVEL, this.isolationLevelXml()) );
  @@ -2205,7 +2214,7 @@
   
       private String isolationLevelXml()
       {
  -        return LockHelper.getIsolationLevelAsString(getIsolationLevel());
  +        return getIsolationLevel().getName();
       }
   
   }
  
  
  
  1.64      +14 -21    db-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
  
  Index: DescriptorRepository.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- DescriptorRepository.java	27 Aug 2005 12:16:55 -0000	1.63
  +++ DescriptorRepository.java	31 Aug 2005 17:38:51 -0000	1.64
  @@ -31,7 +31,7 @@
   import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.commons.lang.builder.ToStringStyle;
   import org.apache.ojb.broker.OJBRuntimeException;
  -import org.apache.ojb.broker.locking.LockHelper;
  +import org.apache.ojb.broker.locking.IsolationLevels;
   import org.apache.ojb.broker.util.ClassHelper;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.broker.util.logging.Logger;
  @@ -61,7 +61,7 @@
       /**
        * the default isolation level used for this repository
        */
  -    private int defaultIsolationLevel = IsolationLevels.IL_DEFAULT;
  +    private IsolationLevels globalIsolationLevel = IsolationLevels.READ_UNCOMMITTED;
       /**
        * This table holds all known Mapping descriptions.
        * Key values are the respective Class objects
  @@ -572,21 +572,24 @@
       }
   
       /**
  -     * Returns the defaultIsolationLevel.
  -     * @return int
  +     * Returns the global {@link org.apache.ojb.broker.locking.IsolationLevels}.
  +     *
  +     * @return The isolation level.
        */
  -    public int getDefaultIsolationLevel()
  +    public IsolationLevels getGlobalIsolationLevel()
       {
  -        return defaultIsolationLevel;
  +        return globalIsolationLevel;
       }
   
       /**
  -     * Sets the defaultIsolationLevel.
  -     * @param defaultIsolationLevel The defaultIsolationLevel to set
  +     * Sets the global {@link org.apache.ojb.broker.locking.IsolationLevels} used
  +     * for all classes without specific isolation level.
  +     *
  +     * @param globalLevel The global IsolationLevel to set.
        */
  -    public void setDefaultIsolationLevel(int defaultIsolationLevel)
  +    public void setGlobalIsolationLevel(IsolationLevels globalLevel)
       {
  -        this.defaultIsolationLevel = defaultIsolationLevel;
  +        this.globalIsolationLevel = globalLevel;
       }
   
       /**
  @@ -625,16 +628,6 @@
       }
   
       /**
  -     * returns IsolationLevel literal as matching
  -     * to the corresponding id
  -     * @return the IsolationLevel literal
  -     */
  -    protected String getIsolationLevelAsString()
  -    {
  -        return LockHelper.getIsolationLevelAsString(defaultIsolationLevel);
  -    }
  -
  -    /**
        * Starts by looking to see if the <code>className</code> is
        * already mapped specifically to the descritpor repository.
        * If the <code>className</code> is not specifically mapped we
  
  
  
  1.30      +2 -2      db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryPersistor.java
  
  Index: RepositoryPersistor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryPersistor.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- RepositoryPersistor.java	4 Mar 2005 13:31:06 -0000	1.29
  +++ RepositoryPersistor.java	31 Aug 2005 17:38:51 -0000	1.30
  @@ -143,7 +143,7 @@
   
               buf.append(RepositoryTags.getOpeningTagNonClosingById(RepositoryElements.MAPPING_REPOSITORY) + eol);
               buf.append("  " + RepositoryTags.getAttribute(RepositoryElements.REPOSITORY_VERSION, DescriptorRepository.getVersion()) + eol);
  -            buf.append("  " + RepositoryTags.getAttribute(RepositoryElements.ISOLATION_LEVEL, repository.getIsolationLevelAsString()) + eol);
  +            buf.append("  " + RepositoryTags.getAttribute(RepositoryElements.ISOLATION_LEVEL, repository.getGlobalIsolationLevel().getName()) + eol);
               buf.append(">" + eol);
   
               if(conRepository != null) buf.append(eol + eol + conRepository.toXML() + eol + eol);
  
  
  
  1.71      +24 -6     db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java
  
  Index: RepositoryXmlHandler.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- RepositoryXmlHandler.java	27 Aug 2005 12:16:55 -0000	1.70
  +++ RepositoryXmlHandler.java	31 Aug 2005 17:38:51 -0000	1.71
  @@ -16,12 +16,13 @@
    */
   
   import org.apache.ojb.broker.accesslayer.QueryCustomizer;
  -import org.apache.ojb.broker.locking.LockHelper;
  +import org.apache.ojb.broker.locking.IsolationLevels;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
   import org.apache.ojb.broker.util.ClassHelper;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  +import org.apache.commons.lang.StringUtils;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   import org.xml.sax.SAXParseException;
  @@ -145,8 +146,12 @@
                           this.m_CurrentAttrContainer = m_repository;
   
                           String defIso = atts.getValue(RepositoryTags.getTagById(ISOLATION_LEVEL));
  -                        this.m_repository.setDefaultIsolationLevel(LockHelper.getIsolationLevelFor(defIso));
  -                        if (isDebug) logger.debug("     " + RepositoryTags.getTagById(ISOLATION_LEVEL) + ": " + defIso);
  +                        if(checkString(defIso))
  +                        {
  +                            defIso = defIso.trim();
  +                            this.m_repository.setGlobalIsolationLevel(IsolationLevels.getEnum(defIso));
  +                            if (isDebug) logger.debug("     " + RepositoryTags.getTagById(ISOLATION_LEVEL) + ": " + defIso);
  +                        }
   
   
                           String proxyPrefetchingLimit = atts.getValue(RepositoryTags.getTagById(PROXY_PREFETCHING_LIMIT));
  @@ -187,7 +192,11 @@
                           only when an isolation-level is set in CLD, set it.
                           Else the CLD use the default iso-level defined in the repository
                           */
  -                        if(checkString(isoLevel)) m_CurrentCLD.setIsolationLevel(LockHelper.getIsolationLevelFor(isoLevel));
  +                        if(checkString(isoLevel))
  +                        {
  +                            isoLevel = isoLevel.trim();
  +                            m_CurrentCLD.setIsolationLevel(IsolationLevels.getEnum(isoLevel));
  +                        }
   
                           // set class attribute
                           String classname = atts.getValue(RepositoryTags.getTagById(CLASS_NAME));
  @@ -218,6 +227,7 @@
                           if (isDebug) logger.debug("     " + RepositoryTags.getTagById(CLASS_PROXY) + ": " + proxy);
                           if (checkString(proxy))
                           {
  +                            proxy = proxy.trim();
                               if (proxy.equalsIgnoreCase(ClassDescriptor.DYNAMIC_STR))
                               {
                                   m_CurrentCLD.setProxyClassName(ClassDescriptor.DYNAMIC_STR);
  @@ -259,6 +269,7 @@
                           if (isDebug) logger.debug("     " + RepositoryTags.getTagById(EXTENDS) + ": " + extendsAtt);
                           if (checkString(extendsAtt))
                           {
  +                            extendsAtt = extendsAtt.trim();
                               m_CurrentCLD.setSuperClass(extendsAtt);
                           }
   
  @@ -348,6 +359,7 @@
                               String className = atts.getValue(RepositoryTags.getTagById(CLASS_NAME));
                               if(checkString(className))
                               {
  +                                className = className.trim();
                                   ocd.setObjectCache(ClassHelper.getClass(className));
                                   if (isDebug) logger.debug("     " + RepositoryTags.getTagById(CLASS_NAME) + ": " + className);
                               }
  @@ -355,12 +367,14 @@
                               String strategy = atts.getValue(RepositoryTags.getTagById(STRATEGY));
                               if(checkString(strategy))
                               {
  +                                strategy = strategy.trim();
                                   ocd.setCachingStrategy(ClassHelper.getClass(strategy));
                                   if (isDebug) logger.debug("     " + RepositoryTags.getTagById(STRATEGY) + ": " + strategy);
                               }
                               String timeout = atts.getValue(RepositoryTags.getTagById(TIMEOUT));
                               if(checkString(timeout))
                               {
  +                                timeout = timeout.trim();
                                   ocd.setTimeout(new Integer(Integer.parseInt(timeout)));
                                   if (isDebug) logger.debug("     " + RepositoryTags.getTagById(TIMEOUT) + ": " + timeout);
                               }
  @@ -471,6 +485,7 @@
                           if (isDebug) logger.debug("     " + RepositoryTags.getTagById(UPDATE_LOCK) + ": " + updateLock);
                           if(checkString(updateLock))
                           {
  +                            updateLock = updateLock.trim();
                               b = (Boolean.valueOf(updateLock)).booleanValue();
                               m_CurrentFLD.setUpdateLock(b);
                           }
  @@ -1288,8 +1303,11 @@
           throw e;
       }
   
  +    /**
  +     * Return <em>true</em> if the string is not 'null' or blank.
  +     */
       private boolean checkString(String str)
       {
  -        return (str != null && !str.trim().equals(""));
  +        return StringUtils.isNotBlank(str);
       }
   }
  
  
  
  1.6       +5 -5      db-ojb/src/java/org/apache/ojb/odmg/locking/LockManagerOdmgImpl.java
  
  Index: LockManagerOdmgImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/locking/LockManagerOdmgImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LockManagerOdmgImpl.java	27 Aug 2005 12:28:14 -0000	1.5
  +++ LockManagerOdmgImpl.java	31 Aug 2005 17:38:51 -0000	1.6
  @@ -1,7 +1,7 @@
   package org.apache.ojb.odmg.locking;
   
   import org.apache.ojb.broker.Identity;
  -import org.apache.ojb.broker.locking.LockHelper;
  +import org.apache.ojb.broker.locking.IsolationLevels;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.odmg.TransactionImpl;
   
  @@ -56,7 +56,7 @@
       public boolean readLock(TransactionImpl tx, Identity oid, Object obj)
       {
           ClassDescriptor cld = tx.getBroker().getClassDescriptor(tx.getBrokerInternal().getProxyFactory().getRealClass(obj));
  -        int isolationLevel = LockHelper.extractLockLevel(cld);
  +        IsolationLevels isolationLevel = cld.getIsolationLevel();
           return lm.readLock(tx.getGUID(), oid, isolationLevel);
       }
   
  @@ -69,7 +69,7 @@
       public boolean writeLock(TransactionImpl tx, Identity oid, Object obj)
       {
           ClassDescriptor cld = tx.getBroker().getClassDescriptor(tx.getBrokerInternal().getProxyFactory().getRealClass(obj));
  -        int isolationLevel = LockHelper.extractLockLevel(cld);
  +        IsolationLevels isolationLevel = cld.getIsolationLevel();
           return lm.writeLock(tx.getGUID(), oid, isolationLevel);
       }
   
  @@ -82,7 +82,7 @@
       public boolean upgradeLock(TransactionImpl tx, Identity oid, Object obj)
       {
           ClassDescriptor cld = tx.getBroker().getClassDescriptor(tx.getBrokerInternal().getProxyFactory().getRealClass(obj));
  -        int isolationLevel = LockHelper.extractLockLevel(cld);
  +        IsolationLevels isolationLevel = cld.getIsolationLevel();
           return lm.upgradeLock(tx.getGUID(), oid, isolationLevel);
       }
   
  
  
  
  1.14      +12 -5     db-ojb/src/java/org/apache/ojb/otm/lock/IsolationFactory.java
  
  Index: IsolationFactory.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/lock/IsolationFactory.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- IsolationFactory.java	27 Aug 2005 13:38:39 -0000	1.13
  +++ IsolationFactory.java	31 Aug 2005 17:38:51 -0000	1.14
  @@ -16,8 +16,8 @@
    */
   
   import org.apache.ojb.broker.metadata.ClassDescriptor;
  -import org.apache.ojb.broker.metadata.IsolationLevels;
   import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.locking.IsolationLevels;
   import org.apache.ojb.otm.lock.isolation.ReadCommittedIsolation;
   import org.apache.ojb.otm.lock.isolation.ReadUncommittedIsolation;
   import org.apache.ojb.otm.lock.isolation.RepeatableReadIsolation;
  @@ -59,10 +59,10 @@
           // Class clazz = lock.getTargetIdentity().getObjectsTopLevelClass();
           Class clazz = lock.getTargetIdentity().getObjectsRealClass();
           ClassDescriptor classDescriptor = pb.getClassDescriptor(clazz);
  -        int isolationLevel = classDescriptor.getIsolationLevel();
  +        IsolationLevels isolationLevel = classDescriptor.getIsolationLevel();
   
  -        TransactionIsolation isolation = null;
  -        switch (isolationLevel) {
  +        TransactionIsolation isolation;
  +        switch (isolationLevel.getValue()) {
   
               case IsolationLevels.IL_READ_UNCOMMITTED:
                   isolation = READ_UNCOMMITTED_ISOLATION;
  @@ -79,7 +79,14 @@
               case IsolationLevels.IL_SERIALIZABLE:
                   isolation = SERIALIZABLE_ISOLATION;
                   break;
  -            case -2:
  +            /*
  +            TODO: fix this!!
  +            */
  +            case IsolationLevels.IL_NO_LOCKING:
  +                // new added isolation level
  +                isolation = READ_UNCOMMITTED_ISOLATION;
  +                break;
  +            case IsolationLevels.IL_OPTIMISTIC:
                   // new added isolation level
                   isolation = READ_UNCOMMITTED_ISOLATION;
                   break;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message