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/copy MetadataObjectCopyStrategy.java ReflectiveObjectCopyStrategy.java
Date Tue, 29 Jul 2003 16:51:58 GMT
mattbaird    2003/07/29 09:51:57

  Modified:    src/java/org/apache/ojb/otm/copy
                        MetadataObjectCopyStrategy.java
                        ReflectiveObjectCopyStrategy.java
  Added:       src/java/org/apache/ojb/otm/util IdentityMapFactory.java
  Log:
  codeswitcher doesn't really work worth beans, used a different way to get around it.
  
  Revision  Changes    Path
  1.1                  db-ojb/src/java/org/apache/ojb/otm/util/IdentityMapFactory.java
  
  Index: IdentityMapFactory.java
  ===================================================================
  package org.apache.ojb.otm.util;
  
  import java.util.Map;
  
  /**
   * Created by IntelliJ IDEA.
   * User: matthew.baird
   * Date: Jul 29, 2003
   * Time: 9:16:27 AM
   * To change this template use Options | File Templates.
   */
  public final class IdentityMapFactory
  {
  	private static boolean HAS_JDK_IDENTITY_MAP = true;
  	private static final String CLASS_NAME = "java.util.IdentityHashMap";
  	private static Class JDK_IDENTITY_MAP;
  
  	static
  	{
  		try
  		{
  			JDK_IDENTITY_MAP = Thread.currentThread().getContextClassLoader().loadClass(CLASS_NAME);
  		}
  		catch (ClassNotFoundException e)
  		{
  			HAS_JDK_IDENTITY_MAP = false;
  		}
  	}
  	
  	private IdentityMapFactory() {}
  
  	public static Map getIdentityMap()
  	{
  		Map retval = null;
  		if (HAS_JDK_IDENTITY_MAP)
  		{
  			try
  			{
  				retval = (Map) JDK_IDENTITY_MAP.newInstance();
  			}
  			catch (InstantiationException e)
  			{
  				HAS_JDK_IDENTITY_MAP = false;
  			}
  			catch (IllegalAccessException e)
  			{
  				HAS_JDK_IDENTITY_MAP = false;
  			}
  		}
  		if (!HAS_JDK_IDENTITY_MAP)
  		{
  			retval = new org.apache.ojb.otm.util.IdentityHashMap();
  		}
  		return retval;
  	}
  }
  
  
  
  1.9       +3 -4      db-ojb/src/java/org/apache/ojb/otm/copy/MetadataObjectCopyStrategy.java
  
  Index: MetadataObjectCopyStrategy.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/copy/MetadataObjectCopyStrategy.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MetadataObjectCopyStrategy.java	25 Jul 2003 00:22:00 -0000	1.8
  +++ MetadataObjectCopyStrategy.java	29 Jul 2003 16:51:57 -0000	1.9
  @@ -59,18 +59,17 @@
   import org.apache.ojb.broker.accesslayer.CollectionProxy;
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.util.ConstructorHelper;
  +import org.apache.ojb.otm.util.IdentityMapFactory;
   
   import java.lang.reflect.Constructor;
   import java.util.Map;
   import java.util.Collection;
   import java.util.Iterator;
   
  -//#ifdef JDK14
  -import java.util.IdentityHashMap;
  +//#ifdef JDK13
   import java.lang.reflect.Proxy;
   //#else
   /*
  -import org.apache.ojb.otm.util.IdentityHashMap;
   import com.develop.java.lang.reflect.Proxy;
   */
   //#endif
  @@ -97,7 +96,7 @@
        */
       public Object copy(final Object obj, final PersistenceBroker broker)
       {
  -        return clone(obj, new IdentityHashMap(), broker);
  +        return clone(obj, IdentityMapFactory.getIdentityMap(), broker);
       }
   
       private static Object clone(final Object toCopy, final Map objMap, final PersistenceBroker
broker)
  
  
  
  1.9       +2 -8      db-ojb/src/java/org/apache/ojb/otm/copy/ReflectiveObjectCopyStrategy.java
  
  Index: ReflectiveObjectCopyStrategy.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/copy/ReflectiveObjectCopyStrategy.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ReflectiveObjectCopyStrategy.java	11 Jul 2003 17:21:42 -0000	1.8
  +++ ReflectiveObjectCopyStrategy.java	29 Jul 2003 16:51:57 -0000	1.9
  @@ -55,6 +55,7 @@
    */
   
   import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.otm.util.IdentityMapFactory;
   
   import java.lang.reflect.Array;
   import java.lang.reflect.Constructor;
  @@ -64,13 +65,6 @@
   import java.util.HashSet;
   import java.util.Map;
   import java.util.Set;
  -//#ifdef JDK14
  -import java.util.IdentityHashMap;
  -//#else
  -/*
  -import org.apache.ojb.otm.util.IdentityHashMap;
  -*/
  -//#endif
   
   /**
    * User: matthew.baird
  @@ -105,7 +99,7 @@
   	 */
   	public final Object copy(final Object toCopy, final PersistenceBroker broker)
   	{
  -		return clone(toCopy, new IdentityHashMap(), new HashMap());
  +		return clone(toCopy, IdentityMapFactory.getIdentityMap(), new HashMap());
   	}
   	/*
   	 * class used to cache class metadata info
  
  
  

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