public abstract static class Repository.LayerProvider extends Object
system file system
(which influences structure under FileUtil.getConfigRoot()
). The
method Repository.LayerProvider.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.LayerProvider
s
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.
The additional layers are inserted below traditional layers provided by modules in so called@
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(); } }
fallback mode
- e.g. modules
can override and redefine layers contributed by layer providers.Constructor and Description |
---|
LayerProvider() |
Modifier and Type | Method and Description |
---|---|
protected void |
refresh()
Method to call when set of URLs returned from the
Repository.LayerProvider.registerLayers(java.util.Collection)
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() . |
protected abstract void registerLayers(Collection<? super URL> context)
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.context
- the context where to register the additionsprotected final void refresh()
Repository.LayerProvider.registerLayers(java.util.Collection)
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