org.specrunner.plugins.core.factories
Class PluginFactoryGroupImpl

java.lang.Object
  extended by org.specrunner.util.composite.core.CompositeImpl<IPluginFactoryGroup,IPluginFactory>
      extended by org.specrunner.plugins.core.factories.PluginFactoryGroupImpl
All Implemented Interfaces:
IPluginFactory, IPluginFactoryGroup, IComposite<IPluginFactoryGroup,IPluginFactory>
Direct Known Subclasses:
PluginFactoryGroupDefault

public class PluginFactoryGroupImpl
extends CompositeImpl<IPluginFactoryGroup,IPluginFactory>
implements IPluginFactoryGroup

Default factory group implementation.

Author:
Thiago Santos

Constructor Summary
PluginFactoryGroupImpl()
           
 
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 node, IContext context)
          Creates a new plugin.
 
Methods inherited from class org.specrunner.util.composite.core.CompositeImpl
add, getChildren, isEmpty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.specrunner.util.composite.IComposite
add, getChildren, isEmpty
 

Constructor Detail

PluginFactoryGroupImpl

public PluginFactoryGroupImpl()
Method Detail

newPlugin

public IPlugin newPlugin(nu.xom.Node node,
                         IContext context)
                  throws PluginException
Description copied from interface: IPluginFactory
Creates a new plugin.

Specified by:
newPlugin in interface IPluginFactory
Parameters:
node - The source node for plugin creation.
context - The context.
Returns:
A plugin based on source information.
Throws:
PluginException - On creation error.

getClass

public Class<? extends IPlugin> getClass(String alias)
                                  throws PluginException
Description copied from interface: IPluginFactory
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.

Specified by:
getClass in interface IPluginFactory
Parameters:
alias - The plugin alias.
Returns:
The class, if type is mapped, null, otherwise.
Throws:
PluginException - On reference lookup failure.

getAlias

public String getAlias(Class<? extends IPlugin> type)
                throws PluginException
Description copied from interface: IPluginFactory
Given a class, for example, return the corresponding alias for the plugin.

Specified by:
getAlias in interface IPluginFactory
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

public IPluginFactory bind(PluginKind kind,
                           String alias,
                           IPlugin plugin)
                    throws PluginException
Description copied from interface: IPluginFactory
Bind a plugin instance to a given kind.

Specified by:
bind in interface IPluginFactory
Parameters:
kind - The plugin kind.
alias - The alias.
plugin - The plugin instance.
Returns:
The factory itself.
Throws:
PluginException - On bind errors.

finalizePlugin

public boolean finalizePlugin(nu.xom.Node source,
                              IContext context,
                              IPlugin plugin)
                       throws PluginException
Description copied from interface: IPluginFactory
Finalize a plugin.

Specified by:
finalizePlugin in interface IPluginFactory
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.