org.openide.filesystems 8.5.1

org.openide.filesystems
Class Repository.LayerProvider

java.lang.Object
  extended by org.openide.filesystems.Repository.LayerProvider
Enclosing class:
Repository

public abstract static class Repository.LayerProvider
extends Object

Contributes to content of system file system (which influences structure under FileUtil.getConfigRoot()). The method registerLayers(java.util.Collection) is called during initialization of Repository and implementors (registered via ServiceProvider annotation) may add their layers (later processed via XMLFileSystem) into the general collection of existing providers.

The list of layers as well as their content may be cached. In a typical NetBeans Platform application, the cache remains until list of modules and their enabled state remain the same. While it does, the Repository.LayerProviders are not queried again.

You can show a dialog letting the user log in to some server, you can call LoginProvider.injectLayer(...) with the URL to an XML layer. The contents of the layer will become available only after login.

 @ServiceProviders({
     @ServiceProvider(service=LoginProvider.class),
     @ServiceProvider(service=LayerProvider.class)
 })
 public final class LoginProvider extends LayerProvider {
     private URL layer;
 
     public void registerLayers(Collection<? super URL> arr) {
         if (layer != null) {
             arr.add(layer);
         }
     }
 
     public static void injectLayer(URL u) {
         LoginProvider lp = Lookup.getDefault().lookup(LoginProvider.class);
         lp.url = u;
         lp.refresh();
     }
 }
 
The additional layers are inserted below traditional layers provided by modules in so called fallback mode - e.g. modules can override and redefine layers contributed by layer providers.

Since:
7.59

Constructor Summary
Repository.LayerProvider()
           
 
Method Summary
protected  void refresh()
          Method to call when set of URLs returned from the #layers() method changed and there is a need to refresh it.
protected abstract  void registerLayers(Collection<? super URL> context)
          Allows providers to add their additions to the structure beneath FileUtil.getConfigRoot().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Repository.LayerProvider

public Repository.LayerProvider()
Method Detail

registerLayers

protected abstract void registerLayers(Collection<? super URL> context)
Allows providers to add their additions to the structure beneath FileUtil.getConfigRoot(). The method is supposed to collect all additional layers and add them into the context collection. The provided layers will be processed by XMLFileSystem-like manner later.

Parameters:
context - the context where to register the additions

refresh

protected final void refresh()
Method to call when set of URLs returned from the #layers() method changed and there is a need to refresh it. Refresh is very likely a time consuming task - consider invoking it on a background thread and don't hold any locks while calling the method


org.openide.filesystems 8.5.1

Built on June 6 2013.  |  Portions Copyright 1997-2013 Oracle. All rights reserved.