1 21 package oracle.toplink.essentials.internal.helper; 23 24 import java.security.AccessController ; 25 import java.security.PrivilegedActionException ; 26 27 import oracle.toplink.essentials.Version; 28 import oracle.toplink.essentials.exceptions.ValidationException; 29 import oracle.toplink.essentials.internal.security.PrivilegedAccessHelper; 30 import oracle.toplink.essentials.internal.security.PrivilegedNewInstanceFromClass; 31 import oracle.toplink.essentials.internal.security.PrivilegedClassForName; 32 33 41 public class JavaPlatform { 42 private static JDKPlatform platform = null; 43 44 public static final int FALSE = 0; 46 public static final int TRUE = 1; 47 public static final int UNDEFINED = 2; 48 49 54 private static JDKPlatform getPlatform() { 55 if (platform == null) { 56 if (Version.isJDK15()) { 57 try { 58 Class platformClass = null; 59 if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ 61 try { 62 platformClass = (Class )AccessController.doPrivileged(new PrivilegedClassForName("oracle.toplink.essentials.internal.helper.JDK15Platform")); 63 } catch (PrivilegedActionException exception) { 64 } 65 } else { 66 platformClass = oracle.toplink.essentials.internal.security.PrivilegedAccessHelper.getClassForName("oracle.toplink.essentials.internal.helper.JDK15Platform"); 67 } 68 if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ 69 try { 70 platform = (JDKPlatform)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(platformClass)); 71 } catch (PrivilegedActionException exception) { 72 } 73 } else { 74 platform = (JDKPlatform)PrivilegedAccessHelper.newInstanceFromClass(platformClass); 75 } 76 } catch (Exception exception) { 77 } 78 } 79 if (platform == null) { 80 platform = new JDK15Platform(); 81 } 82 } 83 return platform; 84 } 85 86 94 public static int conformLike(Object left, Object right) { 95 return getPlatform().conformLike(left, right); 96 } 97 98 104 public static long getTimeInMillis(java.util.Calendar calendar) { 105 return getPlatform().getTimeInMillis(calendar); 106 } 107 108 112 public static java.util.Map getQueryCacheMap() { 113 return getPlatform().getQueryCacheMap(); 114 } 115 116 120 public static void setTimeInMillis(java.util.Calendar calendar, long millis) { 121 getPlatform().setTimeInMillis(calendar, millis); 122 } 123 124 130 public static void setExceptionCause(Throwable exception, Throwable cause) { 131 getPlatform().setExceptionCause(exception, cause); 132 } 133 134 141 public static boolean shouldPrintInternalException() { 142 return getPlatform().shouldPrintInternalException(); 143 } 144 } 145 | Popular Tags |