mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
The enum TcclLookupPrecedence is a single public enum, detached from the ClassLoaderService interface because it is only implementation-specific
This commit is contained in:
parent
c2330c29f6
commit
346941dcb7
@ -13,8 +13,8 @@
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
|
||||
import org.hibernate.boot.registry.classloading.internal.TcclLookupPrecedence;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService.TcclLookupPrecedence;
|
||||
import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
|
||||
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
||||
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.boot.registry.classloading.internal;
|
||||
|
||||
/**
|
||||
* Defines when the lookup in the current thread context {@link ClassLoader} should be
|
||||
* done according to the other ones.
|
||||
*
|
||||
* @author Cédric Tabin
|
||||
*/
|
||||
public enum TcclLookupPrecedence {
|
||||
/**
|
||||
* The current thread context {@link ClassLoader} will never be used during
|
||||
* the class lookup.
|
||||
*/
|
||||
NEVER,
|
||||
|
||||
/**
|
||||
* The class lookup will be done in the thread context {@link ClassLoader} prior
|
||||
* to the other {@code ClassLoader}s.
|
||||
*/
|
||||
BEFORE,
|
||||
|
||||
/**
|
||||
* The class lookup will be done in the thread context {@link ClassLoader} if
|
||||
* the former hasn't been found in the other {@code ClassLoader}s.
|
||||
* This is the default value.
|
||||
*/
|
||||
AFTER
|
||||
}
|
@ -80,30 +80,4 @@ interface Work<T> {
|
||||
}
|
||||
|
||||
<T> T workWithClassLoader(Work<T> work);
|
||||
|
||||
/**
|
||||
* Defines when the lookup in the current thread context {@link ClassLoader} should be
|
||||
* done according to the other ones.
|
||||
*/
|
||||
enum TcclLookupPrecedence {
|
||||
|
||||
/**
|
||||
* The current thread context {@link ClassLoader} will never be used during
|
||||
* the class lookup.
|
||||
*/
|
||||
NEVER,
|
||||
|
||||
/**
|
||||
* The class lookup will be done in the thread context {@link ClassLoader} prior
|
||||
* to the other {@code ClassLoader}s.
|
||||
*/
|
||||
BEFORE,
|
||||
|
||||
/**
|
||||
* The class lookup will be done in the thread context {@link ClassLoader} if
|
||||
* the former hasn't been found in the other {@code ClassLoader}s.
|
||||
* This is the default value.
|
||||
*/
|
||||
AFTER
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,6 @@
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import javassist.CtClass;
|
||||
import javassist.CtField;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.SessionFactoryObserver;
|
||||
@ -44,8 +42,8 @@
|
||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.classloading.internal.TcclLookupPrecedence;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService.TcclLookupPrecedence;
|
||||
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||
import org.hibernate.boot.spi.MetadataBuilderImplementor;
|
||||
|
@ -7,7 +7,6 @@
|
||||
package org.hibernate.boot.registry.classloading.internal;
|
||||
|
||||
import java.net.URL;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@ -19,17 +18,17 @@ public class ClassLoaderServiceImplTest {
|
||||
public void testNullTCCL() {
|
||||
Thread.currentThread().setContextClassLoader(null);
|
||||
|
||||
ClassLoaderServiceImpl csi1 = new ClassLoaderServiceImpl(null,ClassLoaderService.TcclLookupPrecedence.BEFORE);
|
||||
ClassLoaderServiceImpl csi1 = new ClassLoaderServiceImpl(null,TcclLookupPrecedence.BEFORE);
|
||||
Class<ClassLoaderServiceImplTest> clazz1 = csi1.classForName(ClassLoaderServiceImplTest.class.getName());
|
||||
assertEquals(ClassLoaderServiceImplTest.class, clazz1);
|
||||
csi1.stop();
|
||||
|
||||
ClassLoaderServiceImpl csi2 = new ClassLoaderServiceImpl(null,ClassLoaderService.TcclLookupPrecedence.AFTER);
|
||||
ClassLoaderServiceImpl csi2 = new ClassLoaderServiceImpl(null,TcclLookupPrecedence.AFTER);
|
||||
Class<ClassLoaderServiceImplTest> clazz2 = csi2.classForName(ClassLoaderServiceImplTest.class.getName());
|
||||
assertEquals(ClassLoaderServiceImplTest.class, clazz2);
|
||||
csi2.stop();
|
||||
|
||||
ClassLoaderServiceImpl csi3 = new ClassLoaderServiceImpl(null,ClassLoaderService.TcclLookupPrecedence.NEVER);
|
||||
ClassLoaderServiceImpl csi3 = new ClassLoaderServiceImpl(null,TcclLookupPrecedence.NEVER);
|
||||
Class<ClassLoaderServiceImplTest> clazz3 = csi3.classForName(ClassLoaderServiceImplTest.class.getName());
|
||||
assertEquals(ClassLoaderServiceImplTest.class, clazz3);
|
||||
csi3.stop();
|
||||
@ -40,7 +39,7 @@ public void testLookupBefore() {
|
||||
InternalClassLoader icl = new InternalClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(icl);
|
||||
|
||||
ClassLoaderServiceImpl csi = new ClassLoaderServiceImpl(null,ClassLoaderService.TcclLookupPrecedence.BEFORE);
|
||||
ClassLoaderServiceImpl csi = new ClassLoaderServiceImpl(null,TcclLookupPrecedence.BEFORE);
|
||||
Class<ClassLoaderServiceImplTest> clazz = csi.classForName(ClassLoaderServiceImplTest.class.getName());
|
||||
assertEquals(ClassLoaderServiceImplTest.class, clazz);
|
||||
assertEquals(1, icl.accessCount);
|
||||
@ -52,7 +51,7 @@ public void testLookupAfterAvoided() {
|
||||
InternalClassLoader icl = new InternalClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(icl);
|
||||
|
||||
ClassLoaderServiceImpl csi = new ClassLoaderServiceImpl(null,ClassLoaderService.TcclLookupPrecedence.AFTER);
|
||||
ClassLoaderServiceImpl csi = new ClassLoaderServiceImpl(null,TcclLookupPrecedence.AFTER);
|
||||
Class<ClassLoaderServiceImplTest> clazz = csi.classForName(ClassLoaderServiceImplTest.class.getName());
|
||||
assertEquals(ClassLoaderServiceImplTest.class, clazz);
|
||||
assertEquals(0, icl.accessCount);
|
||||
@ -64,7 +63,7 @@ public void testLookupAfter() {
|
||||
InternalClassLoader icl = new InternalClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(icl);
|
||||
|
||||
ClassLoaderServiceImpl csi = new ClassLoaderServiceImpl(null,ClassLoaderService.TcclLookupPrecedence.AFTER);
|
||||
ClassLoaderServiceImpl csi = new ClassLoaderServiceImpl(null,TcclLookupPrecedence.AFTER);
|
||||
try { csi.classForName("test.class.name"); assertTrue(false); }
|
||||
catch (Exception e) {}
|
||||
assertEquals(1, icl.accessCount);
|
||||
@ -76,7 +75,7 @@ public void testLookupAfterNotFound() {
|
||||
InternalClassLoader icl = new InternalClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(icl);
|
||||
|
||||
ClassLoaderServiceImpl csi = new ClassLoaderServiceImpl(null,ClassLoaderService.TcclLookupPrecedence.BEFORE);
|
||||
ClassLoaderServiceImpl csi = new ClassLoaderServiceImpl(null,TcclLookupPrecedence.BEFORE);
|
||||
try { csi.classForName("test.class.not.found"); assertTrue(false); }
|
||||
catch (Exception e) { }
|
||||
assertEquals(1, icl.accessCount);
|
||||
@ -88,7 +87,7 @@ public void testLookupNever() {
|
||||
InternalClassLoader icl = new InternalClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(icl);
|
||||
|
||||
ClassLoaderServiceImpl csi = new ClassLoaderServiceImpl(null,ClassLoaderService.TcclLookupPrecedence.NEVER);
|
||||
ClassLoaderServiceImpl csi = new ClassLoaderServiceImpl(null,TcclLookupPrecedence.NEVER);
|
||||
try { csi.classForName("test.class.name"); assertTrue(false); }
|
||||
catch (Exception e) { }
|
||||
assertEquals(0, icl.accessCount);
|
||||
|
Loading…
x
Reference in New Issue
Block a user