Class ResourceFinder

  • All Implemented Interfaces:
    ResourceOpener

    public class ResourceFinder
    extends java.lang.Object
    implements ResourceOpener
    A class for finding resources in the WEB-INF directory at run-time based on patterns. The purpose of this is to allow resources, particularly configuration files to be found and used by giving them a name with a certain pattern, or by placing them in a certain directory.
    Author:
    Alex Kalderimis
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourceFinder​(javax.servlet.ServletContext context)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Collection<java.lang.String> findResourcesMatching​(java.util.regex.Pattern pattern)
      Find all resources matching a pattern in the WEB-INF directory.
      java.io.InputStream openResource​(java.lang.String resourceName)
      Open a resource by name, and return an InputStream to it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResourceFinder

        public ResourceFinder​(javax.servlet.ServletContext context)
        Constructor. Makes a ResourceFinder with reference to the current servlet context, meaning that it knows were to look to find the WEB-INF directory.
        Parameters:
        context - The servlet context.
    • Method Detail

      • openResource

        public java.io.InputStream openResource​(java.lang.String resourceName)
        Description copied from interface: ResourceOpener
        Open a resource by name, and return an InputStream to it.
        Specified by:
        openResource in interface ResourceOpener
        Parameters:
        resourceName - The name of the resource.
        Returns:
        The open input stream.
      • findResourcesMatching

        public java.util.Collection<java.lang.String> findResourcesMatching​(java.util.regex.Pattern pattern)
        Find all resources matching a pattern in the WEB-INF directory.
        Parameters:
        pattern - The pattern to match.
        Returns:
        A collection of resource names.