GraphLab Project

graphlab.platform.plugin
Class Plugger

java.lang.Object
  extended by graphlab.platform.plugin.Plugger

public class Plugger
extends java.lang.Object

GraphLab plugging functionality is provided here.

Class Plugger, is the heart of plugin structure. In order to gather all the plugins, you need to gather all the possible libraries(.jar) files to the project. The method plug() does this using Java Reflection API and Java Class Loader.

After this, you need to read the manifest files. This is done via Java JarFile class. other properties of the plugin like its version , the dependencies and the answer to the question that this plugin should be loaded to GraphLab should be answered here. Method init(File) gets a jar file and checks all the mentioned actions using helper methods verify(), dfs(), load() and remove().

verify() reads a HashMap called depends. This Map is filled in the init() method using the property reader of JarFile class. It reads all the dependencies that are mentioned in the jar file. These are only related to version dependencies.

dfs() tries a DFS algorithm to topologically sort the dependencies tree and then use the sorted trees to give priority to plugin loads.

Author:
Reza Mohammadi

Field Summary
 int activePlugins
           
 java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> childs
           
 java.net.URLClassLoader classLoader
           
 java.util.HashMap<java.lang.String,java.lang.String> configxml
           
 java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.Object[]>> depends
           
 java.util.HashMap<java.lang.String,java.io.File> files
           
 java.lang.String handler_postfix
           
 java.util.HashMap<java.lang.String,java.lang.String> initializer
           
 java.util.HashMap<java.lang.String,java.lang.Integer> mark
           
static java.lang.String PLUGGER_INSTANCE
           
 java.lang.String postfix
           
 java.lang.String prefix
           
 java.util.HashMap<java.lang.String,java.lang.Long> versions
           
 
Constructor Summary
Plugger(BlackBoard blackboard)
           
 
Method Summary
 void dfs(java.lang.String name)
          DFS to find a topological sort of plugins.
static java.lang.String getExtension(java.io.File f)
          Return the extension portion of the file's name .
 void init(java.io.File ff)
          Read manifest of a jar file and make that plugin candidate to be loaded.
 void load(java.lang.String name)
          Load and initialize a plugin.
 void plug()
          Search plugins directory and add jar files to Graphlab.
 void remove(java.lang.String name)
          Remove a "plugin candidate" because of lack of dependencies.
 void verify()
          Check dependencies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prefix

public final java.lang.String prefix
See Also:
Constant Field Values

postfix

public final java.lang.String postfix
See Also:
Constant Field Values

handler_postfix

public final java.lang.String handler_postfix
See Also:
Constant Field Values

PLUGGER_INSTANCE

public static final java.lang.String PLUGGER_INSTANCE
See Also:
Constant Field Values

versions

public java.util.HashMap<java.lang.String,java.lang.Long> versions

files

public java.util.HashMap<java.lang.String,java.io.File> files

mark

public java.util.HashMap<java.lang.String,java.lang.Integer> mark

initializer

public java.util.HashMap<java.lang.String,java.lang.String> initializer

configxml

public java.util.HashMap<java.lang.String,java.lang.String> configxml

depends

public java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.Object[]>> depends

childs

public java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> childs

classLoader

public java.net.URLClassLoader classLoader

activePlugins

public int activePlugins
Constructor Detail

Plugger

public Plugger(BlackBoard blackboard)
Method Detail

plug

public void plug()
Search plugins directory and add jar files to Graphlab. And add all jar files in plgins directory and lib directory to classLoader


init

public void init(java.io.File ff)
Read manifest of a jar file and make that plugin candidate to be loaded.

Parameters:
ff - file object

remove

public void remove(java.lang.String name)
Remove a "plugin candidate" because of lack of dependencies.

Parameters:
name - Name of plugin

verify

public void verify()
Check dependencies


dfs

public void dfs(java.lang.String name)
DFS to find a topological sort of plugins.

Parameters:
name - Name of plugin

load

public void load(java.lang.String name)
Load and initialize a plugin. if plugin has defined plugin-initializer or has graphlab.plugins.pluginname.Init, Then the init class of plugin will be loaded. Else if plugin has defined plugin-configxml (or using default = "/graphlab/gui/plugin/pluginname/config.xml"), then this function search parents of this plugin to find a PluginHandlerInterface and send path of config.xml to that handler.

Parameters:
name - Name of plugin
See Also:
PluginInterface.init(graphlab.platform.core.BlackBoard), PluginHandlerInterface.init(String,graphlab.platform.core.BlackBoard)

getExtension

public static java.lang.String getExtension(java.io.File f)
Return the extension portion of the file's name .

See Also:
getExtension(java.io.File), FileFilter.accept(java.io.File)

GraphLab Project