Class ClassLoaderServiceImpl
- java.lang.Object
-
- org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl
-
- All Implemented Interfaces:
Serializable
,ClassLoaderService
,ResourceLocator
,ResourceStreamLocator
,Service
,Stoppable
- Direct Known Subclasses:
ClassLoaderServiceTestingImpl
,ExtraJavaServicesClassLoaderService
public class ClassLoaderServiceImpl extends Object implements ClassLoaderService
Standard implementation of the service for interacting with class loaders- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.boot.registry.classloading.spi.ClassLoaderService
ClassLoaderService.Work<T>
-
-
Constructor Summary
Constructors Constructor Description ClassLoaderServiceImpl()
Constructs a ClassLoaderServiceImpl with standard set-upClassLoaderServiceImpl(ClassLoader classLoader)
Constructs a ClassLoaderServiceImpl with the given ClassLoaderClassLoaderServiceImpl(Collection<ClassLoader> providedClassLoaders, TcclLookupPrecedence lookupPrecedence)
Constructs a ClassLoaderServiceImpl with the given ClassLoader instances
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> Class<T>
classForName(String className)
Locate a class by name.static ClassLoaderServiceImpl
fromConfigSettings(Map configValues)
Deprecated.No longer used/supported!<T> T
generateProxy(InvocationHandler handler, Class... interfaces)
<S> Collection<S>
loadJavaServices(Class<S> serviceContract)
Discovers and instantiates implementations of the named service contract.URL
locateResource(String name)
Locate a resource by name (classpath lookup).List<URL>
locateResources(String name)
Locate a series of resource by name (classpath lookup).InputStream
locateResourceStream(String name)
Locate a resource by name (classpath lookup) and gets its stream.Package
packageForNameOrNull(String packageName)
Loading a Package from the ClassLoader.void
stop()
Stop phase notification<T> T
workWithClassLoader(ClassLoaderService.Work<T> work)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.boot.registry.classloading.spi.ClassLoaderService
classForTypeName
-
-
-
-
Constructor Detail
-
ClassLoaderServiceImpl
public ClassLoaderServiceImpl()
Constructs a ClassLoaderServiceImpl with standard set-up
-
ClassLoaderServiceImpl
public ClassLoaderServiceImpl(ClassLoader classLoader)
Constructs a ClassLoaderServiceImpl with the given ClassLoader- Parameters:
classLoader
- The ClassLoader to use
-
ClassLoaderServiceImpl
public ClassLoaderServiceImpl(Collection<ClassLoader> providedClassLoaders, TcclLookupPrecedence lookupPrecedence)
Constructs a ClassLoaderServiceImpl with the given ClassLoader instances- Parameters:
providedClassLoaders
- The ClassLoader instances to uselookupPrecedence
- The lookup precedence of the thread contextClassLoader
-
-
Method Detail
-
fromConfigSettings
@Deprecated @Internal public static ClassLoaderServiceImpl fromConfigSettings(Map configValues)
Deprecated.No longer used/supported!No longer used/supported!- Parameters:
configValues
- The config values- Returns:
- The built service
-
classForName
public <T> Class<T> classForName(String className)
Description copied from interface:ClassLoaderService
Locate a class by name.- Specified by:
classForName
in interfaceClassLoaderService
- Type Parameters:
T
- The returned class type.- Parameters:
className
- The name of the class to locate- Returns:
- The class reference
-
locateResource
public URL locateResource(String name)
Description copied from interface:ClassLoaderService
Locate a resource by name (classpath lookup).- Specified by:
locateResource
in interfaceClassLoaderService
- Specified by:
locateResource
in interfaceResourceLocator
- Parameters:
name
- The resource name.- Returns:
- The located URL; may return
null
to indicate the resource was not found
-
locateResourceStream
public InputStream locateResourceStream(String name)
Description copied from interface:ClassLoaderService
Locate a resource by name (classpath lookup) and gets its stream.- Specified by:
locateResourceStream
in interfaceClassLoaderService
- Specified by:
locateResourceStream
in interfaceResourceStreamLocator
- Parameters:
name
- The resource name.- Returns:
- The stream of the located resource; may return
null
to indicate the resource was not found
-
locateResources
public List<URL> locateResources(String name)
Description copied from interface:ClassLoaderService
Locate a series of resource by name (classpath lookup).- Specified by:
locateResources
in interfaceClassLoaderService
- Parameters:
name
- The resource name.- Returns:
- The list of URL matching; may return
null
to indicate the resource was not found
-
loadJavaServices
public <S> Collection<S> loadJavaServices(Class<S> serviceContract)
Description copied from interface:ClassLoaderService
Discovers and instantiates implementations of the named service contract.- Specified by:
loadJavaServices
in interfaceClassLoaderService
- Type Parameters:
S
- The type of the service contract- Parameters:
serviceContract
- The java type defining the service contract- Returns:
- The ordered set of discovered services.
- See Also:
JavaServiceLoadable
-
generateProxy
public <T> T generateProxy(InvocationHandler handler, Class... interfaces)
- Specified by:
generateProxy
in interfaceClassLoaderService
-
packageForNameOrNull
public Package packageForNameOrNull(String packageName)
Description copied from interface:ClassLoaderService
Loading a Package from the ClassLoader.- Specified by:
packageForNameOrNull
in interfaceClassLoaderService
- Returns:
- The Package.
null
if no such Package is found, or if the ClassLoader call leads to an exception (LinkageError
, e.g.).
-
workWithClassLoader
public <T> T workWithClassLoader(ClassLoaderService.Work<T> work)
- Specified by:
workWithClassLoader
in interfaceClassLoaderService
-
-