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/accesslayer/conversions Object2Base64StringFieldConversion.java
Date Fri, 26 Mar 2004 08:47:10 GMT
arminw      2004/03/26 00:47:10

  Modified:    src/java/org/apache/ojb/broker/metadata MetadataManager.java
               src/java/org/apache/ojb/broker/metadata/fieldaccess
                        AbstractPersistentField.java
               src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlSelectMNStatement.java
                        SqlProcedureStatement.java SqlInsertStatement.java
                        SqlExistStatement.java SqlDeleteMNStatement.java
                        SqlDeleteByQuery.java SqlDeleteByPkStatement.java
               src/java/org/apache/ojb/broker/accesslayer/conversions
                        Object2Base64StringFieldConversion.java
  Log:
  - restore some removed javadoc comments (ASL 2.0 update)
  - fix javadoc tags
  
  Revision  Changes    Path
  1.15      +101 -10   db-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java
  
  Index: MetadataManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- MetadataManager.java	11 Mar 2004 18:16:11 -0000	1.14
  +++ MetadataManager.java	26 Mar 2004 08:47:10 -0000	1.15
  @@ -1,5 +1,20 @@
   package org.apache.ojb.broker.metadata;
   
  +/* Copyright  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 org.apache.commons.lang.SerializationUtils;
   import org.apache.ojb.broker.core.PersistenceBrokerConfiguration;
   import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
  @@ -12,19 +27,95 @@
   import java.util.Iterator;
   import java.util.List;
   
  -/* Copyright  2004 The Apache Software Foundation
  +/**
  + * Central class for metadata operations/manipulations - manages OJB's
  + * metadata objects, in particular:
  + * <ul>
  + * <li>{@link org.apache.ojb.broker.metadata.DescriptorRepository} contains
  + * metadata of persistent objects</li>
  + * <li>{@link org.apache.ojb.broker.metadata.ConnectionRepository} contains
  + * all connection metadata information</li>
  + * </ul>
    *
  - * 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
  + * This class allows transparent flexible metadata loading/manipulation at runtime.
    *
  - *     http://www.apache.org/licenses/LICENSE-2.0
  + * <p>
  + * <b>How to read/merge metadata</b><br/>
  + * Per default OJB loads default {@link org.apache.ojb.broker.metadata.DescriptorRepository}
  + * and {@link org.apache.ojb.broker.metadata.ConnectionRepository} instances, by reading
the
  + * specified repository file. This is done first time the <code>MetadataManager</code>
instance
  + * was used.
  + * <br/>
  + * To read metadata information at runtime use
  + * {@link #readDescriptorRepository readDescriptorRepository} and
  + * {@link #readConnectionRepository readConnectionRepository}
  + * methods.
  + * <br/>
  + * It is also possible to merge different repositories using
  + * {@link #mergeDescriptorRepository mergeDescriptorRepository}
  + * and {@link #mergeConnectionRepository mergeConnectionRepository}
    *
  - * 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.
  + * </p>
  + *
  + * <a name="perThread"/>
  + * <h3>Per thread handling of metadata</h3>
  + * <p>
  + * Per default the manager handle one global {@link org.apache.ojb.broker.metadata.DescriptorRepository}
  + * for all calling threads, but it is ditto possible to use different metadata <i>profiles</i>
in a per thread
  + * manner - <i>profiles</i> means different copies of {@link org.apache.ojb.broker.metadata.DescriptorRepository}
  + * objects.
  + * <p/>
  + *
  + * <p>
  + * <a name="enablePerThreadMode"/>
  + * <b>Enable the per thread mode</b><br/>
  + * To enable the 'per thread' mode for {@link org.apache.ojb.broker.metadata.DescriptorRepository}
  + * instances:
  + * <pre>
  + *   MetadataManager mm = MetadataManager.getInstance();
  + *   // tell the manager to use per thread mode
  + *   mm.setEnablePerThreadChanges(true);
  + *   ...
  + * </pre>
  + * This could be done e.g. at start up.<br/>
  + * Now it's possible to use dedicated <code>DescriptorRepository</code> instances
  + * per thread:
  + *  <pre>
  + *   // e.g we get a coppy of the global repository
  + *   DescriptorRepository dr = mm.copyOfGlobalRepository();
  + *   // now we can manipulate the persistent object metadata of the copy
  + *   ......
  + *
  + *   // set the changed repository for this thread
  + *   mm.setDescriptor(dr);
  + *
  + *   // now let this thread lookup a PersistenceBroker instance
  + *   // with the modified metadata
  + *   // all other threads use the global metadata
  + *   PersistenceBroker broker = Persis......
  + * </pre>
  + * Note: Change metadata <i>before</i> lookup the {@link org.apache.ojb.broker.PersistenceBroker}
  + * instance for current thread, because the metadata was bound to the PB at lookup.
  + * </p>
  + *
  + * <p>
  + * <b>How to use different metadata profiles</b><br/>
  + * MetadataManager was shipped with a simple mechanism to
  + * add, remove and load different persistent objects metadata
  + * profiles (different {@link org.apache.ojb.broker.metadata.DescriptorRepository}
  + * instances) in a per thread manner. Use
  + * <ul>
  + * <li>{@link #addProfile addProfile} add different persistent object metadata profiles</li>
  + * <li>{@link #removeProfile removeProfile} remove a persistent object metadata profiles</li>
  + * <li>{@link #loadProfile loadProfile} load a profile for the current thread</li>
  + * </ul>
  + * Note: method {@link #loadProfile loadProfile} only works if
  + * the <a href="#enablePerThreadMode">per thread mode</a> is enabled.
  + * </p>
  + *
  + *
  + * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  + * @version $Id$
    */
   public class MetadataManager
   {
  
  
  
  1.17      +2 -2      db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/AbstractPersistentField.java
  
  Index: AbstractPersistentField.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/AbstractPersistentField.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- AbstractPersistentField.java	24 Mar 2004 17:04:25 -0000	1.16
  +++ AbstractPersistentField.java	26 Mar 2004 08:47:10 -0000	1.17
  @@ -163,7 +163,7 @@
           }
           catch (NoSuchFieldException e)
           {
  -            throw new MetadataException("Can't find member " + fieldname + " in " + c.getName(),
e);
  +            throw new MetadataException("Can't find member '" + fieldname + "' in " + c.getName(),
e);
           }
       }
   
  
  
  
  1.5       +2 -3      db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectMNStatement.java
  
  Index: SqlSelectMNStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectMNStatement.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SqlSelectMNStatement.java	11 Mar 2004 18:16:08 -0000	1.4
  +++ SqlSelectMNStatement.java	26 Mar 2004 08:47:10 -0000	1.5
  @@ -39,7 +39,7 @@
       }
   
       /**
  -     * @see org.apache.ojb.broker.accesslayer.SqlStatement#getStatement()
  +     * @see org.apache.ojb.broker.accesslayer.sql.SqlStatement#getStatement()
        */
       public String getStatement()
       {
  @@ -53,5 +53,4 @@
   
           return stmt.toString();
       }
  -
   }
  
  
  
  1.4       +6 -6      db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlProcedureStatement.java
  
  Index: SqlProcedureStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlProcedureStatement.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SqlProcedureStatement.java	11 Mar 2004 18:16:08 -0000	1.3
  +++ SqlProcedureStatement.java	26 Mar 2004 08:47:10 -0000	1.4
  @@ -20,8 +20,8 @@
   
   /**
    * Model a call to a stored procedure based on ProcedureDescriptors
  - * 
  - * @see org.apache.ojb.broker.metadata.ProcedureDescriptor 
  + *
  + * @see org.apache.ojb.broker.metadata.ProcedureDescriptor
    * @author <a href="mailto:rburt3@mchsi.com">Randall Burt</a>
    * @author <a href="mailto:rgallagh@bellsouth.net">Ron Gallagher</a>
    * @version $Id$
  @@ -42,8 +42,8 @@
   
       /**
        * Create an instance of this object.
  -     * 
  -     * @param procDesc the descriptor that defines the procedure to invoke.
  +     *
  +     * @param procedureDescriptor the descriptor that defines the procedure to invoke.
        * @param logger the logger to utilize
        */
       public SqlProcedureStatement(ProcedureDescriptor procedureDescriptor, Logger logger)
  @@ -57,7 +57,7 @@
        * Get the syntax that is required to invoke the procedure that is defined
        * by the <code>ProcedureDescriptor</code> that was passed to the
        * constructor of this class.
  -     * 
  +     *
        * @see SqlStatement#getStatement()
        */
       public String getStatement()
  
  
  
  1.6       +8 -8      db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlInsertStatement.java
  
  Index: SqlInsertStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlInsertStatement.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SqlInsertStatement.java	11 Mar 2004 18:16:08 -0000	1.5
  +++ SqlInsertStatement.java	26 Mar 2004 08:47:10 -0000	1.6
  @@ -24,7 +24,7 @@
   
   /**
    * Model an INSERT Statement
  - * 
  + *
    * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
    * @version $Id$
    */
  @@ -42,7 +42,7 @@
   	}
   
   	/**
  -	 * @see org.apache.ojb.broker.accesslayer.SqlStatement#getStatement()
  +	 * @see org.apache.ojb.broker.accesslayer.sql.SqlStatement#getStatement()
   	 */
   	public String getStatement()
   	{
  @@ -55,8 +55,8 @@
           appendListOfColumns(cld, stmt);
           stmt.append(")");
           appendListOfValues(cld, stmt);
  -        
  -        return stmt.toString();      
  +
  +        return stmt.toString();
   	}
   
       private List appendListOfColumns(ClassDescriptor cld, StringBuffer buf)
  @@ -76,7 +76,7 @@
           }
           return columnList;
       }
  -    
  +
       /**
        * generates a values(?,) for a prepared insert statement.
        * returns null if there are no fields
  @@ -89,7 +89,7 @@
           if (fields.length == 0)
           {
               return;
  -        }    
  +        }
   
           stmt.append(" VALUES (");
           for (int i = 0; i < fields.length; i++)
  @@ -102,6 +102,6 @@
           }
           stmt.append(") ");
       }
  -    
  +
   }
   
  
  
  
  1.3       +13 -5     db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlExistStatement.java
  
  Index: SqlExistStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlExistStatement.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SqlExistStatement.java	11 Mar 2004 18:16:08 -0000	1.2
  +++ SqlExistStatement.java	26 Mar 2004 08:47:10 -0000	1.3
  @@ -1,10 +1,5 @@
   package org.apache.ojb.broker.accesslayer.sql;
   
  -import org.apache.ojb.broker.OJBRuntimeException;
  -import org.apache.ojb.broker.metadata.ClassDescriptor;
  -import org.apache.ojb.broker.metadata.FieldDescriptor;
  -import org.apache.ojb.broker.util.logging.Logger;
  -
   /* Copyright  2004 The Apache Software Foundation
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
  @@ -18,6 +13,19 @@
    * 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 org.apache.ojb.broker.OJBRuntimeException;
  +import org.apache.ojb.broker.metadata.ClassDescriptor;
  +import org.apache.ojb.broker.metadata.FieldDescriptor;
  +import org.apache.ojb.broker.util.logging.Logger;
  +
  +/**
  + * Generate a select to check existence of an object.
  + * Something like "SELECT id_1 FROM myTable where id_1 = 123 and id_2 = 'kjngzt'".
  + *
  + * @author <a href="mailto:arminw@apache.org">Armin Waibel</a>
  + * @version $Id$
    */
   public class SqlExistStatement extends SqlPkStatement
   {
  
  
  
  1.7       +4 -4      db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlDeleteMNStatement.java
  
  Index: SqlDeleteMNStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlDeleteMNStatement.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SqlDeleteMNStatement.java	11 Mar 2004 18:16:08 -0000	1.6
  +++ SqlDeleteMNStatement.java	26 Mar 2004 08:47:10 -0000	1.7
  @@ -18,8 +18,8 @@
   import org.apache.ojb.broker.util.logging.Logger;
   
   /**
  - * Model an DELETE Statement for M:N indirection table 
  - * 
  + * Model an DELETE Statement for M:N indirection table
  + *
    * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
    * @version $Id$
    */
  @@ -36,7 +36,7 @@
       }
   
       /**
  -     * @see org.apache.ojb.broker.accesslayer.SqlStatement#getStatement()
  +     * @see org.apache.ojb.broker.accesslayer.sql.SqlStatement#getStatement()
        */
       public String getStatement()
       {
  
  
  
  1.14      +5 -5      db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlDeleteByQuery.java
  
  Index: SqlDeleteByQuery.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlDeleteByQuery.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SqlDeleteByQuery.java	11 Mar 2004 18:16:08 -0000	1.13
  +++ SqlDeleteByQuery.java	26 Mar 2004 08:47:10 -0000	1.14
  @@ -42,7 +42,7 @@
   	}
   
   	/**
  -	 * @see org.apache.ojb.broker.accesslayer.SqlStatement#getStatement()
  +	 * @see org.apache.ojb.broker.accesslayer.sql.SqlStatement#getStatement()
   	 */
   	public String getStatement()
   	{
  @@ -67,10 +67,10 @@
           String result;
   
           if (translate)
  -        {     
  +        {
               fld = getFieldDescriptor(aTableAlias, aPathInfo);
           }
  - 
  +
           if (fld != null)
           {
               // BRJ : No alias for delete
  @@ -80,7 +80,7 @@
           {
               result = aPathInfo.column;
           }
  -       
  +
          return result;
      }
   
  
  
  
  1.5       +5 -5      db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlDeleteByPkStatement.java
  
  Index: SqlDeleteByPkStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlDeleteByPkStatement.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SqlDeleteByPkStatement.java	11 Mar 2004 18:16:08 -0000	1.4
  +++ SqlDeleteByPkStatement.java	26 Mar 2004 08:47:10 -0000	1.5
  @@ -20,7 +20,7 @@
   
   /**
    * Model a DELETE Statement
  - * 
  + *
    * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
    * @version $Id$
    */
  @@ -38,17 +38,17 @@
   	}
   
   	/**
  -	 * @see org.apache.ojb.broker.accesslayer.SqlStatement#getStatement()
  +	 * @see org.apache.ojb.broker.accesslayer.sql.SqlStatement#getStatement()
   	 */
   	public String getStatement()
   	{
           StringBuffer stmt = new StringBuffer(1024);
           ClassDescriptor cld = getClassDescriptor();
  -        
  +
           stmt.append("DELETE FROM ");
           appendTable(cld,stmt);
           appendWhereClause(cld, true, stmt); //use Locking
  -        
  +
           return stmt.toString();
   	}
   
  
  
  
  1.7       +21 -11    db-ojb/src/java/org/apache/ojb/broker/accesslayer/conversions/Object2Base64StringFieldConversion.java
  
  Index: Object2Base64StringFieldConversion.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/conversions/Object2Base64StringFieldConversion.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Object2Base64StringFieldConversion.java	11 Mar 2004 18:16:08 -0000	1.6
  +++ Object2Base64StringFieldConversion.java	26 Mar 2004 08:47:10 -0000	1.7
  @@ -1,15 +1,5 @@
   package org.apache.ojb.broker.accesslayer.conversions;
   
  -import java.io.ByteArrayInputStream;
  -import java.io.ByteArrayOutputStream;
  -import java.io.ObjectInputStream;
  -import java.io.ObjectOutputStream;
  -import java.util.zip.GZIPInputStream;
  -import java.util.zip.GZIPOutputStream;
  -
  -import org.apache.ojb.broker.util.Base64;
  -
  -
   /* Copyright  2004 The Apache Software Foundation
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
  @@ -24,6 +14,26 @@
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  +
  +import java.io.ByteArrayInputStream;
  +import java.io.ByteArrayOutputStream;
  +import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
  +import java.util.zip.GZIPInputStream;
  +import java.util.zip.GZIPOutputStream;
  +
  +import org.apache.ojb.broker.util.Base64;
  +
  +/**
  + * this implementation of the FieldConversion interface converts
  + * between java.lang.Objects values and char[] values in the rdbms.
  + * This conversion is useful to store serialized objects in database
  + * columns. For an example have a look at the mapping of
  + * org.apache.ojb.odmg.collections.DlistEntry.
  + *
  + * @author Thomas Mahler, Scott C. Gray
  + * @version $Id$
  + */
   public class Object2Base64StringFieldConversion implements FieldConversion
   {
       private ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
  @@ -48,7 +58,7 @@
                   }
   
                   /*
  -                ** Clear out the byte array 
  +                ** Clear out the byte array
                   */
                   byteOut.reset();
   
  
  
  

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