Class Repository

java.lang.Object
org.openide.filesystems.Repository
All Implemented Interfaces:
Serializable

public class Repository extends Object implements Serializable
Holder for NetBeans default (system, configuration) filesystem, used for most of NetBeans' runtime configuration. The default implementation is a merge of all of the XML layer files provided by enabled modules, and the config subfolder of the userdir on the user's disk. If you just want to modify configuration data use e.g.
 FileObject menus = FileUtil.getConfigFile("Menu");
 // ...
 
Formerly (NB 3.x) contained a list of mounted filesystems. This functionality is no longer used and is now deprecated.
See Also:
  • Constructor Details

    • Repository

      public Repository(FileSystem def)
      Creates new instance of filesystem pool and registers it as the default one. Also registers the default filesystem.
      Parameters:
      def - the default filesystem
  • Method Details

    • refreshAdditionalLayers

      protected void refreshAdditionalLayers()
      Methods that tells Repository subclasses to refresh list of URLs provided by Repository.LayerProviders.
      Since:
      7.59
    • findLayers

      protected final List<? extends URL> findLayers(Repository.LayerProvider p)
      Allows subclasses registered as getDefault() to find out list of URLs for a given provider. The method just calls Repository.LayerProvider.registerLayers(java.util.Collection).
      Parameters:
      p - the provider.
      Returns:
      ordered list of URLs
      Since:
      7.59
    • provideLayers

      protected static final void provideLayers(ClassLoader l, List<URL> layerUrls) throws IOException
      Allows subclasses to accept layer contributions from Repository.LayerProviders. Layer XMLs will be collected from locations specified in manifests accessible by the passed ClassLoader, including generated layers. Finally Repository.LayerProviders will be consulted to append their URLs to the list. If the passed classloader is null, the classloader which loaded the Repository class will be used.
      Parameters:
      layerUrls - out: collection which receives the URLs.
      Throws:
      IOException - propagated if some I/O error occurs.
      Since:
      9.5
    • getDefault

      public static Repository getDefault()
      Access method to get default instance of repository in the system. The instance is either taken as a result of org.openide.util.Lookup.getDefault ().lookup (Repository.class) or (if the lookup query returns null) a default instance is created.

      In a contextual environment, the method remembers the result of the default Lookup query, and will return the same instance as a system-wide Repository instance. Instances provided by Lookup.getDefault().lookup(Repository.class) may vary depending on the Lookup's implementation and context - be aware that multiple Repository instances may exist, possibly one for each contextual Lookup created.

      Returns:
      default repository for the system
      Since:
      9.5 support for multiple contexts
    • getDefaultFileSystem

      @Deprecated public final FileSystem getDefaultFileSystem()
      Deprecated.
      Gets the NetBeans default (system, configuration) filesystem.
      Returns:
      the default filesystem
    • addFileSystem

      @Deprecated public final void addFileSystem(FileSystem fs)
      Deprecated.
      Please use the ClassPath API instead.
      Adds new filesystem to the pool. Note that a filesystem cannot be assigned to more than one file system pool at one time (though currently there is only one pool anyway). At any given time, no two filesystems in the pool may share the same name (unless all but one are invalid). To be sure, that filesystem was really added in Repository, then test that FileSystem is valid.
      Parameters:
      fs - filesystem to add
    • removeFileSystem

      @Deprecated public final void removeFileSystem(FileSystem fs)
      Deprecated.
      Please use the ClassPath API instead.
      Removes a filesystem from the pool.
      Parameters:
      fs - filesystem to remove
    • reorder

      @Deprecated public final void reorder(int[] perm)
      Deprecated.
      Please use the ClassPath API instead.
      Reorders FileSystems by given permutation. For example, if there are three filesystems, new int[] {2, 0, 1} cycles the filesystems forwards.
      Parameters:
      perm - an array of integers
      Throws:
      IllegalArgumentException - if the array is not a permutation, or is not the same length as the current number of filesystems in the pool
    • getFileSystems

      @Deprecated public final Enumeration<? extends FileSystem> getFileSystems()
      Deprecated.
      Please use the ClassPath API instead.
      Returns enumeration of all filesystems.
      Returns:
      enumeration of type FileSystem
    • fileSystems

      @Deprecated public final Enumeration<? extends FileSystem> fileSystems()
      Deprecated.
      Please use the ClassPath API instead.
      Returns enumeration of all filesystems.
      Returns:
      enumeration of type FileSystem
    • toArray

      @Deprecated public final FileSystem[] toArray()
      Deprecated.
      Please use the ClassPath API instead.
      Returns a sorted array of filesystems.
      Returns:
      a sorted array of filesystems
    • findFileSystem

      @Deprecated public final FileSystem findFileSystem(String systemName)
      Deprecated.
      Please use the ClassPath API instead.
      Finds filesystem when only its system name is known.
      Parameters:
      systemName - name of the filesystem
      Returns:
      the filesystem or null if there is no such filesystem
    • writeExternal

      @Deprecated public final void writeExternal(ObjectOutput oos) throws IOException
      Deprecated.
      Unused.
      Saves pool to stream by saving all filesystems. The default (system) filesystem, or any persistent filesystems, are skipped.
      Parameters:
      oos - object output stream
      Throws:
      IOException - if an error occures
    • readExternal

      @Deprecated public final void readExternal(ObjectInput ois) throws IOException, ClassNotFoundException
      Deprecated.
      Unused.
      Reads object from stream. Reads all filesystems. Persistent and system filesystems are untouched; all others are removed and possibly reread.
      Parameters:
      ois - object input stream
      Throws:
      IOException - if an error occures
      ClassNotFoundException - if read class is not found
    • find

      @Deprecated public final FileObject find(String aPackage, String name, String ext)
      Deprecated.
      Please use the ClassPath API instead.
      Finds file when its name is provided. It scans in the list of filesystems and asks them for the specified file by a call to find. The first object that is found is returned or null if none of the filesystems contain such a file.
      Parameters:
      aPackage - package name where each package is separated by a dot
      name - name of the file (without dots) or null if one wants to obtain the name of a package and not a file in it
      ext - extension of the file or null if one needs a package and not a file name
      Returns:
      FileObject that represents file with given name or null if the file does not exist
    • findResource

      @Deprecated public final FileObject findResource(String name)
      Deprecated.
      Please use the ClassPath API instead.
      Searches for the given resource among all filesystems.
      Parameters:
      name - a name of the resource
      Returns:
      file object or null if the resource can not be found
      See Also:
    • findAllResources

      @Deprecated public final Enumeration<? extends FileObject> findAllResources(String name)
      Deprecated.
      Please use the ClassPath API instead.
      Searches for the given resource among all filesystems, returning all matches.
      Parameters:
      name - name of the resource
      Returns:
      enumeration of FileObjects
    • findAll

      @Deprecated public final Enumeration<? extends FileObject> findAll(String aPackage, String name, String ext)
      Deprecated.
      Please use the ClassPath API instead.
      Finds all files among all filesystems matching a given name, returning all matches. All filesystems are queried with FileSystem.find(java.lang.String, java.lang.String, java.lang.String).
      Parameters:
      aPackage - package name where each package is separated by a dot
      name - name of the file (without dots) or null if one wants to obtain the name of a package and not a file in it
      ext - extension of the file or null if one needs a package and not a file name
      Returns:
      enumeration of FileObjects
    • addRepositoryListener

      @Deprecated public final void addRepositoryListener(RepositoryListener list)
      Deprecated.
      Please use the ClassPath API instead.
      Adds new listener.
      Parameters:
      list - the listener
    • removeRepositoryListener

      @Deprecated public final void removeRepositoryListener(RepositoryListener list)
      Deprecated.
      Please use the ClassPath API instead.
      Removes listener.
      Parameters:
      list - the listener
    • addFileChangeListener

      @Deprecated public final void addFileChangeListener(FileChangeListener fcl)
      Deprecated.
      useless because there is no filesystem but only default filesystem in Repository. Add new listener directly to default filesystem getDefaultFileSystem().
      Add new listener to this object.
      Parameters:
      fcl - the listener
      Since:
      2.8
    • removeFileChangeListener

      @Deprecated public final void removeFileChangeListener(FileChangeListener fcl)
      Deprecated.
      useless because there is no filesystem but only default filesystem in Repository. Add new listener directly to default filesystem getDefaultFileSystem().
      Remove listener from this object.
      Parameters:
      fcl - the listener
      Since:
      2.8