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/broker/util/sequence HighLowSequence.java SequenceManagerHelper.java SequenceManagerHighLowImpl.java
Date Sat, 03 Sep 2005 18:14:06 GMT
arminw      2005/09/03 11:14:06

  Modified:    src/java/org/apache/ojb/broker/util/sequence
                        HighLowSequence.java SequenceManagerHelper.java
                        SequenceManagerHighLowImpl.java
  Log:
  fix handling of boolean properties, improvements
  
  Revision  Changes    Path
  1.13      +2 -2      db-ojb/src/java/org/apache/ojb/broker/util/sequence/HighLowSequence.java
  
  Index: HighLowSequence.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/HighLowSequence.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- HighLowSequence.java	27 Aug 2005 12:23:16 -0000	1.12
  +++ HighLowSequence.java	3 Sep 2005 18:14:06 -0000	1.13
  @@ -139,7 +139,7 @@
        */
       public long getNextId()
       {
  -        if (curVal == maxKey)
  +        if (curVal >= maxKey)
           {
               //no reserved IDs, must be reloaded, reserve new keyset and saved
               return 0;
  
  
  
  1.23      +8 -8      db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java
  
  Index: SequenceManagerHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHelper.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- SequenceManagerHelper.java	27 Aug 2005 12:23:16 -0000	1.22
  +++ SequenceManagerHelper.java	3 Sep 2005 18:14:06 -0000	1.23
  @@ -20,8 +20,8 @@
   import java.sql.Statement;
   import java.util.Collection;
   import java.util.Iterator;
  -import java.util.Vector;
   import java.util.Properties;
  +import java.util.Vector;
   
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerException;
  @@ -128,7 +128,7 @@
                   /*
                   check for inheritance on multiple table
                   */
  -                cldTargetClass = findInheritanceRoot(brokerForClass, cldTargetClass);
  +                cldTargetClass = findInheritanceRoot(cldTargetClass);
                   Class topLevel = brokerForClass.getTopLevelClass(cldTargetClass.getClassOfObject());
                   ClassDescriptor cldTopLevel = brokerForClass.getClassDescriptor(topLevel);
                   /**
  @@ -206,12 +206,12 @@
        * hierachy of the given descriptor or the descriptor itself if no inheriatance on
multiple table is
        * used.
        */
  -    private static ClassDescriptor findInheritanceRoot(PersistenceBroker broker, ClassDescriptor
cld)
  +    private static ClassDescriptor findInheritanceRoot(ClassDescriptor cld)
       {
           ClassDescriptor result = cld;
           if(cld.getSuperClassDescriptor() != null)
           {
  -            result = findInheritanceRoot(broker, cld.getSuperClassDescriptor());
  +            result = findInheritanceRoot(cld.getSuperClassDescriptor());
           }
           return result;
       }
  @@ -318,7 +318,7 @@
       {
           Platform platform = brokerForClass.serviceConnectionManager().getSupportedPlatform();
           FieldDescriptor field = null;
  -        
  +
           if (!original.getClassDescriptor().equals(cldForOriginalOrExtent))
           {
               // check if extent match not the same table
  @@ -497,7 +497,7 @@
           String result = prop.getProperty(PROP_SEQ_CYCLE, null);
           if(result != null)
           {
  -            return Boolean.getBoolean(result) ? Boolean.TRUE : Boolean.FALSE;
  +            return Boolean.valueOf(result);
           }
           else
           {
  @@ -518,7 +518,7 @@
           String result = prop.getProperty(PROP_SEQ_ORDER, null);
           if(result != null)
           {
  -            return Boolean.getBoolean(result) ? Boolean.TRUE : Boolean.FALSE;
  +            return Boolean.valueOf(result);
           }
           else
           {
  
  
  
  1.34      +16 -12    db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHighLowImpl.java
  
  Index: SequenceManagerHighLowImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerHighLowImpl.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- SequenceManagerHighLowImpl.java	27 Aug 2005 12:23:16 -0000	1.33
  +++ SequenceManagerHighLowImpl.java	3 Sep 2005 18:14:06 -0000	1.34
  @@ -118,6 +118,7 @@
        * sequence name used for global id generation.
        */
       private static final String GLOBAL_SEQUENCE_NAME = "global - default sequence name";
  +    private static final Object sync = new Object();
       public static final String PROPERTY_GRAB_SIZE = "grabSize";
       public static final String PROPERTY_GLOBAL_SEQUENCE_ID = "globalSequenceId";
       public static final String PROPERTY_GLOBAL_SEQUENCE_START = "globalSequenceStart";
  @@ -135,7 +136,7 @@
           Long start = SequenceManagerHelper.getSeqStart(getConfigurationProperties());
           sequenceStart = start != null ? start.longValue() : 1;
           grabSize = Integer.parseInt(getConfigurationProperty(PROPERTY_GRAB_SIZE, "20"));
  -        useGlobalSequenceIdentities = Boolean.getBoolean(getConfigurationProperty(PROPERTY_GLOBAL_SEQUENCE_ID,
"false"));
  +        useGlobalSequenceIdentities = Boolean.valueOf(getConfigurationProperty(PROPERTY_GLOBAL_SEQUENCE_ID,
"false")).booleanValue();
           // support for deprecated properties
           long globalSequenceStart = Long.parseLong(getConfigurationProperty(PROPERTY_GLOBAL_SEQUENCE_START,
"1"));
           if(useGlobalSequenceIdentities && globalSequenceStart > sequenceStart)
  @@ -147,12 +148,13 @@
       protected long getUniqueLong(FieldDescriptor field) throws SequenceManagerException
       {
           HighLowSequence seq;
  +        long id;
  +
           String sequenceName = buildSequenceName(field);
  -        synchronized (SequenceManagerHighLowImpl.class)
  +        synchronized(sync)
           {
               // try to find sequence
               seq = getSequence(sequenceName);
  -
               if (seq == null)
               {
                   // not found, get sequence from database or create new
  @@ -161,7 +163,7 @@
               }
   
               // now we have a sequence
  -            long id = seq.getNextId();
  +            id = seq.getNextId();
               // seq does not have reserved IDs => catch new block of keys
               if (id == 0)
               {
  @@ -180,8 +182,8 @@
                               SystemUtils.LINE_SEPARATOR + "PB: " + getBrokerForClass());
                   }
               }
  -            return id;
           }
  +        return id;
       }
   
       /**
  @@ -218,9 +220,14 @@
           if(mapForDB == null)
           {
               mapForDB = new HashMap();
  +            sequencesMap.put(jcdAlias, mapForDB);
  +        }
  +        HighLowSequence old = (HighLowSequence) mapForDB.put(sequenceName, seq);
  +        if(old != null && old.getMaxKey() > seq.getMaxKey())
  +        {
  +            mapForDB.put(sequenceName, old);
  +            seq.setMaxKey(0);
           }
  -        mapForDB.put(sequenceName, seq);
  -        sequencesMap.put(jcdAlias, mapForDB);
       }
   
       /**
  @@ -235,10 +242,7 @@
                   .serviceConnectionManager().getConnectionDescriptor().getJcdAlias());
           if(mapForDB != null)
           {
  -            synchronized(SequenceManagerHighLowImpl.class)
  -            {
  -                mapForDB.remove(sequenceName);
  -            }
  +            mapForDB.remove(sequenceName);
           }
       }
   
  
  
  

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