org.specrunner.plugins
Interface IPluginFactory

All Known Subinterfaces:
IPluginFactoryGroup
All Known Implementing Classes:
PluginFactoryAttribute, PluginFactoryCSS, PluginFactoryCustom, PluginFactoryElement, PluginFactoryGroupDefault, PluginFactoryGroupImpl, PluginFactoryImpl, PluginFactoryText

public interface IPluginFactory

Stands for a plugin factory.

Author:
Thiago Santos

Method Summary
 IPluginFactory bind(PluginKind kind, String alias, IPlugin plugin)
          Bind a plugin instance to a given kind.
 boolean finalizePlugin(nu.xom.Node source, IContext context, IPlugin plugin)
          Finalize a plugin.
 String getAlias(Class<? extends IPlugin> type)
          Given a class, for example, return the corresponding alias for the plugin.
 Class<? extends IPlugin> getClass(String alias)
          Given a name, return the corresponding plugin class associated. i.e.
 IPlugin newPlugin(nu.xom.Node source, IContext context)
          Creates a new plugin.
 

Method Detail

getClass

Class<? extends IPlugin> getClass(String alias)
                                  throws PluginException
Given a name, return the corresponding plugin class associated. i.e. For 'include' the class PluginInclude of core plugins package is returned or if 'bean' is requested the PluginBean is returned.

Parameters:
alias - The plugin alias.
Returns:
The class, if type is mapped, null, otherwise.
Throws:
PluginException - On reference lookup failure.

getAlias

String getAlias(Class<? extends IPlugin> type)
                throws PluginException
Given a class, for example, return the corresponding alias for the plugin.

Parameters:
type - The plugin type, i.e. 'PluginInclude.class', 'PluginConnection', etc.
Returns:
The alias, if type is mapped, null, otherwise. Null does not means a invalid plugin, but the plugin is either not mapped in the usual way, or the factory of plugins is not based on alias premises.
Throws:
PluginException - On alias lookup name failure.

bind

IPluginFactory bind(PluginKind kind,
                    String alias,
                    IPlugin plugin)
                    throws PluginException
Bind a plugin instance to a given kind.

Parameters:
kind - The plugin kind.
alias - The alias.
plugin - The plugin instance.
Returns:
The factory itself.
Throws:
PluginException - On bind errors.

newPlugin

IPlugin newPlugin(nu.xom.Node source,
                  IContext context)
                  throws PluginException
Creates a new plugin.

Parameters:
source - The source node for plugin creation.
context - The context.
Returns:
A plugin based on source information.
Throws:
PluginException - On creation error.

finalizePlugin

boolean finalizePlugin(nu.xom.Node source,
                       IContext context,
                       IPlugin plugin)
                       throws PluginException
Finalize a plugin.

Parameters:
source - The source Node..
context - The context.
plugin - The previously created plugin for this node.
Returns:
true, if finalized, false, otherwise.
Throws:
PluginException - On finalization error.


Copyright © 2014. All rights reserved.