/** * INTERNAL: Convert all the class-name-based settings in this mapping 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. */ @Override public void convertClassNamesToClasses(ClassLoader classLoader) { super.convertClassNamesToClasses(classLoader); Iterator iterator = getTypeIndicatorNameTranslation().entrySet().iterator(); this.typeIndicatorTranslation = new HashMap(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String referenceClassName = (String) entry.getKey(); Object indicator = entry.getValue(); Class referenceClass = null; try { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { try { referenceClass = (Class) AccessController.doPrivileged( new PrivilegedClassForName(referenceClassName, true, classLoader)); } catch (PrivilegedActionException exception) { throw ValidationException.classNotFoundWhileConvertingClassNames( referenceClassName, exception.getException()); } } else { referenceClass = PrivilegedAccessHelper.getClassForName(referenceClassName, true, classLoader); } } catch (ClassNotFoundException exception) { throw ValidationException.classNotFoundWhileConvertingClassNames( referenceClassName, exception); } addClassIndicator(referenceClass, indicator); } }
/** * INTERNAL: Convert all the class-name-based settings in this InheritancePolicy 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. It will also convert referenced classes to the versions * of the classes from the classLoader. */ public void convertClassNamesToClasses(ClassLoader classLoader) { Vector newParentInterfaces = new Vector(); for (Iterator iterator = getParentInterfaceNames().iterator(); iterator.hasNext(); ) { String interfaceName = (String) iterator.next(); Class interfaceClass = null; try { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { try { interfaceClass = (Class) AccessController.doPrivileged( new PrivilegedClassForName(interfaceName, true, classLoader)); } catch (PrivilegedActionException exception) { throw ValidationException.classNotFoundWhileConvertingClassNames( interfaceName, exception.getException()); } } else { interfaceClass = org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName( interfaceName, true, classLoader); } } catch (ClassNotFoundException exc) { throw ValidationException.classNotFoundWhileConvertingClassNames(interfaceName, exc); } newParentInterfaces.add(interfaceClass); } this.parentInterfaces = newParentInterfaces; }
/** * 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); } }
/** * INTERNAL: Convert all the class-name-based settings in this Descriptor 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. * * @param classLoader */ public void convertClassNamesToClasses(ClassLoader classLoader) { if (this.type == null) { try { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { try { this.type = AccessController.doPrivileged( new PrivilegedClassForName(this.typeName, true, classLoader)); } catch (PrivilegedActionException exception) { throw ValidationException.classNotFoundWhileConvertingClassNames( this.typeName, exception.getException()); } } else { this.type = org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName( this.typeName, true, classLoader); } } catch (ClassNotFoundException exc) { throw ValidationException.classNotFoundWhileConvertingClassNames(this.typeName, exc); } if (this.items != null) { for (ATTRIBUTE_ITEM item : this.items.values()) { item.convertClassNamesToClasses(classLoader); } } if (this.allsubclasses != null) { Map<Object, CoreAttributeGroup> allGroups = new HashMap<Object, CoreAttributeGroup>(); this.subClasses = new HashSet<CoreAttributeGroup>(); for (CoreAttributeGroup subClass : allsubclasses.values()) { subClass.convertClassNamesToClasses(classLoader); allGroups.put(subClass.getType(), subClass); } this.allsubclasses = allGroups; for (CoreAttributeGroup subClass : allsubclasses.values()) { if (CoreAttributeItem.orderInheritance(subClass, allGroups)) { this.insertSubClass(subClass); } } } } }