com.unitesk.atp.tool
Class PluginManagerClass

java.lang.Object
  extended by com.unitesk.atp.tool.PluginManagerClass
All Implemented Interfaces:
PluginManager
Direct Known Subclasses:
PluginManagerClass, Tool

public class PluginManagerClass
extends Object
implements PluginManager

Plugin manager default implementation.

Version:
$Id: PluginManagerClass.java,v 1.3 2004/10/11 15:00:44 all-x Exp $
Author:
Alexey Demakov

Field Summary
protected  Properties config
          The set of application properties.
protected  MessageBox mbox
          The message box for application messages.
protected  String name
          Plugin manager name.
protected  DynamicVariablesTable table
          The table of plugins initialized from resource file.
 
Constructor Summary
PluginManagerClass()
          Default constructor.
PluginManagerClass(String name, MessageBox mbox, Properties config, InputStream in)
          Constructs plugin manager with the specified parameters.
 
Method Summary
protected  void createPluginsTable()
          Creates plugins table and set table field.
 MessageBox getMessageBox()
          Returns message box.
 String getName()
          Get plugin manager name.
 Object getPlugin(String name)
          Returns the plugin with the specified name.
 String getPluginProperty(Object plugin, String name)
          Gets the value of a plugin property with the specified name for the specified plugin.
 String getPluginProperty(Object plugin, String name, String value)
          Gets the value of a plugin property with the specified name for the specified plugin or default value if this property is not defined.
 String getPluginPropertyName(Object plugin, String name)
          Gets the qualified property name for plugin property name of the specified plugin.
 String getProperty(String name)
          Get property value for the specified property name.
 String getProperty(String name, String value)
          Get property value for the specified property name.
protected  void help(List pluginNames)
          Prints help messages for plugins.
protected  void initConfig()
           
protected  void initMessageBox()
           
protected  void initName()
           
protected  void initPluginsTable()
           
protected  void loadPlugins(InputStream in)
          Loads plugins from the specified input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name
Plugin manager name.


mbox

protected MessageBox mbox
The message box for application messages.


config

protected Properties config
The set of application properties. Can be inited as constructor parameter or by overloading initConfig() method.


table

protected DynamicVariablesTable table
The table of plugins initialized from resource file. Can be inited as constructor parameter or by overloading initPluginsTable() method.

Constructor Detail

PluginManagerClass

public PluginManagerClass(String name,
                          MessageBox mbox,
                          Properties config,
                          InputStream in)
                   throws IOException,
                          ClassNotFoundException
Constructs plugin manager with the specified parameters.

Parameters:
name - the plugin manager name
mbox - the plugin manager message box. If it is null no message box will be available for plugins.
config - the set of properties. It can be null.
in - the input stream to read plugin table from.
Throws:
IOException
ClassNotFoundException

PluginManagerClass

public PluginManagerClass()
Default constructor. Calls initName(), initConfig(), initMessageBox(), initPluginsTable(). These methods should be overriden by inheritor if it use this constructor.

Method Detail

initName

protected void initName()

initConfig

protected void initConfig()

initMessageBox

protected void initMessageBox()

initPluginsTable

protected void initPluginsTable()

getName

public String getName()
Get plugin manager name.

Specified by:
getName in interface PluginManager

getMessageBox

public MessageBox getMessageBox()
Returns message box.

Specified by:
getMessageBox in interface PluginManager

getPlugin

public Object getPlugin(String name)
Returns the plugin with the specified name.

Specified by:
getPlugin in interface PluginManager
Parameters:
name - The plugin name.
Returns:
The plugin with the specified name or null.

getProperty

public final String getProperty(String name)
Get property value for the specified property name. The default implementation of plugin manager searches in config properties set then in system properties.

Parameters:
name - the specified property name.
Returns:
property value or null if no such property specified.

getProperty

public final String getProperty(String name,
                                String value)
Get property value for the specified property name. The default implementation of plugin manager searches in config properties set then in system properties.

Parameters:
name - the specified property name.
value - the default property value.
Returns:
property value or value if no such property specified.

getPluginPropertyName

public String getPluginPropertyName(Object plugin,
                                    String name)
Gets the qualified property name for plugin property name of the specified plugin.

Specified by:
getPluginPropertyName in interface PluginManager
Parameters:
plugin - The specified plugin.
name - The name of plugin property.
Returns:
The corresponding qualified property name. For plugin property property.name of plugin with name plugin of manager manager qualified property name is manager.plugin.property.name.
See Also:
DynamicVariablesTable.getPropertyName(Object,String)

getPluginProperty

public String getPluginProperty(Object plugin,
                                String name)
Gets the value of a plugin property with the specified name for the specified plugin.

Specified by:
getPluginProperty in interface PluginManager
Parameters:
plugin - The specified plugin.
name - The name of plugin property.
Returns:
The value of the plugin property for the specified plugin.
See Also:
DynamicVariablesTable.getProperty(Object,String)

getPluginProperty

public String getPluginProperty(Object plugin,
                                String name,
                                String value)
Gets the value of a plugin property with the specified name for the specified plugin or default value if this property is not defined.

Specified by:
getPluginProperty in interface PluginManager
Parameters:
plugin - The specified plugin.
name - The name of plugin property.
value - The default value is used if for the specified plugin there is no property with the specified name.
Returns:
The value of the plugin property for the specified plugin.
See Also:
DynamicVariablesTable.getProperty(Object,String,String)

createPluginsTable

protected void createPluginsTable()
Creates plugins table and set table field.


loadPlugins

protected void loadPlugins(InputStream in)
                    throws IOException,
                           ClassNotFoundException
Loads plugins from the specified input stream. If plugins table is not created yet call createPluginsTable().

Parameters:
in - the input stream to load plugins from.
Throws:
IOException - if the was I/O error while reading input stream.
ClassNotFoundException - if class specified in plugin table was not fount.
NullPointerException - if in is null.

help

protected void help(List pluginNames)
Prints help messages for plugins.

Parameters:
pluginNames - the list of plugin names If pluginNames is null or pluginNames.size() is 0 prints the list of available plugins otherwise - help message for each plugin


Copyright © 2001-2006 ISP RAS, RedVerst Group. All Rights Reserved.