Class FileSystemRepository

java.lang.Object
i5.las2peer.classLoaders.libraries.FileSystemRepository
All Implemented Interfaces:
Repository

public class FileSystemRepository extends Object implements Repository
implements a repository which loads all libraries from a given directory or from severeal ones. The search for library files (jars) may be recursive.
  • Constructor Details

    • FileSystemRepository

      public FileSystemRepository(String directory)
      create a repository for the given directory, non-recursive
      Parameters:
      directory - A directory path name to use as repository
    • FileSystemRepository

      public FileSystemRepository(String directory, boolean recursive)
      create a repository for the given directory
      Parameters:
      directory - A directory path name to use as repository
      recursive - If true, recursion is used for sub-directories.
    • FileSystemRepository

      public FileSystemRepository(String[] directories)
      create a repository for the given directories, non-recursive
      Parameters:
      directories - An array of directory path names to use as repository
    • FileSystemRepository

      public FileSystemRepository(String[] directories, boolean recursive)
      create a repository for the given directories
      Parameters:
      directories - An array of directory path names to use as repository
      recursive - If true, recursion is used for sub-directories.
    • FileSystemRepository

      public FileSystemRepository(Iterable<String> directories, boolean recursive)
      create a repository for the given directories
      Parameters:
      directories - A bunch of directory path names to use as repository
      recursive - If true, recursion is used for sub-directories.
  • Method Details

    • findLibrary

      public LoadedLibrary findLibrary(String name) throws LibraryNotFoundException
      get the newest library for the given name
      Specified by:
      findLibrary in interface Repository
      Parameters:
      name - A library name to search for
      Returns:
      Returns a LoadedLibrary for the requested library name
      Throws:
      LibraryNotFoundException - If the library could not be found in this repository
    • findLibrary

      public LoadedLibrary findLibrary(LibraryIdentifier lib) throws LibraryNotFoundException
      get a library matching name and version of the given identifier
      Specified by:
      findLibrary in interface Repository
      Parameters:
      lib - A library identifier
      Returns:
      Returns a LoadedLibrary for the requested library identifier
      Throws:
      LibraryNotFoundException - If the library could not be found in this repository
    • getAvailableVersions

      public String[] getAvailableVersions(String libraryName)
      get an array with all versions found for the given library name
      Parameters:
      libraryName - A canonical library name
      Returns:
      array with all available versions of the given library
    • getAvailableVersionSet

      public Collection<LibraryVersion> getAvailableVersionSet(String libraryName)
      get a collection with all versions found for the given library name
      Parameters:
      libraryName - A canonical library name
      Returns:
      a collections with all versions of the given library
    • getAllLibraries

      public String[] getAllLibraries()
      get an array with found jar files within this repository
      Returns:
      an array with all libraries in this repository
    • getLibraryCollection

      public Collection<String> getLibraryCollection()
      get a collection with all found jar files within this repository
      Returns:
      a collection with all libraries in this repository
    • getLastModified

      public static long getLastModified(File dir, boolean recursive)
      helper method to get the last modification date of a directory
      Parameters:
      dir - A directory
      recursive - If true also files inside the directory are considered
      Returns:
      Returns the last modified date in epoch format
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      a simple string representation of this object