Interface ClassLoaderService
- All Superinterfaces:
ResourceLocator
,ResourceStreamLocator
,Serializable
,Service
,Stoppable
- All Known Implementing Classes:
ClassLoaderServiceImpl
public interface ClassLoaderService
extends ResourceLocator, ResourceStreamLocator, Service, Stoppable
A service for interacting with class loaders.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescription<T> Class<T>
classForName
(String className) Locate a class by name.default <T> Class<T>
classForTypeName
(String className) <T> T
generateProxy
(InvocationHandler handler, Class<?>... interfaces) <S> Collection<S>
loadJavaServices
(Class<S> serviceContract) Discovers and instantiates implementations of the named service contract.locateResource
(String name) Locate a resource by name (classpath lookup).locateResources
(String name) Locate a series of resource by name (classpath lookup).locateResourceStream
(String name) Locate a resource by name (classpath lookup) and gets its stream.packageForNameOrNull
(String packageName) Loading a Package from the ClassLoader.<T> T
-
Method Details
-
classForName
Locate a class by name.- Type Parameters:
T
- The returned class type.- Parameters:
className
- The name of the class to locate- Returns:
- The class reference
- Throws:
ClassLoadingException
- Indicates the class could not be found
-
classForTypeName
-
locateResource
Locate a resource by name (classpath lookup).- 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
Locate a resource by name (classpath lookup) and gets its stream.- 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
Locate a series of resource by name (classpath lookup).- Parameters:
name
- The resource name.- Returns:
- The list of URL matching; may return
null
to indicate the resource was not found
-
loadJavaServices
Discovers and instantiates implementations of the named service contract.- 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:
- API Note:
- The term "service" here does not refer to a
Service
. Here it refers to a JavaServiceLoader
.
-
generateProxy
-
packageForNameOrNull
Loading a Package from the ClassLoader.- Returns:
- The Package.
null
if no such Package is found, or if the ClassLoader call leads to an exception (LinkageError
, e.g.).
-
workWithClassLoader
-