1 package org.apache.ojb.broker.util; 2 3 17 18 import java.util.Map ; 19 20 public final class IdentityMapFactory 21 { 22 private static boolean HAS_JDK_IDENTITY_MAP = true; 23 private static final String CLASS_NAME = "java.util.IdentityHashMap"; 24 private static Class JDK_IDENTITY_MAP; 25 26 static 27 { 28 try 29 { 30 JDK_IDENTITY_MAP = ClassHelper.getClassLoader().loadClass(CLASS_NAME); 31 } 32 catch (ClassNotFoundException e) 33 { 34 HAS_JDK_IDENTITY_MAP = false; 35 } 36 } 37 38 private IdentityMapFactory() {} 39 40 public static Map getIdentityMap() 41 { 42 Map retval = null; 43 if (HAS_JDK_IDENTITY_MAP) 44 { 45 try 46 { 47 retval = (Map ) JDK_IDENTITY_MAP.newInstance(); 48 } 49 catch (InstantiationException e) 50 { 51 HAS_JDK_IDENTITY_MAP = false; 52 } 53 catch (IllegalAccessException e) 54 { 55 HAS_JDK_IDENTITY_MAP = false; 56 } 57 } 58 if (!HAS_JDK_IDENTITY_MAP) 59 { 60 retval = new org.apache.ojb.broker.util.IdentityHashMap(); 61 } 62 return retval; 63 } 64 } 65 | Popular Tags |