/**
  * INTERNAL: Convert all the class-name-based settings to actual class-based settings. This method
  * is used when converting a project that has been built with class names to a project with
  * classes.
  */
 public void convertClassNamesToClasses(ClassLoader classLoader) {
   if (getPartitioningClasName() == null) {
     setPartitioningClasName("");
   }
   try {
     if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
       Class partitioningClass =
           (Class)
               AccessController.doPrivileged(
                   new PrivilegedClassForName(getPartitioningClasName(), true, classLoader));
       this.policy =
           (PartitioningPolicy)
               AccessController.doPrivileged(
                   new PrivilegedNewInstanceFromClass(partitioningClass));
     } else {
       Class partitioningClass =
           PrivilegedAccessHelper.getClassForName(getPartitioningClasName(), true, classLoader);
       this.policy =
           (PartitioningPolicy) PrivilegedAccessHelper.newInstanceFromClass(partitioningClass);
     }
   } catch (PrivilegedActionException exception) {
     throw ValidationException.classNotFoundWhileConvertingClassNames(
         getPartitioningClasName(), exception.getException());
   } catch (ClassNotFoundException exception) {
     throw ValidationException.classNotFoundWhileConvertingClassNames(
         getPartitioningClasName(), exception);
   } catch (IllegalAccessException exception) {
     throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(
         getPartitioningClasName(), exception);
   } catch (InstantiationException exception) {
     throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(
         getPartitioningClasName(), exception);
   }
 }
Esempio n. 2
0
  /** INTERNAL: Return a new instance of the class provided. */
  public Object getClassInstance(Class cls) {
    if (cls != null) {
      try {
        if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
          return AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(cls));
        } else {
          return org.eclipse.persistence.internal.security.PrivilegedAccessHelper
              .newInstanceFromClass(cls);
        }
      } catch (Exception e) {
        throw ValidationException.reflectiveExceptionWhileCreatingClassInstance(cls.getName(), e);
      }
    }

    return null;
  }