Consistent use of ClassUtils.forName instead of class.getClassLoader().loadClass
Issue: SPR-11780
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -89,7 +89,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
zoneIdClass = PropertyEditorRegistrySupport.class.getClassLoader().loadClass("java.time.ZoneId");
|
zoneIdClass = ClassUtils.forName("java.time.ZoneId", PropertyEditorRegistrySupport.class.getClassLoader());
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex) {
|
catch (ClassNotFoundException ex) {
|
||||||
// Java 8 ZoneId class not available
|
// Java 8 ZoneId class not available
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -33,6 +33,7 @@ import org.hibernate.service.Service;
|
|||||||
|
|
||||||
import org.springframework.transaction.jta.UserTransactionAdapter;
|
import org.springframework.transaction.jta.UserTransactionAdapter;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of Hibernate 4's JtaPlatform SPI (which has a different package
|
* Implementation of Hibernate 4's JtaPlatform SPI (which has a different package
|
||||||
@@ -51,14 +52,14 @@ class ConfigurableJtaPlatform implements InvocationHandler {
|
|||||||
Class<?> jpClass;
|
Class<?> jpClass;
|
||||||
try {
|
try {
|
||||||
// Try Hibernate 4.0-4.2 JtaPlatform variant
|
// Try Hibernate 4.0-4.2 JtaPlatform variant
|
||||||
jpClass = SpringSessionContext.class.getClassLoader().loadClass(
|
jpClass = ClassUtils.forName("org.hibernate.service.jta.platform.spi.JtaPlatform",
|
||||||
"org.hibernate.service.jta.platform.spi.JtaPlatform");
|
ConfigurableJtaPlatform.class.getClassLoader());
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex) {
|
catch (ClassNotFoundException ex) {
|
||||||
try {
|
try {
|
||||||
// Try Hibernate 4.3 JtaPlatform variant
|
// Try Hibernate 4.3 JtaPlatform variant
|
||||||
jpClass = SpringSessionContext.class.getClassLoader().loadClass(
|
jpClass = ClassUtils.forName("org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform",
|
||||||
"org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform");
|
ConfigurableJtaPlatform.class.getClassLoader());
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex2) {
|
catch (ClassNotFoundException ex2) {
|
||||||
throw new IllegalStateException("Neither Hibernate 4.0-4.2 nor 4.3 variant of JtaPlatform found");
|
throw new IllegalStateException("Neither Hibernate 4.0-4.2 nor 4.3 variant of JtaPlatform found");
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class LocalSessionFactoryBuilder extends Configuration {
|
|||||||
try {
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends Annotation> converterAnnotation = (Class<? extends Annotation>)
|
Class<? extends Annotation> converterAnnotation = (Class<? extends Annotation>)
|
||||||
LocalSessionFactoryBuilder.class.getClassLoader().loadClass("javax.persistence.Converter");
|
ClassUtils.forName("javax.persistence.Converter", LocalSessionFactoryBuilder.class.getClassLoader());
|
||||||
entityTypeFilters.add(new AnnotationTypeFilter(converterAnnotation, false));
|
entityTypeFilters.add(new AnnotationTypeFilter(converterAnnotation, false));
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex) {
|
catch (ClassNotFoundException ex) {
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class DefaultPersistenceUnitManager
|
|||||||
try {
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends Annotation> converterAnnotation = (Class<? extends Annotation>)
|
Class<? extends Annotation> converterAnnotation = (Class<? extends Annotation>)
|
||||||
DefaultPersistenceUnitManager.class.getClassLoader().loadClass("javax.persistence.Converter");
|
ClassUtils.forName("javax.persistence.Converter", DefaultPersistenceUnitManager.class.getClassLoader());
|
||||||
entityTypeFilters.add(new AnnotationTypeFilter(converterAnnotation, false));
|
entityTypeFilters.add(new AnnotationTypeFilter(converterAnnotation, false));
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex) {
|
catch (ClassNotFoundException ex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user