db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: db-ojb .classpath
Date Sun, 03 Jul 2005 20:32:34 GMT
tomdz       2005/07/03 13:32:34

  Modified:    src/java/org/apache/ojb/broker/metadata
                        ConnectionDescriptorXmlHandler.java
                        IsolationLevels.java ClassDescriptor.java
                        RepositoryXmlHandler.java DescriptorRepository.java
               src/java/org/apache/ojb/broker/ant
                        RepositoryVerifierHandler.java
               .        .classpath
  Added:       lib      commons-betwixt-0.7RC2.jar commons-digester-1.7.jar
                        commons-lang-2.1.jar
  Removed:     lib      commons-betwixt-0.5.jar commons-digester-1.5.jar
                        commons-lang-2.0.jar
  Log:
  Introduced a proper enum (commons-lang) for the isolation level
  Updated to newest commons-lang, commons-digester and commons-betwixt
  
  Revision  Changes    Path
  1.1                  db-ojb/lib/commons-betwixt-0.7RC2.jar
  
  	<<Binary file>>
  
  
  1.1                  db-ojb/lib/commons-digester-1.7.jar
  
  	<<Binary file>>
  
  
  1.1                  db-ojb/lib/commons-lang-2.1.jar
  
  	<<Binary file>>
  
  
  1.16      +2 -2      db-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionDescriptorXmlHandler.java
  
  Index: ConnectionDescriptorXmlHandler.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionDescriptorXmlHandler.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ConnectionDescriptorXmlHandler.java	15 Nov 2004 22:51:40 -0000	1.15
  +++ ConnectionDescriptorXmlHandler.java	3 Jul 2005 20:32:30 -0000	1.16
  @@ -44,7 +44,7 @@
    */
   public class ConnectionDescriptorXmlHandler
           extends DefaultHandler
  -        implements RepositoryElements, IsolationLevels
  +        implements RepositoryElements
   {
       private Logger logger = LoggerFactory.getLogger(ConnectionDescriptorXmlHandler.class);
   
  
  
  
  1.6       +106 -3    db-ojb/src/java/org/apache/ojb/broker/metadata/IsolationLevels.java
  
  Index: IsolationLevels.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/IsolationLevels.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- IsolationLevels.java	4 Apr 2004 23:53:34 -0000	1.5
  +++ IsolationLevels.java	3 Jul 2005 20:32:31 -0000	1.6
  @@ -15,14 +15,23 @@
    * limitations under the License.
    */
   
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Map;
  +
  +import org.apache.commons.lang.enums.ValuedEnum;
  +
   /**
    * This Interface defines Isolation level constants.
    * It contains numeric constants and literal constants
    * representing all known isolation levels.
    * @author Thomas Mahler
    */
  -public interface IsolationLevels
  +public final class IsolationLevels extends ValuedEnum
   {
  +    /** Id specifiying the class version for the serialization */
  +    private static final long serialVersionUID = 1L;
  +
       /** 
        * numeric constant representing the uncommited read isolation level.
        */
  @@ -79,7 +88,101 @@
        * literal constant representing the optimistic locking isolation level.
        */
       public final static String LITERAL_IL_OPTIMISTIC       = "optimistic";
  +
  +
  +    /** 
  +     * the uncommited read isolation level.
  +     */
  +    public final static IsolationLevels READ_UNCOMMITTED = new IsolationLevels(LITERAL_IL_READ_UNCOMMITTED,
IL_READ_UNCOMMITTED);
       
  -    
  -    
  +    /** 
  +     * the commited read isolation level.
  +     */
  +    public final static IsolationLevels READ_COMMITTED   = new IsolationLevels(LITERAL_IL_READ_COMMITTED,
IL_READ_COMMITTED);
  +    
  +    /** 
  +     * the repeatable read isolation level.
  +     */
  +    public final static IsolationLevels REPEATABLE_READ  = new IsolationLevels(LITERAL_IL_REPEATABLE_READ,
IL_REPEATABLE_READ);
  +    
  +    /** 
  +     * the serializable transactions isolation level.
  +     */
  +    public final static IsolationLevels SERIALIZABLE     = new IsolationLevels(LITERAL_IL_SERIALIZABLE,
IL_SERIALIZABLE);
  +    
  +    /** 
  +     * the optimistic locking isolation level.
  +     */
  +    public final static IsolationLevels OPTIMISTIC       = new IsolationLevels(LITERAL_IL_OPTIMISTIC,
IL_OPTIMISTIC);
  +
  +    /** 
  +     * the default (i.e. uncommited read) isolation level.
  +     */
  +    public final static IsolationLevels DEFAULT = READ_UNCOMMITTED;
  +
  +    /**
  +     * Creates a new enum object.
  +     * 
  +     * @param defaultTextRep The default (un-localized) textual representation
  +     * @param value          The corresponding integer value
  +     */
  +    private IsolationLevels(String defaultTextRep, int value)
  +    {
  +        super(defaultTextRep, value);
  +    }
  +
  +    /**
  +     * Returns the enum value that corresponds to the given (un-localized) textual
  +     * representation.
  +     * 
  +     * @param defaultTextRep The textual representation
  +     * @return The enum value
  +     */
  +    public static IsolationLevels getEnum(String defaultTextRep)
  +    {
  +        return (IsolationLevels)getEnum(IsolationLevels.class, defaultTextRep);
  +    }
  +    
  +    /**
  +     * 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 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);
  +    }
  +
   }
  
  
  
  1.107     +6 -32     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.106
  retrieving revision 1.107
  diff -u -r1.106 -r1.107
  --- ClassDescriptor.java	24 Apr 2005 16:29:10 -0000	1.106
  +++ ClassDescriptor.java	3 Jul 2005 20:32:31 -0000	1.107
  @@ -48,7 +48,7 @@
    * @version $Id$
    */
   public final class ClassDescriptor extends DescriptorBase
  -    implements Serializable, XmlCapable, IsolationLevels
  +    implements Serializable, XmlCapable
   {
   	private boolean useObjectFactory;
   
  @@ -127,7 +127,7 @@
       /**
        * transaction isolation level specified for this class, used in the ODMG server
        */
  -    private int m_IsolationLevel = IsolationLevels.IL_READ_UNCOMMITTED;
  +    private IsolationLevels m_IsolationLevel = IsolationLevels.READ_UNCOMMITTED;
       /**
        * the SQL SCHEMA of the underlying table of this class
        */
  @@ -1343,7 +1343,7 @@
        */
       public int getIsolationLevel()
       {
  -        return m_IsolationLevel;
  +        return m_IsolationLevel.getValue();
       }
   
       /**
  @@ -1352,7 +1352,7 @@
        */
       public void setIsolationLevel(int isoLevel)
       {
  -        m_IsolationLevel = isoLevel;
  +        m_IsolationLevel = IsolationLevels.getEnum(isoLevel);
       }
   
       /**
  @@ -2096,33 +2096,7 @@
   
       private String isolationLevelXml()
       {
  -        switch (this.getIsolationLevel())
  -        {
  -            case (IL_OPTIMISTIC) :
  -                {
  -                    return LITERAL_IL_OPTIMISTIC;
  -                }
  -            case (IL_READ_COMMITTED) :
  -                {
  -                    return LITERAL_IL_READ_COMMITTED;
  -                }
  -            case (IL_READ_UNCOMMITTED) :
  -                {
  -                    return LITERAL_IL_READ_UNCOMMITTED;
  -                }
  -            case (IL_REPEATABLE_READ) :
  -                {
  -                    return LITERAL_IL_REPEATABLE_READ;
  -                }
  -            case (IL_SERIALIZABLE) :
  -                {
  -                    return LITERAL_IL_SERIALIZABLE;
  -                }
  -            default :
  -                {
  -                    return LITERAL_IL_READ_UNCOMMITTED;
  -                }
  -        }
  +        return m_IsolationLevel.getName();
       }
   
   }
  
  
  
  1.69      +6 -27     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.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- RepositoryXmlHandler.java	24 Apr 2005 16:29:10 -0000	1.68
  +++ RepositoryXmlHandler.java	3 Jul 2005 20:32:32 -0000	1.69
  @@ -44,7 +44,7 @@
    */
   public class RepositoryXmlHandler
           extends DefaultHandler
  -        implements RepositoryElements, IsolationLevels
  +        implements RepositoryElements
   {
       private Logger logger = LoggerFactory.getLogger(RepositoryXmlHandler.class);
   
  @@ -61,7 +61,7 @@
       /** holds custom attributes */
       private AttributeContainer m_CurrentAttrContainer;
       /** the default isolation level*/
  -    private int defIsoLevel = IL_DEFAULT;
  +    private IsolationLevels defIsoLevel = IsolationLevels.DEFAULT;
       /** the default proxy prefetching limit*/
       private int defProxyPrefetchingLimit = 50;
       /**
  @@ -185,7 +185,7 @@
                           // set isolation-level attribute
                           String isoLevel = atts.getValue(RepositoryTags.getTagById(ISOLATION_LEVEL));
                           if (isDebug) logger.debug("     " + RepositoryTags.getTagById(ISOLATION_LEVEL)
+ ": " + isoLevel);
  -                        m_CurrentCLD.setIsolationLevel(getIsoLevel(isoLevel));
  +                        m_CurrentCLD.setIsolationLevel(getIsoLevel(isoLevel).getValue());
   
                           // set class attribute
                           String classname = atts.getValue(RepositoryTags.getTagById(CLASS_NAME));
  @@ -1273,35 +1273,14 @@
        * @param isoLevel
        * @return the id
        */
  -    private int getIsoLevel(String isoLevel)
  +    private IsolationLevels getIsoLevel(String isoLevel)
       {
           if(isoLevel == null)
           {
               logger.debug("isolation level is 'null', using default isolation level: " +
defIsoLevel);
               return defIsoLevel;
           }
  -        if (isoLevel.equalsIgnoreCase(LITERAL_IL_READ_UNCOMMITTED))
  -        {
  -            return IL_READ_UNCOMMITTED;
  -        }
  -        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_READ_COMMITTED))
  -        {
  -            return IL_READ_COMMITTED;
  -        }
  -        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_REPEATABLE_READ))
  -        {
  -            return IL_REPEATABLE_READ;
  -        }
  -        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_SERIALIZABLE))
  -        {
  -            return IL_SERIALIZABLE;
  -        }
  -        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_OPTIMISTIC))
  -        {
  -            return IL_OPTIMISTIC;
  -        }
  -        logger.warn("unknown isolation-level: " + isoLevel + " using default isolation
level: " + defIsoLevel);
  -        return defIsoLevel;
  +        return IsolationLevels.getEnum(isoLevel);
       }
   
       private boolean checkString(String str)
  
  
  
  1.62      +6 -26     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.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- DescriptorRepository.java	11 Mar 2005 18:58:56 -0000	1.61
  +++ DescriptorRepository.java	3 Jul 2005 20:32:33 -0000	1.62
  @@ -46,7 +46,7 @@
    * @version $Id$
    */
   public final class DescriptorRepository extends DescriptorBase
  -        implements Serializable, XmlCapable, IsolationLevels
  +        implements Serializable, XmlCapable
   {
       static final long serialVersionUID = -1556339982311359524L;
       /**
  @@ -57,7 +57,7 @@
       /**
        * the default isolation level used for this repository
        */
  -    private int defaultIsolationLevel = IsolationLevels.IL_DEFAULT;
  +    private IsolationLevels defaultIsolationLevel = IsolationLevels.DEFAULT;
       /**
        * This table holds all known Mapping descriptions.
        * Key values are the respective Class objects
  @@ -559,14 +559,14 @@
        */
       public int getDefaultIsolationLevel()
       {
  -        return defaultIsolationLevel;
  +        return defaultIsolationLevel.getValue();
       }
   
       /**
        * Sets the defaultIsolationLevel.
        * @param defaultIsolationLevel The defaultIsolationLevel to set
        */
  -    public void setDefaultIsolationLevel(int defaultIsolationLevel)
  +    public void setDefaultIsolationLevel(IsolationLevels defaultIsolationLevel)
       {
           this.defaultIsolationLevel = defaultIsolationLevel;
       }
  @@ -613,27 +613,7 @@
        */
       protected String getIsolationLevelAsString()
       {
  -        if (defaultIsolationLevel == IL_READ_UNCOMMITTED)
  -        {
  -            return LITERAL_IL_READ_UNCOMMITTED;
  -        }
  -        else if (defaultIsolationLevel == IL_READ_COMMITTED)
  -        {
  -            return LITERAL_IL_READ_COMMITTED;
  -        }
  -        else if (defaultIsolationLevel == IL_REPEATABLE_READ)
  -        {
  -            return LITERAL_IL_REPEATABLE_READ;
  -        }
  -        else if (defaultIsolationLevel == IL_SERIALIZABLE)
  -        {
  -            return LITERAL_IL_SERIALIZABLE;
  -        }
  -        else if (defaultIsolationLevel == IL_OPTIMISTIC)
  -        {
  -            return LITERAL_IL_OPTIMISTIC;
  -        }
  -        return LITERAL_IL_READ_UNCOMMITTED;
  +        return defaultIsolationLevel.getName();
       }
   
       /**
  
  
  
  1.18      +4 -35     db-ojb/src/java/org/apache/ojb/broker/ant/RepositoryVerifierHandler.java
  
  Index: RepositoryVerifierHandler.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/ant/RepositoryVerifierHandler.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- RepositoryVerifierHandler.java	11 Aug 2004 00:42:55 -0000	1.17
  +++ RepositoryVerifierHandler.java	3 Jul 2005 20:32:34 -0000	1.18
  @@ -43,7 +43,7 @@
    */
   public class RepositoryVerifierHandler
       extends DefaultHandler
  -    implements RepositoryElements, IsolationLevels
  +    implements RepositoryElements
   {
       private Logger logger;
   
  @@ -64,7 +64,7 @@
       private boolean m_currentTableExists = false;
   
       /** the default isolation level*/
  -    private int defIsoLevel = IL_DEFAULT;
  +    private IsolationLevels defIsoLevel = IsolationLevels.DEFAULT;
   
       private Collection m_VerifyExceptions = new ArrayList(69);
       private Collection m_VerifyWarnings = new ArrayList(69);
  @@ -141,7 +141,7 @@
                           String defIso = atts.getValue(RepositoryTags.getTagById(ISOLATION_LEVEL));
                           if (defIso != null)
                           {
  -                            defIsoLevel = getIsoLevel(defIso);
  +                            defIsoLevel = IsolationLevels.getEnum(defIso);
                           }
   
                           break;
  @@ -519,37 +519,6 @@
           throw e;
       }
   
  -    /**
  -     * maps IsolationLevel literals to the corresponding id
  -     * @param isoLevel
  -     * @return the id
  -     */
  -    private int getIsoLevel(String isoLevel)
  -    {
  -        if (isoLevel.equalsIgnoreCase(LITERAL_IL_READ_UNCOMMITTED))
  -        {
  -            return IL_READ_UNCOMMITTED;
  -        }
  -        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_READ_COMMITTED))
  -        {
  -            return IL_READ_COMMITTED;
  -        }
  -        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_REPEATABLE_READ))
  -        {
  -            return IL_REPEATABLE_READ;
  -        }
  -        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_SERIALIZABLE))
  -        {
  -            return IL_SERIALIZABLE;
  -        }
  -        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_OPTIMISTIC))
  -        {
  -            return IL_OPTIMISTIC;
  -        }
  -        //logger.warn("unknown isolation-level: " + isoLevel + " using RW_UNCOMMITTED as
default");
  -        return defIsoLevel;
  -    }
  -
   
       public int getErrorCount()
       {
  
  
  
  1.51      +3 -3      db-ojb/.classpath
  
  Index: .classpath
  ===================================================================
  RCS file: /home/cvs/db-ojb/.classpath,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- .classpath	8 May 2005 14:50:50 -0000	1.50
  +++ .classpath	3 Jul 2005 20:32:34 -0000	1.51
  @@ -11,7 +11,6 @@
   	<classpathentry kind="lib" path="lib/commons-beanutils.jar"/>
   	<classpathentry kind="lib" path="lib/commons-logging.jar"/>
   	<classpathentry kind="lib" path="lib/commons-dbcp-1.1.jar"/>
  -	<classpathentry kind="lib" path="lib/commons-lang-2.0.jar"/>
   	<classpathentry kind="lib" path="lib/commons-pool-1.2.jar"/>
   	<classpathentry kind="lib" path="lib/hsqldb.jar"/>
   	<classpathentry kind="lib" path="lib/jakarta-regexp-1.3.jar"/>
  @@ -26,8 +25,6 @@
   	<classpathentry kind="lib" path="lib/prevayler.jar"/>
   	<classpathentry kind="lib" path="lib/antlr-2.7.3.jar"/>
   	<classpathentry kind="lib" path="lib/commons-sql-1.0-dev.jar"/>
  -	<classpathentry kind="lib" path="lib/commons-betwixt-0.5.jar"/>
  -	<classpathentry kind="lib" path="lib/commons-digester-1.5.jar"/>
   	<classpathentry kind="lib" path="lib/picocontainer-1.1.jar"/>
   	<classpathentry kind="lib" path="lib/spring-core.jar"/>
   	<classpathentry kind="lib" path="lib/commons-collections-3.1.jar"/>
  @@ -38,5 +35,8 @@
   	<classpathentry kind="lib" path="lib/xdoclet-1.2.3.jar"/>
   	<classpathentry kind="lib" path="lib/xjavadoc-1.1.jar"/>
   	<classpathentry kind="lib" path="lib/cglib-2.1.jar"/>
  +	<classpathentry kind="lib" path="lib/commons-betwixt-0.7RC2.jar"/>
  +	<classpathentry kind="lib" path="lib/commons-digester-1.7.jar"/>
  +	<classpathentry kind="lib" path="lib/commons-lang-2.1.jar"/>
   	<classpathentry kind="output" path="target/classes/main"/>
   </classpath>
  
  
  

---------------------------------------------------------------------
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