at.spardat.xma.plugins
Class PluginManager

java.lang.Object
  extended byat.spardat.xma.plugins.PluginManager
Direct Known Subclasses:
PluginManagerClient, PluginManagerServer

public abstract class PluginManager
extends java.lang.Object

Base class for client and server side plugin managers.


Constructor Summary
PluginManager()
           
 
Method Summary
 java.lang.Object getPlugin(java.lang.Class pluginInterface)
          Finds the configured Plugin implementing the given interface.
 java.lang.Object getPlugin(java.lang.String interfaceName)
          Returns a plugin implementation for a specified interface name.
 java.lang.Object getPlugin(java.lang.String interfaceName, java.lang.ClassLoader cl)
          Returns a plugin implementation for a specified interface name.
 boolean isPluginDeclared(java.lang.Class pluginInterface)
          Checks if a plugin is configured for the given interface.
abstract  boolean isPluginDeclared(java.lang.String interfaceName)
          Checks if a plugin is configured for the given interface.
protected  java.lang.Object newInstanceOf(java.lang.String className, java.lang.ClassLoader loader)
          Uses the default constructor to construct an instance of a given class's name in a provided ClassLoader and returns it.
protected abstract  java.lang.Object resolvePlugin(java.lang.String interfaceName, java.lang.ClassLoader cl)
          Resolves a plugin implementation for a specified interface name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginManager

public PluginManager()
Method Detail

getPlugin

public java.lang.Object getPlugin(java.lang.Class pluginInterface)
Finds the configured Plugin implementing the given interface.

Parameters:
pluginInterface - the interface of the plugin to find.
Returns:
the found Plugin implementation
Throws:
java.lang.RuntimeException - if no implementation is configured for the interface.

getPlugin

public java.lang.Object getPlugin(java.lang.String interfaceName)
Returns a plugin implementation for a specified interface name.

Parameters:
interfaceName - the fully qualified name of a java interface, specifying the interface the implementation has to implement. Both, the interface and the implementation must be loadable by the classloader that loaded this class.
Returns:
an object implementing the provided interface.
Throws:
java.lang.RuntimeException - if no implementation is configured for the interface.

getPlugin

public java.lang.Object getPlugin(java.lang.String interfaceName,
                                  java.lang.ClassLoader cl)
Returns a plugin implementation for a specified interface name. Once an implementation for a particular interface is found, it is cached inside the PluginManager and future calls always return the same instance.

Parameters:
interfaceName - the fully qualified name of a java interface, specifying the interface the implementation has to implement. Both, the interface and the implementation must be loadable by the classloader that loaded this class.
cl - the ClassLoader where the implementation class can be loaded from.
Returns:
an object implementing the provided interface.
Throws:
java.lang.RuntimeException - if no implementation is configured for the interface.

resolvePlugin

protected abstract java.lang.Object resolvePlugin(java.lang.String interfaceName,
                                                  java.lang.ClassLoader cl)
Resolves a plugin implementation for a specified interface name. This method is called just once per interface name. It is required that this operation should terminate as fast as possible, optimally just constructing the implementation object.

Parameters:
interfaceName - the fully qualified name of a java interface, specifying the interface the implementation has to implement. Both, the interface and the implementation must be loadable by the classloader that loaded this class.
cl - the ClassLoader where the implementation class can be loaded from.
Returns:
an object implementing the provided interface.

newInstanceOf

protected java.lang.Object newInstanceOf(java.lang.String className,
                                         java.lang.ClassLoader loader)
Uses the default constructor to construct an instance of a given class's name in a provided ClassLoader and returns it.

Throws:
at.spardat.enterprise.exc.SysException - with code Codes.PLUGIN_CANNOT_CONSTRUCT_OBJECT on faults.

isPluginDeclared

public boolean isPluginDeclared(java.lang.Class pluginInterface)
Checks if a plugin is configured for the given interface. If called on client side, it checks for the definition of a client side implementaition. If called on server side, it checks for the definition of a server side implementation.

Parameters:
pluginInterface - the interface of the plugin to find.
Returns:
true if a plugin is declared for the given interface in xma-app.xml, false otherwise.

isPluginDeclared

public abstract boolean isPluginDeclared(java.lang.String interfaceName)
Checks if a plugin is configured for the given interface. If called on client side, it checks for the definition of a client side implementaition. If called on server side, it checks for the definition of a server side implementation.

Parameters:
interfaceName - the fully qualified name of a java interface, specifying the interface the plugin has to implement.
Returns:
true if a plugin is declared for the given interface in xma-app.xml, false otherwise.