use of org.eclipse.persistence.internal.security.PrivilegedGetSystemProperty in project eclipselink by eclipse-ee4j.
the class PersistenceUnitProcessor method getArchiveFactory.
public static ArchiveFactory getArchiveFactory(ClassLoader loader, Map properties) {
if (ARCHIVE_FACTORY != null) {
return ARCHIVE_FACTORY;
}
ArchiveFactory factory = null;
String factoryClassName = PrivilegedAccessHelper.shouldUsePrivilegedAccess() ? AccessController.doPrivileged(new PrivilegedGetSystemProperty(SystemProperties.ARCHIVE_FACTORY)) : System.getProperty(SystemProperties.ARCHIVE_FACTORY);
if (factoryClassName == null && properties != null) {
Object name = properties.get(SystemProperties.ARCHIVE_FACTORY);
if (name instanceof String) {
factoryClassName = (String) name;
}
}
if (factoryClassName == null) {
return new ArchiveFactoryImpl();
} else {
try {
if (loader != null) {
Class<?> archiveClass = loader.loadClass(factoryClassName);
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
try {
factory = (ArchiveFactory) AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(archiveClass));
} catch (PrivilegedActionException exception) {
throw PersistenceUnitLoadingException.exceptionCreatingArchiveFactory(factoryClassName, exception);
}
} else {
factory = (ArchiveFactory) PrivilegedAccessHelper.newInstanceFromClass(archiveClass);
}
}
} catch (ClassNotFoundException cnfe) {
throw PersistenceUnitLoadingException.exceptionCreatingArchiveFactory(factoryClassName, cnfe);
} catch (IllegalAccessException iae) {
throw PersistenceUnitLoadingException.exceptionCreatingArchiveFactory(factoryClassName, iae);
} catch (InstantiationException ie) {
throw PersistenceUnitLoadingException.exceptionCreatingArchiveFactory(factoryClassName, ie);
}
}
return factory;
}
Aggregations