Package org.jppf.classloader
Class AbstractResourceProvider
java.lang.Object
org.jppf.classloader.AbstractResourceProvider
- All Implemented Interfaces:
ResourceProvider
- Direct Known Subclasses:
ResourceProviderImpl
Instances of this class are dedicated to reading resource files form the JVM's classpath and converting them into
arrays of bytes.
- Since:
- 5.0
- Author:
- Laurent Cohen, Domingos Creado
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]computeCallable(byte[] serializedCallable) Compute a callable sent through the JPPF class loader.getMultipleResourcesAsBytes(ClassLoader classloader, boolean lookupInFileSystem, String... names) Get all resources associated with each specified resource name.List<byte[]>getMultipleResourcesAsBytes(String name, ClassLoader classloader, boolean lookupInFileSystem) Get all resources associated with the specified resource name.List<byte[]>getMultipleResourcesAsBytes(String name, Collection<ClassLoader> classLoaders, boolean lookupInFileSystem) Get all resources associated with the specified resource name.getMultipleResourcesAsBytes(Collection<ClassLoader> classLoaders, boolean lookupInFileSystem, String... names) Get all resources associated with each specified resource name.byte[]getResource(String resName, boolean lookupInFileSystem) Get a resource as an array of byte using a call to ClassLoader.getResource().byte[]getResource(String resName, ClassLoader classloader, boolean lookupInFileSystem) Get a resource as an array of byte using a call to ClassLoader.getResource().byte[]getResource(String resName, Collection<ClassLoader> classLoaders, boolean lookupInFileSystem) Get a resource as an array of byte using a call to ClassLoader.getResource().protected abstract ClassLoaderresolveClassLoader(ClassLoader classloader) Resolve the class loader to use for getting resources from the classpath.
-
Constructor Details
-
AbstractResourceProvider
public AbstractResourceProvider()Default constructor.
-
-
Method Details
-
getResource
Description copied from interface:ResourceProviderGet a resource as an array of byte using a call to ClassLoader.getResource(). This method simply callsgetResource(String, ClassLoader)with a null class loader.- Specified by:
getResourcein interfaceResourceProvider- Parameters:
resName- the name of the resource to find.lookupInFileSystem- whether resources should be looked up in the file system if not found in the classpath.- Returns:
- the content of the resource as an array of bytes.
-
getResource
Description copied from interface:ResourceProviderGet a resource as an array of byte using a call to ClassLoader.getResource().- Specified by:
getResourcein interfaceResourceProvider- Parameters:
resName- the name of the resource to find.classloader- the class loader to use to load the request resource.lookupInFileSystem- whether resources should be looked up in the file system if not found in the classpath.- Returns:
- the content of the resource as an array of bytes.
-
getResource
public byte[] getResource(String resName, Collection<ClassLoader> classLoaders, boolean lookupInFileSystem) Description copied from interface:ResourceProviderGet a resource as an array of byte using a call to ClassLoader.getResource().- Specified by:
getResourcein interfaceResourceProvider- Parameters:
resName- the name of the resource to find.classLoaders- the set of class loaders available to use to load the requested resource.lookupInFileSystem- whether resources should be looked up in the file system if not found in the classpath.- Returns:
- the content of the resource as an array of bytes.
-
computeCallable
public byte[] computeCallable(byte[] serializedCallable) Description copied from interface:ResourceProviderCompute a callable sent through the JPPF class loader.- Specified by:
computeCallablein interfaceResourceProvider- Parameters:
serializedCallable- the callable to execute in serialized form.- Returns:
- the serialized result of the callable's execution, or of an eventually resulting exception.
-
getMultipleResourcesAsBytes
public List<byte[]> getMultipleResourcesAsBytes(String name, ClassLoader classloader, boolean lookupInFileSystem) Description copied from interface:ResourceProviderGet all resources associated with the specified resource name.- Specified by:
getMultipleResourcesAsBytesin interfaceResourceProvider- Parameters:
name- the name of the resources to look for.classloader- the class loader used to load the resources.lookupInFileSystem- whether resources should be looked up in the file system if not found in the classpath.- Returns:
- the content of all found resources as a list of byte arrays.
-
getMultipleResourcesAsBytes
public List<byte[]> getMultipleResourcesAsBytes(String name, Collection<ClassLoader> classLoaders, boolean lookupInFileSystem) Description copied from interface:ResourceProviderGet all resources associated with the specified resource name.- Specified by:
getMultipleResourcesAsBytesin interfaceResourceProvider- Parameters:
name- the name of the resources to look for.classLoaders- the set of class loaders available to load the resources.lookupInFileSystem- whether resources should be looked up in the file system if not found in the classpath.- Returns:
- the content of all found resources as a list of byte arrays.
-
getMultipleResourcesAsBytes
public Map<String,List<byte[]>> getMultipleResourcesAsBytes(ClassLoader classloader, boolean lookupInFileSystem, String... names) Description copied from interface:ResourceProviderGet all resources associated with each specified resource name.- Specified by:
getMultipleResourcesAsBytesin interfaceResourceProvider- Parameters:
classloader- the class loader used to load the resources.lookupInFileSystem- whether resources should be looked up in the file system if not found in the classpath.names- the names of all the resources to look for.- Returns:
- A mapping of each resource names with a list of the byte content of corresponding resources in the classpath.
-
getMultipleResourcesAsBytes
public Map<String,List<byte[]>> getMultipleResourcesAsBytes(Collection<ClassLoader> classLoaders, boolean lookupInFileSystem, String... names) Description copied from interface:ResourceProviderGet all resources associated with each specified resource name.- Specified by:
getMultipleResourcesAsBytesin interfaceResourceProvider- Parameters:
classLoaders- the set of class loader available to load the resources.lookupInFileSystem- whether resources should be looked up in the file system if not found in the classpath.names- the names of all the resources to look for.- Returns:
- A mapping of each resource names with a list of the byte content of corresponding resources in the classpath.
-
resolveClassLoader
Resolve the class loader to use for getting resources from the classpath.- Parameters:
classloader- the initial clss loader.- Returns:
- the resolved class loader.
-