db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/singlevm PersistenceBrokerImpl.java
Date Tue, 15 Apr 2003 19:18:51 GMT
brj         2003/04/15 12:18:50

  Modified:    src/java/org/apache/ojb/broker/singlevm
                        PersistenceBrokerImpl.java
  Added:       src/java/org/apache/ojb/broker/accesslayer SetProxy.java
  Log:
  additional SetProxy to support proxied ManageableHashSet
  
  Revision  Changes    Path
  1.1                  db-ojb/src/java/org/apache/ojb/broker/accesslayer/SetProxy.java
  
  Index: SetProxy.java
  ===================================================================
  package org.apache.ojb.broker.accesslayer;
  
  /* ====================================================================
   * 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 java.util.Collection;
  import java.util.Set;
  
  import org.apache.ojb.broker.PBKey;
  import org.apache.ojb.broker.PersistenceBrokerException;
  import org.apache.ojb.broker.query.Query;
  import org.apache.ojb.broker.util.collections.ManageableArrayList;
  
  /**
   * SetProxy. <br> A placeHolder for a whole set to support deferred loading of
   * relationships. The complete relationship is loaded on request.
   * 
   * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
   * @version $Id: SetProxy.java,v 1.1 2003/04/15 19:18:49 brj Exp $
   */
  public class SetProxy extends CollectionProxy implements Set
  {
  
  	/**
  	 * Constructor for ListProxy.
  	 * @param aKey
  	 * @param aQuery
  	 */
  	public SetProxy(PBKey aKey, Query aQuery)
  	{
  		this(aKey, ManageableArrayList.class, aQuery);
  	}
  
  	/**
  	 * Constructor for ListProxy.
  	 * @param aKey
  	 * @param aCollClass
  	 * @param aQuery
  	 */
  	public SetProxy(PBKey aKey, Class aCollClass, Query aQuery)
  	{
  		super(aKey, aCollClass, aQuery);
  	}
  
      protected Set getSetData()
      {
          return (Set)super.getData();    
      }
      
  	/**
  	 * @see org.apache.ojb.broker.accesslayer.CollectionProxy#loadData()
  	 */
  	protected Collection loadData() throws PersistenceBrokerException
  	{
          Collection result = super.loadData();
  
          if (result instanceof Set)
          {
              return result;
          }    
          else
          {
              throw new PersistenceBrokerException("loaded data does not implement java.util.Set");
          }
  		
  	}
  
  }
  
  
  
  1.154     +9 -15     db-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerImpl.java,v
  retrieving revision 1.153
  retrieving revision 1.154
  diff -u -r1.153 -r1.154
  --- PersistenceBrokerImpl.java	12 Apr 2003 23:24:41 -0000	1.153
  +++ PersistenceBrokerImpl.java	15 Apr 2003 19:18:49 -0000	1.154
  @@ -55,24 +55,16 @@
    */
   
   import java.lang.reflect.Array;
  +import java.lang.reflect.Proxy;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Enumeration;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Set;
   import java.util.Vector;
   
  -import org.apache.ojb.broker.Identity;
  -import org.apache.ojb.broker.ManageableCollection;
  -import org.apache.ojb.broker.OJBRuntimeException;
  -import org.apache.ojb.broker.PBKey;
  -import org.apache.ojb.broker.PBState;
  -import org.apache.ojb.broker.PersistenceBrokerAware;
  -import org.apache.ojb.broker.PersistenceBrokerException;
  -import org.apache.ojb.broker.TransactionAbortedException;
  -import org.apache.ojb.broker.TransactionInProgressException;
  -import org.apache.ojb.broker.TransactionNotInProgressException;
  -import org.apache.ojb.broker.VirtualProxy;
  +import org.apache.ojb.broker.*;
   import org.apache.ojb.broker.accesslayer.*;
   import org.apache.ojb.broker.accesslayer.sql.SqlGenerator;
   import org.apache.ojb.broker.accesslayer.sql.SqlGeneratorFactory;
  @@ -109,9 +101,6 @@
   import org.apache.ojb.broker.util.sequence.SequenceManager;
   import org.apache.ojb.broker.util.sequence.SequenceManagerException;
   import org.apache.ojb.broker.util.sequence.SequenceManagerFactory;
  -
  -//#ifdef JDK13
  -import java.lang.reflect.Proxy;
   //#else
   /*
   import com.develop.java.lang.reflect.Proxy;
  @@ -1448,6 +1437,11 @@
   		{
   		    return ListProxy.class;
   		}
  +
  +        if (Set.class.isAssignableFrom(collectionClass))
  +        {
  +            return SetProxy.class;
  +        }
   
           return CollectionProxy.class;
   	}
  
  
  

Mime
View raw message