Class AbstractResourceProvider

java.lang.Object
org.jppf.classloader.AbstractResourceProvider
All Implemented Interfaces:
ResourceProvider
Direct Known Subclasses:
ResourceProviderImpl

public abstract class AbstractResourceProvider extends Object implements ResourceProvider
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 Details

    • AbstractResourceProvider

      public AbstractResourceProvider()
      Default constructor.
  • Method Details

    • getResource

      public byte[] getResource(String resName, boolean lookupInFileSystem)
      Description copied from interface: ResourceProvider
      Get a resource as an array of byte using a call to ClassLoader.getResource(). This method simply calls getResource(String, ClassLoader) with a null class loader.
      Specified by:
      getResource in interface ResourceProvider
      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

      public byte[] getResource(String resName, ClassLoader classloader, boolean lookupInFileSystem)
      Description copied from interface: ResourceProvider
      Get a resource as an array of byte using a call to ClassLoader.getResource().
      Specified by:
      getResource in interface ResourceProvider
      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: ResourceProvider
      Get a resource as an array of byte using a call to ClassLoader.getResource().
      Specified by:
      getResource in interface ResourceProvider
      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: ResourceProvider
      Compute a callable sent through the JPPF class loader.
      Specified by:
      computeCallable in interface ResourceProvider
      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: ResourceProvider
      Get all resources associated with the specified resource name.
      Specified by:
      getMultipleResourcesAsBytes in interface ResourceProvider
      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: ResourceProvider
      Get all resources associated with the specified resource name.
      Specified by:
      getMultipleResourcesAsBytes in interface ResourceProvider
      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: ResourceProvider
      Get all resources associated with each specified resource name.
      Specified by:
      getMultipleResourcesAsBytes in interface ResourceProvider
      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: ResourceProvider
      Get all resources associated with each specified resource name.
      Specified by:
      getMultipleResourcesAsBytes in interface ResourceProvider
      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

      protected abstract ClassLoader resolveClassLoader(ClassLoader classloader)
      Resolve the class loader to use for getting resources from the classpath.
      Parameters:
      classloader - the initial clss loader.
      Returns:
      the resolved class loader.