db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/otm Kit.java OTMConnection.java OTMKit.java
Date Tue, 01 Jul 2003 21:04:57 GMT
mattbaird    2003/07/01 14:04:57

  Modified:    src/java/org/apache/ojb/otm/core ConcreteEditingContext.java
                        BaseConnection.java
               src/java/org/apache/ojb/otm OTMConnection.java OTMKit.java
  Added:       src/java/org/apache/ojb/otm/core
                        QueryPreparationRuntimeException.java
               src/java/org/apache/ojb/otm Kit.java
  Log:
  new OTM JCA connector support files.
  
  Revision  Changes    Path
  1.17      +53 -47    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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ConcreteEditingContext.java	29 Jun 2003 15:08:03 -0000	1.16
  +++ ConcreteEditingContext.java	1 Jul 2003 21:04:55 -0000	1.17
  @@ -552,15 +552,18 @@
           while (iter.hasNext())
           {
               rds = (ObjectReferenceDescriptor) iter.next();
  -            relObj = rds.getPersistentField().get(object);
  -            if (relObj != null)
  -            {
  -                relOid = new Identity(relObj, _pb);
  -                if (!_order.contains(relOid))
  -                {
  -                    insertInternal(relOid, relObj, LockType.READ_LOCK);
  -                }
  -            }
  +			if (rds.getCascadeStore())
  +			{
  +				relObj = rds.getPersistentField().get(object);
  +				if (relObj != null)
  +				{
  +					relOid = new Identity(relObj, _pb);
  +					if (!_order.contains(relOid))
  +					{
  +						insertInternal(relOid, relObj, LockType.READ_LOCK);
  +					}
  +				}
  +			}
           }
   
           // 1:N relations
  @@ -572,46 +575,49 @@
           while (collections.hasNext())
           {
               collectionDescriptor = (CollectionDescriptor) collections.next();
  -            col = collectionDescriptor.getPersistentField().get(object);
  -            if (col != null)
  -            {
  -                if (col instanceof CollectionProxy)
  -                {
  -                    if (!((CollectionProxy) col).isLoaded())
  -                    {
  -                        continue;
  -                    }
  -                }
  +			if (collectionDescriptor.getCascadeStore())
  +			{
  +				col = collectionDescriptor.getPersistentField().get(object);
  +				if (col != null)
  +				{
  +					if (col instanceof CollectionProxy)
  +					{
  +						if (!((CollectionProxy) col).isLoaded())
  +						{
  +							continue;
  +						}
  +					}
   
  -                if (col instanceof ManageableCollection)
  -                {
  -                    colIterator = ((ManageableCollection) col).ojbIterator();
  -                }
  -                else if (col instanceof Collection)
  -                {
  -                    colIterator = ((Collection) col).iterator();
  -                }
  -                else if (col.getClass().isArray())
  -                {
  -                    colIterator = new ArrayIterator(col);
  -                }
  -                else
  -                {
  -                    throw new OJBRuntimeException(
  -                        col.getClass()
  -                            + " can not be managed by OJB, use Array, Collection or ManageableCollection
instead !");
  -                }
  +					if (col instanceof ManageableCollection)
  +					{
  +						colIterator = ((ManageableCollection) col).ojbIterator();
  +					}
  +					else if (col instanceof Collection)
  +					{
  +						colIterator = ((Collection) col).iterator();
  +					}
  +					else if (col.getClass().isArray())
  +					{
  +						colIterator = new ArrayIterator(col);
  +					}
  +					else
  +					{
  +						throw new OJBRuntimeException(
  +							col.getClass()
  +								+ " can not be managed by OJB, use Array, Collection or ManageableCollection instead
!");
  +					}
   
  -                while (colIterator.hasNext())
  -                {
  -                    relObj = colIterator.next();
  -                    relOid = new Identity(relObj, _pb);
  -                    if (!_order.contains(relOid))
  -                    {
  -                        insertInternal(relOid, relObj, LockType.READ_LOCK);
  -                    }
  -                }
  -            }
  +					while (colIterator.hasNext())
  +					{
  +						relObj = colIterator.next();
  +						relOid = new Identity(relObj, _pb);
  +						if (!_order.contains(relOid))
  +						{
  +							insertInternal(relOid, relObj, LockType.READ_LOCK);
  +						}
  +					}
  +				}
  +			}
           }
       }
   
  
  
  
  1.13      +30 -4     db-ojb/src/java/org/apache/ojb/otm/core/BaseConnection.java
  
  Index: BaseConnection.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/core/BaseConnection.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- BaseConnection.java	29 Jun 2003 15:08:03 -0000	1.12
  +++ BaseConnection.java	1 Jul 2003 21:04:56 -0000	1.13
  @@ -67,6 +67,9 @@
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerFactory;
   import org.apache.ojb.broker.VirtualProxy;
  +import org.apache.ojb.broker.util.configuration.ConfigurationException;
  +import org.apache.ojb.broker.util.configuration.Configurator;
  +import org.apache.ojb.broker.util.ObjectModificationDefaultImpl;
   import org.apache.ojb.broker.accesslayer.IndirectionHandler;
   import org.apache.ojb.broker.accesslayer.OJBIterator;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
  @@ -77,6 +80,9 @@
   import org.apache.ojb.otm.lock.LockManager;
   import org.apache.ojb.otm.lock.LockType;
   import org.apache.ojb.otm.lock.LockingException;
  +import org.apache.ojb.odmg.oql.EnhancedOQLQuery;
  +import org.apache.ojb.odmg.oql.OQLQueryImpl;
  +import org.odmg.ODMGRuntimeException;
   
   /**
    *
  @@ -92,6 +98,7 @@
       private PersistenceBroker _pb;
       private Transaction _tx;
       private ConcreteEditingContext _editingContext;
  +	private Configurator m_configurator;
   
       /**
        * Constructor for BaseConnection.
  @@ -100,7 +107,8 @@
       public BaseConnection(PBKey pbKey)
       {
           _pb = PersistenceBrokerFactory.createPersistenceBroker(pbKey);
  -    }
  +		m_configurator = PersistenceBrokerFactory.getConfigurator();
  +	}
       
       public void close() 
       {
  @@ -162,7 +170,7 @@
       //////////////////////////////////////
   
       /**
  -     * @see org.apache.ojb.otm.OTMConnection#getByIdentity(Identity, int)
  +     * @see org.apache.ojb.otm.OTMConnection#getObjectByIdentity(Identity, int)
        */
       public Object getObjectByIdentity(Identity oid, int lock)
           throws LockingException
  @@ -188,7 +196,7 @@
       }
   
       /**
  -     * @see org.apache.ojb.otm.OTMConnection#getByIdentity(Identity)
  +     * @see org.apache.ojb.otm.OTMConnection#getObjectByIdentity(Identity)
        */
       public Object getObjectByIdentity(Identity oid)
           throws LockingException
  @@ -277,7 +285,7 @@
           throws LockingException
       {
           Identity oid = new Identity(object, _pb);
  -
  +		_pb.store(object, ObjectModificationDefaultImpl.INSERT);
           _editingContext.insert(oid, object, LockType.READ_LOCK);
       }
   
  @@ -297,6 +305,24 @@
           return _editingContext;
       }
   
  +	public EnhancedOQLQuery newOQLQuery()
  +	{
  +		OQLQueryImpl query = new OQLQueryImpl(_pb.getPBKey());
  +        try
  +        {
  +            m_configurator.configure(query);
  +        }
  +        catch (ConfigurationException e)
  +        {
  +            throw new ODMGRuntimeException("Error in configuration of OQLQueryImpl instance:
" + e.getMessage());
  +        }
  +        return query;
  +	}
  +
  +	public int getCount(Query query)
  +	{
  +		return _pb.getCount(query);
  +	}
   
       ///////////////////////////////////////
       // Transaction Notifications
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/otm/core/QueryPreparationRuntimeException.java
  
  Index: QueryPreparationRuntimeException.java
  ===================================================================
  package org.apache.ojb.otm.core;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /**
   *
   *  Error during the creation of a query
   *
   *  @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
   */
  
  public class QueryPreparationRuntimeException extends OTMGenericException
  {
  	public QueryPreparationRuntimeException()
  	{
  	}
  
  	public QueryPreparationRuntimeException(String message)
  	{
  		super(message);
  	}
  }
  
  
  
  1.7       +17 -0     db-ojb/src/java/org/apache/ojb/otm/OTMConnection.java
  
  Index: OTMConnection.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/OTMConnection.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- OTMConnection.java	28 Jun 2003 12:46:54 -0000	1.6
  +++ OTMConnection.java	1 Jul 2003 21:04:56 -0000	1.7
  @@ -56,9 +56,11 @@
   
   import java.util.Iterator;
   import org.apache.ojb.broker.Identity;
  +import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.otm.lock.LockingException;
  +import org.apache.ojb.odmg.oql.EnhancedOQLQuery;
   
   /**
    *
  @@ -189,6 +191,21 @@
        */
       public void invalidate(Identity oid)
               throws LockingException;
  +
  +	/**
  +	 * returns a new OQL Query. This OQL query is Enhanced, meaning it does
  +	 * the ODMG functionality as well as some additional OJB specific, non
  +	 * portable functionality.
  +	 * @return the new OQLQuery
  +	 */
  +	EnhancedOQLQuery newOQLQuery();
  +
  +	/**
  +	 * return the number of objects that would be returned from this query
  +	 * @param query
  +	 * @return the number of objects that would be returned from this query
  +	 */
  +	int getCount(Query query);
   
       /**
        * Close the OTMConnection
  
  
  
  1.7       +1 -1      db-ojb/src/java/org/apache/ojb/otm/OTMKit.java
  
  Index: OTMKit.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/OTMKit.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- OTMKit.java	28 Jun 2003 12:46:54 -0000	1.6
  +++ OTMKit.java	1 Jul 2003 21:04:56 -0000	1.7
  @@ -70,7 +70,7 @@
    * @author <a href="mailto:rraghuram@hotmail.com">Raghu Rajah</a>
    *
    */
  -public abstract class OTMKit
  +public abstract class OTMKit implements Kit
   {
       
       public OTMConnection acquireConnection(PBKey pbKey)
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/otm/Kit.java
  
  Index: Kit.java
  ===================================================================
  package org.apache.ojb.otm;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.ojb.broker.Identity;
  import org.apache.ojb.broker.PBKey;
  import org.apache.ojb.otm.copy.ObjectCopyStrategy;
  import org.apache.ojb.otm.core.Transaction;
  import org.apache.ojb.otm.lock.map.LockMap;
  import org.apache.ojb.otm.lock.wait.LockWaitStrategy;
  import org.apache.ojb.otm.swizzle.Swizzling;
  
  /**
   *
   *  The interface to a configuration Kit
   *
   *  @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
   */
  public interface Kit
  {
  	OTMConnection acquireConnection(PBKey pbKey);
  
  	Transaction getTransaction(OTMConnection conn);
  
  	Swizzling getSwizzlingStrategy();
  
  	LockWaitStrategy getLockWaitStrategy();
  
  	LockMap getLockMap();
  
  	ObjectCopyStrategy getCopyStrategy(Identity oid);
  
  	boolean isImplicitLockingUsed();
  
  }
  
  
  

Mime
View raw message