if (queryBuilderClassName == null) {
queryBuilderClassName = "org.eclipse.persistence.internal.jpa.jpql.HermesParser";
//queryBuilderClassName = "org.eclipse.persistence.queries.ANTLRQueryBuilder";
}
String validation = (String)getProperty(PersistenceUnitProperties.JPQL_VALIDATION);
JPAQueryBuilder builder = null;
try {
Class parserClass = null;
// use class.forName() to avoid loading parser classes for JAXB
// Use Class.forName not thread class loader to avoid class loader issues.
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
parserClass = (Class)AccessController.doPrivileged(new PrivilegedClassForName(queryBuilderClassName));
} catch (PrivilegedActionException exception) {
}
} else {
parserClass = PrivilegedAccessHelper.getClassForName(queryBuilderClassName);
}
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
try {
builder = (JPAQueryBuilder)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(parserClass));
} catch (PrivilegedActionException exception) {
}
} else {
builder = (JPAQueryBuilder)PrivilegedAccessHelper.newInstanceFromClass(parserClass);
}
} catch (Exception e) {
throw new IllegalStateException("Could not load the JPQL parser class." /* TODO: Localize string */, e);
}
if (validation != null) {
builder.setValidationLevel(validation);
}
return builder;
}