Class FileSystemRepository

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

public class FileSystemRepository
extends java.lang.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 Summary

    Constructors 
    Constructor Description
    FileSystemRepository​(java.lang.Iterable<java.lang.String> directories, boolean recursive)
    create a repository for the given directories
    FileSystemRepository​(java.lang.String directory)
    create a repository for the given directory, non-recursive
    FileSystemRepository​(java.lang.String[] directories)
    create a repository for the given directories, non-recursive
    FileSystemRepository​(java.lang.String[] directories, boolean recursive)
    create a repository for the given directories
    FileSystemRepository​(java.lang.String directory, boolean recursive)
    create a repository for the given directory
  • Method Summary

    Modifier and Type Method Description
    LoadedLibrary findLibrary​(LibraryIdentifier lib)
    get a library matching name and version of the given identifier
    LoadedLibrary findLibrary​(java.lang.String name)
    get the newest library for the given name
    java.lang.String[] getAllLibraries()
    get an array with found jar files within this repository
    java.lang.String[] getAvailableVersions​(java.lang.String libraryName)
    get an array with all versions found for the given library name
    java.util.Collection<LibraryVersion> getAvailableVersionSet​(java.lang.String libraryName)
    get a collection with all versions found for the given library name
    static long getLastModified​(java.io.File dir, boolean recursive)
    helper method to get the last modification date of a directory
    java.util.Collection<java.lang.String> getLibraryCollection()
    get a collection with all found jar files within this repository
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FileSystemRepository

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

      public FileSystemRepository​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.Iterable<java.lang.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​(java.lang.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 java.lang.String[] getAvailableVersions​(java.lang.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 java.util.Collection<LibraryVersion> getAvailableVersionSet​(java.lang.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 java.lang.String[] getAllLibraries()
      get an array with found jar files within this repository
      Returns:
      an array with all libraries in this repository
    • getLibraryCollection

      public java.util.Collection<java.lang.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​(java.io.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 java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
      Returns:
      a simple string representation of this object