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/core ConcreteEditingContext.java
Date Sat, 01 Oct 2005 13:48:50 GMT
arminw      2005/10/01 06:48:50

  Modified:    src/java/org/apache/ojb/broker/metadata BatchDescriptor.java
                        ClassDescriptor.java
                        ConnectionDescriptorXmlHandler.java JdbcType.java
                        JdbcTypesHelper.java RepositoryElements.java
                        RepositoryTags.java
               src/java/org/apache/ojb/broker/util BrokerHelper.java
                        ClassHelper.java
               src/java/org/apache/ojb/broker ContainerHelper.java
                        PersistenceBroker.java
                        PersistenceBrokerInternal.java
               src/java/org/apache/ojb/odmg ObjectEnvelopeTable.java
               src/java/org/apache/ojb/otm/core ConcreteEditingContext.java
  Added:       src/java/org/apache/ojb/broker/util ExceptionHelper.java
                        ReflectionHelper.java
  Log:
  initial version of the refactored/reworked batch- and statement-handing
  
  Revision  Changes    Path
  1.4       +41 -26    db-ojb/src/java/org/apache/ojb/broker/metadata/BatchDescriptor.java
  
  Index: BatchDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/BatchDescriptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BatchDescriptor.java	27 Aug 2005 12:16:55 -0000	1.3
  +++ BatchDescriptor.java	1 Oct 2005 13:48:49 -0000	1.4
  @@ -4,6 +4,7 @@
   import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.ojb.broker.accesslayer.batch.BatchManagerImpl;
   import org.apache.ojb.broker.accesslayer.batch.BatchStrategyDefaultImpl;
  +import org.apache.ojb.broker.accesslayer.batch.ReturnValueValidatorImpl;
   
   /* Copyright 2002-2004 The Apache Software Foundation
    *
  @@ -30,10 +31,12 @@
   {
       private static final Class DEFAULT_BATCH_MANAGER = BatchManagerImpl.class;
       private static final Class DEFAULT_BATCH_STRATEGY = BatchStrategyDefaultImpl.class;
  +    private static final Class DEFAULT_VALIDATOR = ReturnValueValidatorImpl.class;
       private static final int DEFAULT_BATCH_LIMIT = 50;
   
       private Class batchManager;
       private Class batchStrategy;
  +    private Class returnValueValidator;
       private int batchLimit;
   
       public BatchDescriptor()
  @@ -41,6 +44,7 @@
           this.batchManager = DEFAULT_BATCH_MANAGER;
           this.batchStrategy = DEFAULT_BATCH_STRATEGY;
           this.batchLimit = DEFAULT_BATCH_LIMIT;
  +        this.returnValueValidator = DEFAULT_VALIDATOR;
       }
   
       public Class getBatchManager()
  @@ -73,13 +77,24 @@
           this.batchLimit = batchLimit;
       }
   
  +    public Class getReturnValueValidator()
  +    {
  +        return returnValueValidator;
  +    }
  +
  +    public void setReturnValueValidator(Class returnValueValidator)
  +    {
  +        this.returnValueValidator = returnValueValidator;
  +    }
  +
       public String toString()
       {
           ToStringBuilder buf = new ToStringBuilder(this);
           buf.
  -        append("batch-manager", batchManager).
  -        append("batch-strategy", batchStrategy).
  -        append("batch-limit", batchLimit);
  +                append("batch-manager", batchManager).
  +                append("batch-strategy", batchStrategy).
  +                append("batch-limit", batchLimit).
  +                append("validator", returnValueValidator);
           return buf.toString();
       }
   
  @@ -87,39 +102,39 @@
       {
           String eol = SystemUtils.LINE_SEPARATOR;
   
  -        StringBuffer buf = new StringBuffer( 1024 );
  -        buf.append( eol );
  -        buf.append( "      " );
  -        buf.append( RepositoryTags.getOpeningTagNonClosingById(BATCH) );
  -        buf.append( eol );
  +        StringBuffer buf = new StringBuffer(1024);
  +        buf.append(eol);
  +        buf.append("      ");
  +        buf.append(RepositoryTags.getOpeningTagNonClosingById(BATCH));
  +        buf.append(eol);
           if(getBatchManager() != null)
           {
               buf.append("         ")
                       .append(RepositoryTags.getAttribute(CLASS_NAME, "" + this.getBatchManager().getName()))
  -                    .append( eol );
  +                    .append(eol);
           }
           if(getBatchStrategy() != null)
           {
               buf.append("         ")
                       .append(RepositoryTags.getAttribute(STRATEGY, "" + this.getBatchStrategy().getName()))
  -                    .append( eol );
  +                    .append(eol);
           }
           buf.append("         ").append(RepositoryTags.getAttribute(LIMIT, "" + this.getBatchLimit()));
  -        buf.append( eol );
  -        buf.append( "      >" );
  -        buf.append( eol );
  -        buf.append( "         <!-- " );
  -        buf.append( eol );
  -        buf.append( "         Add sequence manger properties here, using custom attributes"
);
  -        buf.append( eol );
  -        buf.append( "         e.g. <attribute attribute-name=\"grabSize\" attribute-value=\"20\"/>"
);
  -        buf.append( eol );
  -        buf.append( "         -->" );
  -        buf.append( eol );
  -        buf.append( super.toXML("         ") );
  -        buf.append( "      " );
  -        buf.append( RepositoryTags.getClosingTagById(BATCH) );
  -        buf.append( eol );
  +        buf.append(eol);
  +        buf.append("      >");
  +        buf.append(eol);
  +        buf.append("         <!-- ");
  +        buf.append(eol);
  +        buf.append("         Add sequence manger properties here, using custom attributes");
  +        buf.append(eol);
  +        buf.append("         e.g. <attribute attribute-name=\"grabSize\" attribute-value=\"20\"/>");
  +        buf.append(eol);
  +        buf.append("         -->");
  +        buf.append(eol);
  +        buf.append(super.toXML("         "));
  +        buf.append("      ");
  +        buf.append(RepositoryTags.getClosingTagById(BATCH));
  +        buf.append(eol);
           return buf.toString();
       }
   }
  
  
  
  1.113     +1 -16     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.112
  retrieving revision 1.113
  diff -u -r1.112 -r1.113
  --- ClassDescriptor.java	30 Sep 2005 21:45:15 -0000	1.112
  +++ ClassDescriptor.java	1 Oct 2005 13:48:49 -0000	1.113
  @@ -1083,21 +1083,6 @@
       }
   
       /**
  -     * convenience function to get the first primary key
  -     * <p>
  -     * useful when there is only one
  -     */
  -    public FieldDescriptor getPrimaryKey()
  -    {
  -        FieldDescriptor[] fds = getPkFields();
  -        if (fds != null && fds.length > 0)
  -        {
  -            return fds[0];
  -        }
  -        return null;
  -    }
  -
  -    /**
        * return an array of FieldDescription for optimistic locking sorted ascending
        * according to the field-descriptions getOrder() property
        */
  
  
  
  1.18      +8 -1      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ConnectionDescriptorXmlHandler.java	27 Aug 2005 12:16:55 -0000	1.17
  +++ ConnectionDescriptorXmlHandler.java	1 Oct 2005 13:48:49 -0000	1.18
  @@ -221,6 +221,13 @@
                           if (isDebug) logger.debug("     " + RepositoryTags.getTagById(LIMIT)
+ ": " + batchLimit);
                           if(checkString(batchLimit)) batchDescriptor.setBatchLimit(
                                   (new Integer(batchLimit)).intValue());
  +
  +                        // set batch-validator class
  +                        String validator = atts.getValue(RepositoryTags.getTagById(VALIDATOR));
  +                        if (isDebug) logger.debug("     " + RepositoryTags.getTagById(VALIDATOR)
+ ": " + validator);
  +                        if(checkString(validator)) batchDescriptor.setReturnValueValidator(
  +                                ClassHelper.getClass(validator));
  +
                           break;
                       }
                   case CONNECTION_FACTORY:
  
  
  
  1.8       +6 -1      db-ojb/src/java/org/apache/ojb/broker/metadata/JdbcType.java
  
  Index: JdbcType.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/JdbcType.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JdbcType.java	27 Aug 2005 12:16:55 -0000	1.7
  +++ JdbcType.java	1 Oct 2005 13:48:49 -0000	1.8
  @@ -71,6 +71,11 @@
       public int getType();
   
       /**
  +     * Returns the string representing of the {@link java.sql.Types sql type}.
  +     */
  +    public String getTypeAsString();
  +
  +    /**
        * Indicates whether some other object is "equal to" this one.
        */
       public boolean equals(Object obj);
  
  
  
  1.3       +6 -1      db-ojb/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java
  
  Index: JdbcTypesHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JdbcTypesHelper.java	27 Aug 2005 12:16:55 -0000	1.2
  +++ JdbcTypesHelper.java	1 Oct 2005 13:48:49 -0000	1.3
  @@ -284,6 +284,11 @@
               return result;
           }
   
  +        public String getTypeAsString()
  +        {
  +            return getSqlTypeAsString(getType());
  +        }
  +
           public int hashCode()
           {
               return getType();
  
  
  
  1.44      +3 -2      db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java
  
  Index: RepositoryElements.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- RepositoryElements.java	3 Sep 2005 15:28:14 -0000	1.43
  +++ RepositoryElements.java	1 Oct 2005 13:48:49 -0000	1.44
  @@ -156,9 +156,10 @@
       public static final int CREATION_DESCRIPTOR = 126;
       public static final int CREATION_TYPE = 127;
       public static final int CREATION_PARAMETER = 128;
  -    
  +    public static final int VALIDATOR = 129;
  +
       // maintain a next id to keep track where we are
  -    static final int _NEXT = 129;
  +    static final int _NEXT = 130;
   
       // String constants
       public static final String TAG_ACCESS = "access";
  
  
  
  1.44      +1 -0      db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java
  
  Index: RepositoryTags.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- RepositoryTags.java	3 Sep 2005 15:28:14 -0000	1.43
  +++ RepositoryTags.java	1 Oct 2005 13:48:49 -0000	1.44
  @@ -183,6 +183,7 @@
           
           table.put("limit", new Integer(LIMIT));
           table.put("strategy", new Integer(STRATEGY));
  +        table.put("validator", new Integer(VALIDATOR));
           table.put("timeout", new Integer(TIMEOUT));
   
           table.put("creation-descriptor", new Integer(CREATION_DESCRIPTOR));
  
  
  
  1.84      +3 -1      db-ojb/src/java/org/apache/ojb/broker/util/BrokerHelper.java
  
  Index: BrokerHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/BrokerHelper.java,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- BrokerHelper.java	27 Aug 2005 12:23:16 -0000	1.83
  +++ BrokerHelper.java	1 Oct 2005 13:48:50 -0000	1.84
  @@ -405,6 +405,8 @@
               Object cv = fd.getPersistentField().get(obj);
   
               /*
  +            TODO: Separate this "voodoo stuff" in separate method, don't set autoincrement
  +            values in such intransparent manner.
               handle autoincrement attributes if
               - is a autoincrement field
               - field represents a 'null' value, is nullified
  
  
  
  1.18      +1 -33     db-ojb/src/java/org/apache/ojb/broker/util/ClassHelper.java
  
  Index: ClassHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/ClassHelper.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ClassHelper.java	1 Oct 2005 09:20:26 -0000	1.17
  +++ ClassHelper.java	1 Oct 2005 13:48:50 -0000	1.18
  @@ -513,36 +513,4 @@
           }
           return result;
       }
  -
  -    /**
  -     * Use reflection to find a field with given int value and return
  -     * the name of the field.
  -     */
  -    public static String giveAsString(Class target, int value)
  -    {
  -        String fieldValue = " " + value;
  -        try
  -        {
  -            Field[] fields = target.getDeclaredFields();
  -            for (int i = 0; i < fields.length; i++)
  -            {
  -                try
  -                {
  -                    if (fields[i].getInt(null) == value)
  -                    {
  -                        fieldValue = value + " (="+ ClassUtils.getShortClassName(target)
+"."+fields[i].getName()+")";
  -                        break;
  -                    }
  -                }
  -                catch(Exception ignore)
  -                {
  -                }
  -            }
  -        }
  -        catch (Exception ignore)
  -        {
  -            // ignore
  -        }
  -        return fieldValue;
  -    }
   }
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/broker/util/ExceptionHelper.java
  
  Index: ExceptionHelper.java
  ===================================================================
  package org.apache.ojb.broker.util;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.sql.SQLException;
  import java.sql.BatchUpdateException;
  import java.sql.SQLWarning;
  
  import org.apache.commons.lang.SystemUtils;
  import org.apache.commons.lang.exception.ExceptionUtils;
  import org.apache.ojb.broker.KeyConstraintViolatedException;
  import org.apache.ojb.broker.PersistenceBrokerSQLException;
  import org.apache.ojb.broker.core.ValueContainer;
  import org.apache.ojb.broker.metadata.ClassDescriptor;
  import org.apache.ojb.broker.metadata.FieldDescriptor;
  import org.apache.ojb.broker.metadata.JdbcTypesHelper;
  import org.apache.ojb.broker.util.logging.Logger;
  
  /**
   * A helper class which endorse dealing with exceptions.
   *
   * @version $Id: ExceptionHelper.java,v 1.1 2005/10/01 13:48:50 arminw Exp $
   */
  abstract public class ExceptionHelper
  {
      /**
       * Method which support the conversion of {@link java.sql.SQLException} to
       * OJB's runtime exception (with additional message details).
       *
       * @param ex The exception to convert (mandatory).
       * @param sql The used sql-statement or <em>null</em>.
       * @param cld The {@link org.apache.ojb.broker.metadata.ClassDescriptor} of the target
object or <em>null</em>.
       * @param values The values set in prepared statement or <em>null</em>.
       * @param obj The target object or <em>null</em>.
       * @param logger The {@link org.apache.ojb.broker.util.logging.Logger} to log an detailed
message
       * to the specified {@link org.apache.ojb.broker.util.logging.Logger} or <em>null</em>
to skip logging message.
       * @return A new created {@link org.apache.ojb.broker.PersistenceBrokerSQLException}
based on the specified
       *         arguments.
       */
      public static PersistenceBrokerSQLException generateException(SQLException ex,  String
sql, ClassDescriptor cld, ValueContainer[] values, Object obj, Logger logger)
      {
          /*
          X/OPEN codes within class 23:
          23000	INTEGRITY CONSTRAINT VIOLATION
          23001	RESTRICT VIOLATION
          23502	NOT NULL VIOLATION
          23503	FOREIGN KEY VIOLATION
          23505	UNIQUE VIOLATION
          23514	CHECK VIOLATION
          */
          String eol = SystemUtils.LINE_SEPARATOR;
          StringBuffer msg = new StringBuffer(eol);
  
          if(ex instanceof BatchUpdateException)
          {
              BatchUpdateException tmp = (BatchUpdateException) ex;
              msg.append("BatchUpdateException during execution.");
              msg.append(eol).append("Batch update count is '").append(tmp.getUpdateCounts()).append("'");
          }
          else if(ex instanceof SQLWarning)
          {
              msg.append("SQLWarning during execution.");
          }
          else
          {
              msg.append("SQLException during execution.");
          }
  
          if(sql != null)
          {
              msg.append(eol).append("sql statement was '").append(sql).append("'.");
          }
          msg.append(eol).append("Exception message is [").append(ex.getMessage()).append("]");
          msg.append(eol).append("Vendor error code [").append(ex.getErrorCode()).append("]");
          msg.append(eol).append("SQL state code [");
  
          String stateCode = ex.getSQLState();
          if("23000".equalsIgnoreCase(stateCode)) msg.append(stateCode).append("=INTEGRITY
CONSTRAINT VIOLATION");
          else if("23001".equalsIgnoreCase(stateCode)) msg.append(stateCode).append("=RESTRICT
VIOLATION");
          else if("23502".equalsIgnoreCase(stateCode)) msg.append(stateCode).append("=NOT
NULL VIOLATION");
          else if("23503".equalsIgnoreCase(stateCode)) msg.append(stateCode).append("=FOREIGN
KEY VIOLATION");
          else if("23505".equalsIgnoreCase(stateCode)) msg.append(stateCode).append("=UNIQUE
VIOLATION");
          else if("23514".equalsIgnoreCase(stateCode)) msg.append(stateCode).append("=CHECK
VIOLATION");
          else msg.append(stateCode);
          msg.append("]");
  
          if(cld != null)
          {
              msg.append(eol).append("Target class is '")
                      .append(cld.getClassNameOfObject())
                      .append("'.");
              FieldDescriptor[] fields = cld.getPkFields();
              msg.append(eol).append("PK of the target object is [");
              for(int i = 0; i < fields.length; i++)
              {
                  try
                  {
                      if(i > 0) msg.append(", ");
                      msg.append(fields[i].getPersistentField().getName());
                      if(obj != null)
                      {
                          msg.append("=");
                          msg.append(fields[i].getPersistentField().get(obj));
                      }
                  }
                  catch(Exception ignore)
                  {
                  }
              }
              msg.append("].");
          }
          if(values != null)
          {
              msg.append(eol).append(values.length).append(" values performed in statement:
").append(eol);
              for(int i = 0; i < values.length; i++)
              {
                  ValueContainer value = values[i];
                  msg.append("[");
                  msg.append("jdbcType=").append(JdbcTypesHelper.getSqlTypeAsString(value.getJdbcType().getType()));
                  msg.append(", value=").append(value.getValue());
                  msg.append("]");
              }
          }
          if(obj != null) msg.append(eol).append("Source object: ").append(obj);
  
          // message string for PB exception
          String shortMsg = msg.toString();
  
          // add causing stack trace
          Throwable rootCause = ExceptionUtils.getRootCause(ex);
          if(rootCause  != null)
          {
              msg.append(eol).append("The root cause stack is: ");
              String rootStack = ExceptionUtils.getStackTrace(rootCause);
              msg.append(eol).append(rootStack);
          }
  
          // log error message
          if(logger != null) logger.error(msg.toString(), ex);
  
          // throw a specific type of runtime exception for a key constraint.
          if("23000".equals(stateCode) || "23505".equals(stateCode))
          {
              throw new KeyConstraintViolatedException(shortMsg, ex);
          }
          else
          {
              throw new PersistenceBrokerSQLException(shortMsg, ex);
          }
      }
  }
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/broker/util/ReflectionHelper.java
  
  Index: ReflectionHelper.java
  ===================================================================
  package org.apache.ojb.broker.util;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.lang.Object;
  import java.lang.reflect.Field;
  
  /**
   * Utility class.
   *
   * @version $Id: ReflectionHelper.java,v 1.1 2005/10/01 13:48:50 arminw Exp $
   */
  abstract public class ReflectionHelper
  {
      /**
       * This method try to find a public field with specified int value
       * and return the field name of the field.
       *
       * @param source The source class to look for the field.
       * @param constant The constant value defined in source class.
       * @return The field name of the constant or if not found the
       * specified constant as string wrapped by apostrophe.
       */
      public static String reflectNameFor(Class source, int constant)
      {
          String statusName = "'" + constant + "'";
          try
          {
              Field[] fields = source.getDeclaredFields();
              for (int i = 0; i < fields.length; i++)
              {
                  Field fld = fields[i];
                  if (fld.getInt(null) == constant)
                  {
                      statusName = fld.getName();
                      break;
                  }
              }
          }
          catch (Exception ignore)
          {
          }
          return statusName;
      }
  }
  
  
  
  1.10      +13 -8     db-ojb/src/java/org/apache/ojb/broker/ContainerHelper.java
  
  Index: ContainerHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/ContainerHelper.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ContainerHelper.java	6 Sep 2005 22:19:20 -0000	1.9
  +++ ContainerHelper.java	1 Oct 2005 13:48:50 -0000	1.10
  @@ -40,11 +40,13 @@
   import org.apache.ojb.broker.accesslayer.batch.BatchManagerImpl;
   import org.apache.ojb.broker.accesslayer.batch.BatchStrategy;
   import org.apache.ojb.broker.accesslayer.batch.BatchStrategyDefaultImpl;
  +import org.apache.ojb.broker.accesslayer.batch.ReturnValueValidator;
  +import org.apache.ojb.broker.accesslayer.batch.ReturnValueValidatorImpl;
   import org.apache.ojb.broker.accesslayer.sql.SqlGenerator;
   import org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl;
   import org.apache.ojb.broker.cache.SessionCache;
   import org.apache.ojb.broker.core.IdentityFactoryImpl;
  -import org.apache.ojb.broker.core.PBPoolInfo;
  +import org.apache.ojb.broker.core.PBPoolConfiguration;
   import org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl;
   import org.apache.ojb.broker.core.PersistenceBrokerFactoryIF;
   import org.apache.ojb.broker.core.PersistenceBrokerImpl;
  @@ -122,17 +124,17 @@
                               PersistenceBroker.class.getName() + ".class");
           
           _translationMap.put("maxActive",
  -                            PBPoolInfo.class.getName() + ".maxActive");
  +                            PBPoolConfiguration.class.getName() + ".maxActive");
           _translationMap.put("maxIdle",
  -                            PBPoolInfo.class.getName() + ".maxIdle");
  +                            PBPoolConfiguration.class.getName() + ".maxIdle");
           _translationMap.put("maxWait",
  -                            PBPoolInfo.class.getName() + ".maxWait");
  +                            PBPoolConfiguration.class.getName() + ".maxWait");
           _translationMap.put("timeBetweenEvictionRunsMillis",
  -                            PBPoolInfo.class.getName() + ".timeBetweenEvictionRunsMillis");
  +                            PBPoolConfiguration.class.getName() + ".timeBetweenEvictionRunsMillis");
           _translationMap.put("minEvictableIdleTimeMillis",
  -                            PBPoolInfo.class.getName() + ".minEvictableIdleTimeMillis");
  +                            PBPoolConfiguration.class.getName() + ".minEvictableIdleTimeMillis");
           _translationMap.put("whenExhaustedAction",
  -                            PBPoolInfo.class.getName() + ".whenExhaustedAction");
  +                            PBPoolConfiguration.class.getName() + ".whenExhaustedAction");
   
           _translationMap.put("ConnectionManagerClass",
                               ConnectionManagerIF.class.getName() + ".class");
  @@ -156,6 +158,8 @@
                               StatementManager.class.getName() + ".class");
           _translationMap.put("JdbcAccessClass",
                               JdbcAccess.class.getName() + ".class");
  +        _translationMap.put("BatchManagerClass",
  +                            BatchManager.class.getName() + ".class");
           _translationMap.put("RowReaderDefaultClass",
                               RowReader.class.getName() + ".class");
           _translationMap.put("IdentityFactoryClass",
  @@ -234,6 +238,7 @@
           // setting default types
           container.ensureImplementationClass(BatchManager.class, BatchManagerImpl.class);
           container.ensureImplementationClass(BatchStrategy.class, BatchStrategyDefaultImpl.class);
  +        container.ensureImplementationClass(ReturnValueValidator.class, ReturnValueValidatorImpl.class);
           container.ensureImplementationClass(CollectionFactory.class, CollectionFactoryDefaultImpl.class);
           container.ensureImplementationClass(CollectionProxy.class, CollectionProxyDefaultImpl.class);
           container.ensureImplementationClass(ConnectionFactory.class, ConnectionFactoryPooledImpl.class);
  @@ -250,7 +255,7 @@
           container.ensureImplementationClass(PersistenceBroker.class, PersistenceBrokerImpl.class);
           container.ensureImplementationClass(PersistenceBrokerFactoryIF.class, PersistenceBrokerFactoryDefaultImpl.class);
           container.ensureImplementationClass(PersistentField.class, PersistentFieldDirectImpl.class);
  -        container.ensureImplementationClass(PBPoolInfo.class, PBPoolInfo.class);
  +        container.ensureImplementationClass(PBPoolConfiguration.class, PBPoolConfiguration.class);
           container.ensureImplementationClass(ProxyFactory.class,ProxyFactoryJDKImpl.class);
           container.ensureImplementationClass(RowReader.class, RowReaderDefaultImpl.class);
           container.ensureImplementationClass(SequenceManager.class, SequenceManagerHighLowImpl.class);
  
  
  
  1.40      +9 -1      db-ojb/src/java/org/apache/ojb/broker/PersistenceBroker.java
  
  Index: PersistenceBroker.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/PersistenceBroker.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- PersistenceBroker.java	30 Sep 2005 21:45:14 -0000	1.39
  +++ PersistenceBroker.java	1 Oct 2005 13:48:50 -0000	1.40
  @@ -21,6 +21,7 @@
   import org.apache.ojb.broker.accesslayer.JdbcAccess;
   import org.apache.ojb.broker.accesslayer.OJBIterator;
   import org.apache.ojb.broker.accesslayer.StatementManager;
  +import org.apache.ojb.broker.accesslayer.batch.BatchManager;
   import org.apache.ojb.broker.accesslayer.sql.SqlGenerator;
   import org.apache.ojb.broker.cache.ObjectCache;
   import org.apache.ojb.broker.cache.SessionCache;
  @@ -69,6 +70,13 @@
       public JdbcAccess serviceJdbcAccess();
   
       /**
  +     * Returns the batch manager used by this broker.
  +     *
  +     * @return The batch manager
  +     */
  +    public BatchManager serviceBatchManager();
  +
  +    /**
        * Returns the {@link org.apache.ojb.broker.util.sequence.SequenceManager} instance
associated with this broker.
        */
       public SequenceManager serviceSequenceManager();
  
  
  
  1.11      +2 -10     db-ojb/src/java/org/apache/ojb/broker/PersistenceBrokerInternal.java
  
  Index: PersistenceBrokerInternal.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/PersistenceBrokerInternal.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PersistenceBrokerInternal.java	30 Sep 2005 21:45:14 -0000	1.10
  +++ PersistenceBrokerInternal.java	1 Oct 2005 13:48:50 -0000	1.11
  @@ -3,9 +3,8 @@
   import java.util.Map;
   
   import org.apache.ojb.broker.accesslayer.CollectionCreationContext;
  -import org.apache.ojb.broker.accesslayer.RowReader;
   import org.apache.ojb.broker.accesslayer.RelationshipPrefetcherFactory;
  -import org.apache.ojb.broker.accesslayer.batch.BatchManager;
  +import org.apache.ojb.broker.accesslayer.RowReader;
   import org.apache.ojb.broker.core.QueryReferenceBroker;
   import org.apache.ojb.broker.core.proxy.ProxyFactory;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
  @@ -46,13 +45,6 @@
       public RowReader getRowReaderFor(ClassDescriptor classDesc);
   
       /**
  -     * Returns the batch manager used by this broker.
  -     * 
  -     * @return The batch manager
  -     */
  -    public BatchManager getBatchManager();
  -
  -    /**
        * Returns the proxy factory used by this broker.
        * 
        * @return The factory
  
  
  
  1.47      +5 -5      db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelopeTable.java
  
  Index: ObjectEnvelopeTable.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelopeTable.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- ObjectEnvelopeTable.java	9 Sep 2005 00:35:11 -0000	1.46
  +++ ObjectEnvelopeTable.java	1 Oct 2005 13:48:50 -0000	1.47
  @@ -134,7 +134,7 @@
       {
           PersistenceBroker broker = transaction.getBroker();
           ConnectionManagerIF connMan = broker.serviceConnectionManager();
  -        boolean saveBatchMode = connMan.isBatchMode();
  +        boolean saveBatchMode = broker.serviceBatchManager().isBatchMode();
   
           try
           {
  @@ -159,7 +159,7 @@
               // written into the database.
   
               // 0. turn on the batch mode
  -            connMan.setBatchMode(true);
  +            broker.serviceBatchManager().setBatchMode(true);
   
               // 1. mark objects no longer available in collection
               // for delete and add new found objects
  @@ -185,7 +185,7 @@
               writeAllEnvelopes(reuse);
   
               // 6. execute batch
  -            connMan.executeBatch();
  +            broker.serviceBatchManager().executeBatch();
   
               // 7. Update all Envelopes to new CleanState
               prepareForReuse(reuse);
  @@ -196,7 +196,7 @@
           }
           catch (Exception e)
           {
  -            connMan.clearBatch();
  +            broker.serviceBatchManager().cancelBatch();
               /*
               arminw:
               log only a warn message, because in top-level methods
  @@ -225,7 +225,7 @@
           finally
           {
               needsCommit = false;
  -            connMan.setBatchMode(saveBatchMode);
  +            broker.serviceBatchManager().setBatchMode(saveBatchMode);
           }
       }
   
  
  
  
  1.59      +4 -4      db-ojb/src/java/org/apache/ojb/otm/core/ConcreteEditingContext.java
  
  Index: ConcreteEditingContext.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/core/ConcreteEditingContext.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- ConcreteEditingContext.java	27 Aug 2005 12:29:03 -0000	1.58
  +++ ConcreteEditingContext.java	1 Oct 2005 13:48:50 -0000	1.59
  @@ -578,7 +578,7 @@
           removeCollectionProxyListeners();
   
           ConnectionManagerIF connMan = _pb.serviceConnectionManager();
  -        boolean saveBatchMode = connMan.isBatchMode();
  +        boolean saveBatchMode = _pb.serviceBatchManager().isBatchMode();
           Swizzling swizzlingStrategy = _tx.getKit().getSwizzlingStrategy();
           LockManager lockManager = LockManager.getInstance();
           Identity[] lockOrder = (Identity[]) _order.toArray(new Identity[_order.size()]);
  @@ -748,7 +748,7 @@
               while (countCascadeDeleted > 0);
   
               // perform database operations
  -            connMan.setBatchMode(true);
  +            _pb.serviceBatchManager().setBatchMode(true);
               try
               {
                   for (Iterator it = _order.iterator(); it.hasNext(); )
  @@ -792,11 +792,11 @@
                       }
                       entry.state = state.commit();
                   }
  -                connMan.executeBatch();
  +                _pb.serviceBatchManager().executeBatch();
               }
               finally
               {
  -                connMan.setBatchMode(saveBatchMode);
  +                _pb.serviceBatchManager().setBatchMode(saveBatchMode);
               }
           } catch (Throwable ex) {
               ex.printStackTrace();
  
  
  

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