+ Providers of implementation of + ContentProvider + interface can contribute to the content of system file system. +
++ * 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 enablement state remain the same. While it does, the {@link LayersProvider}s + * are not queried again. + *
+ * @since 7.49 + */ + public static abstract class LayersProvider { + /** Ordered list of {@link URL}s to with {@link XMLFileSystem}-like + * definitions to process + * @return list of URLs + */ + protected abstract List extends URL> layers(); + + /** Method to call when set of URLs returned from the {@link #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 + */ + protected final void refresh() { + Repository.getDefault().refreshAdditionalLayers(); + } + } + + /** Methods that tells {@link Repository} subclasses to refresh list of + * URLs provided by {@link LayersProvider}s. + * @since 7.49 + */ + protected void refreshAdditionalLayers() { + if (getDefaultFileSystem() instanceof MainFS) { + ((MainFS)getDefaultFileSystem()).refreshLayers(); + } + } + + /** Allows subclasses registered as {@link Repository#getDefault()} to + * find out list of URLs for a given provider. The method just calls + * {@link LayersProvider#layers()}. + * + * @param p the provider. + * @return ordered list of URLs + * @since 7.49 + */ + protected final List extends URL> findLayers(LayersProvider p) { + if (this != Repository.getDefault()) { + return Collections.emptyList(); + } + return p.layers(); + } private static final class MainFS extends MultiFileSystem implements LookupListener { private static final Lookup.Result