org.freehep.application.studio
Class PluginMap

java.lang.Object
  extended by org.freehep.application.studio.PluginMap

public class PluginMap
extends Object

Data structure that supports operations on installed plugins and libraries. FIXME: 1. getActivePlugins is called again from getActiveLibraries 2. do I need version checking in getActivePlugins ?

Author:
onoprien

Constructor Summary
PluginMap(Studio application)
          Constructs PluginMap by scanning application extension directories.
 
Method Summary
 PluginMap add(Collection<PluginInfo> plugins)
          Creates a PluginMap that can be used to download and install the specified plugins.
 boolean commit(PluginMap update)
          Installs plugins and libraries contained in the update map.
 Map<String,LibInfo> getActiveLibraries()
           
 Map<String,PluginInfo> getActivePlugins()
          Returns a map of names to descriptors for all currently active plugins.
 Set<PluginInfo> getDependentPlugins(PluginInfo plugin)
          Returns a set of dependents (direct and transient) of the specified plugin.
 Map<File,String> getDownloads()
          Returns a "path to url" map of library files in this map.
 URL[] getExtensionClasspath()
           
 List<LibInfo> getLibraries()
          Returns a list of all library descriptors in this map.
 LibInfo getLibrary(String id, PluginDir dir)
          Returns library descriptor for the specified ID and directory.
 PluginInfo getPlugin(String name)
          Returns active plugin descriptor with the specified name.
 PluginInfo getPlugin(String name, PluginDir dir)
          Returns a plugin descriptor for the specified plugin name and directory.
 List<PluginInfo> getPlugins()
          Returns a list of all plugin descriptors in this map.
 Map<String,PluginInfo> getPlugins(PluginDir dir)
          Returns a map of plugin names to descriptors in the specified directory.
 void purge()
          Purges unused libraries.
 boolean remove(Collection<PluginInfo> plugins)
          Removes the specified plugins from this map and deletes (or marks for deletion) the files that are no longer needed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginMap

public PluginMap(Studio application)
Constructs PluginMap by scanning application extension directories. Attempts de delete empty files while scanning.

Method Detail

add

public PluginMap add(Collection<PluginInfo> plugins)
Creates a PluginMap that can be used to download and install the specified plugins. This method should be called on the application master map, which is not modified as a result of the call. The returned map can be used to get a collection of required downloads through a call to getDownloads(). Once the files are downloaded, it can be passed to the master map's #commit() method to install or update the plugins.

Parameters:
plugins - Collection of plugins to be installed. Must contain all required dependencies.
Returns:
PluginMap that contains only plugins that have to be installed. For each library, getFile() will return the path where the file needs to be downloaded, or null if the same or newer version of this library is already installed.

commit

public boolean commit(PluginMap update)
Installs plugins and libraries contained in the update map.

Parameters:
update -
Returns:
True if the update cannot be immediately loaded and therefore requires restart.

remove

public boolean remove(Collection<PluginInfo> plugins)
Removes the specified plugins from this map and deletes (or marks for deletion) the files that are no longer needed.

Parameters:
plugins - Collection of plugins to be removed. Should not contain dependencies of other plugins - no checking is done by this method.
Returns:
True if restart is required before the changes can take effect.

getDownloads

public Map<File,String> getDownloads()
Returns a "path to url" map of library files in this map. This method should only be called on maps returned by add(java.util.Collection).


purge

public void purge()
Purges unused libraries. Libraries not claimed by any plugins are deleted.


getActivePlugins

public Map<String,PluginInfo> getActivePlugins()
Returns a map of names to descriptors for all currently active plugins. A plugin is active if it would be loaded in the application was starting now.


getActiveLibraries

public Map<String,LibInfo> getActiveLibraries()

getExtensionClasspath

public URL[] getExtensionClasspath()

getPlugins

public List<PluginInfo> getPlugins()
Returns a list of all plugin descriptors in this map.


getPlugins

public Map<String,PluginInfo> getPlugins(PluginDir dir)
Returns a map of plugin names to descriptors in the specified directory.


getPlugin

public PluginInfo getPlugin(String name)
Returns active plugin descriptor with the specified name. Returns null if there is no such plugin in this map.


getPlugin

public PluginInfo getPlugin(String name,
                            PluginDir dir)
Returns a plugin descriptor for the specified plugin name and directory. Returns null if there is no such plugin in this map.


getLibraries

public List<LibInfo> getLibraries()
Returns a list of all library descriptors in this map.


getLibrary

public LibInfo getLibrary(String id,
                          PluginDir dir)
Returns library descriptor for the specified ID and directory. Returns null if there is no such library in this map.


getDependentPlugins

public Set<PluginInfo> getDependentPlugins(PluginInfo plugin)
Returns a set of dependents (direct and transient) of the specified plugin. Only looks for dependents installed in the same directory. No version checking is done.



Copyright © 2000-2013 FreeHEP. All Rights Reserved.