Пример #1
0
 /**
  * INTERNAL: Return the database platform specific information. This allows TopLink to configure
  * certain advanced features for the database desired. NOTE: this must only be used for relational
  * specific usage and will not work for non-relational datasources.
  */
 public DatabasePlatform getPlatform() {
   try {
     return (DatabasePlatform) getDatasourcePlatform();
   } catch (ClassCastException wrongType) {
     throw ValidationException.notSupportedForDatasource();
   }
 }
Пример #2
0
 /**
  * INTERNAL: Set the name of the Platform to be used. Creates a new instance of the specified
  * Class.
  */
 public void setPlatformClassName(String platformClassName) throws ValidationException {
   Class platformClass = null;
   try {
     // First try loading with the Login's class loader
     platformClass = this.getClass().getClassLoader().loadClass(platformClassName);
     Platform platform = null;
     if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
       try {
         platform =
             (Platform)
                 AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(platformClass));
       } catch (PrivilegedActionException exception) {
         throw exception.getException();
       }
     } else {
       platform = (Platform) PrivilegedAccessHelper.newInstanceFromClass(platformClass);
     }
     usePlatform(platform);
   } catch (Exception cne) {
     // next try using ConversionManager
     try {
       platformClass = ConversionManager.loadClass(platformClassName);
       Platform platform = null;
       if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
         try {
           platform =
               (Platform)
                   AccessController.doPrivileged(
                       new PrivilegedNewInstanceFromClass(platformClass));
         } catch (PrivilegedActionException exception) {
           throw ValidationException.platformClassNotFound(
               exception.getException(), platformClassName);
         }
       } else {
         platform = (Platform) PrivilegedAccessHelper.newInstanceFromClass(platformClass);
       }
       usePlatform(platform);
     } catch (Exception cne2) {
       // if still not found, throw exception
       throw ValidationException.platformClassNotFound(cne2, platformClassName);
     }
   }
 }