org.mmbase.bridge.implementation
Class ModuleHandler

java.lang.Object
  extended byorg.mmbase.bridge.implementation.ModuleHandler
All Implemented Interfaces:
Comparable, InvocationHandler, Module

public class ModuleHandler
extends Object
implements Module, Comparable, InvocationHandler

ModuleHandler Creates a framework for calling modules. Supports calls to the methods supported by the MMBase ProcessorModules.

Version:
$Id: ModuleHandler.java,v 1.31 2006/01/02 19:17:47 michiel Exp $
Author:
Pierre van Rooden, Rob Vermeulen

Method Summary
 int compareTo(Object o)
          Compares this module to the passed object.
 Parameters createParameters(String functionName)
          Creates a parameter list for a function.
 boolean equals(Object o)
          Compares two modules, and returns true if they are equal.
protected  Cloud getCloud(Map parameters)
           
 CloudContext getCloudContext()
          Retrieves the CloudContext to which this module belongs
 String getDescription()
          Retrieve the description of the module.
 Function getFunction(String functionName)
          Returns a Fuction object.
 Collection getFunctions()
          Returns all the Function objects of this Module.
 FieldValue getFunctionValue(String functionName, List parameters)
          Executes a function on this module with the given parameters, and returns the result.
 String getInfo(String command)
          Retrieve info from a module based on a command string.
 String getInfo(String command, ServletRequest req, ServletResponse resp)
          Retrieve info from a module based on a command string Similar to the $MOD command in SCAN.
 NodeList getList(String command, Map parameters)
          Retrieve info (as a list of virtual nodes) from a module based on a command string.
 NodeList getList(String command, Map parameters, ServletRequest req, ServletResponse resp)
          Retrieve info from a module based on a command string Similar to the LIST command in SCAN.
static Module getModule(Module mod, CloudContext cloudcontext)
           
 String getName()
          Retrieve the name of the module (in the default language defined in mmbaseroot.xml).
 Map getProperties()
          Retrieve a copy of the module's properties
 String getProperty(String name)
          Retrieve a property of the module.
 Object invoke(Object proxy, Method method, Object[] args)
           
 void process(String command, Object parameter)
          Runs the command with the given parameter(s).
 void process(String command, Object parameter, Map auxparameters)
          Runs the command with the given parameter(s).
 void process(String command, Object parameter, Map auxparameters, ServletRequest req, ServletResponse resp)
          Runs the command with the given parameter(s).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getModule

public static Module getModule(Module mod,
                               CloudContext cloudcontext)

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

getCloudContext

public CloudContext getCloudContext()
Description copied from interface: Module
Retrieves the CloudContext to which this module belongs

Specified by:
getCloudContext in interface Module
Returns:
CloudContext

getCloud

protected Cloud getCloud(Map parameters)

getName

public String getName()
Description copied from interface: Module
Retrieve the name of the module (in the default language defined in mmbaseroot.xml).

Specified by:
getName in interface Module
Returns:
name of the module

getProperty

public String getProperty(String name)
Description copied from interface: Module
Retrieve a property of the module.

Specified by:
getProperty in interface Module
Parameters:
name - the name of the property
Returns:
the property value (null if not given)

getProperties

public Map getProperties()
Description copied from interface: Module
Retrieve a copy of the module's properties

Specified by:
getProperties in interface Module
Returns:
a map of module properties

getDescription

public String getDescription()
Description copied from interface: Module
Retrieve the description of the module.

Specified by:
getDescription in interface Module
Returns:
description of the module

getInfo

public String getInfo(String command)
Description copied from interface: Module
Retrieve info from a module based on a command string. Similar to the $MOD command in SCAN.

Specified by:
getInfo in interface Module
Parameters:
command - the info to obtain, i.e. "USER-OS".
Returns:
info from a module

getInfo

public String getInfo(String command,
                      ServletRequest req,
                      ServletResponse resp)
Description copied from interface: Module
Retrieve info from a module based on a command string Similar to the $MOD command in SCAN.

Specified by:
getInfo in interface Module
Parameters:
command - the info to obtain, i.e. "USER-OS".
req - the Request item to use for obtaining user information. For backward compatibility.
resp - the Response item to use for redirecting users. For backward compatibility.
Returns:
info from a module

process

public void process(String command,
                    Object parameter)
Description copied from interface: Module
Runs the command with the given parameter(s).

Specified by:
process in interface Module
Parameters:
command - the command to run, i.e. "MESSAGE-UPDATE".
parameter - the main parameter for the command. Depends on the command issued. Not all commands make use of this parameter.

process

public void process(String command,
                    Object parameter,
                    Map auxparameters)
Description copied from interface: Module
Runs the command with the given parameter(s).

Specified by:
process in interface Module
Parameters:
command - the command to run, i.e. "MESSAGE-UPDATE".
parameter - the main parameter for the command. Depends on the command issued. Not all commands make use of this parameter.
auxparameters - additional parameters for this command.

process

public void process(String command,
                    Object parameter,
                    Map auxparameters,
                    ServletRequest req,
                    ServletResponse resp)
Description copied from interface: Module
Runs the command with the given parameter(s).

Specified by:
process in interface Module
Parameters:
command - the command to run, i.e. "MESSAGE-UPDATE".
parameter - the main parameter for the command. Depends on the command issued. Not all commands make use of this parameter.
auxparameters - additional parameters for this command.
req - the Request item to use for obtaining user information. For backward compatibility.
resp - the Response item to use for redirecting users. For backward compatibility.

getList

public NodeList getList(String command,
                        Map parameters)
Description copied from interface: Module
Retrieve info (as a list of virtual nodes) from a module based on a command string. Similar to the LIST command in SCAN. The values retrieved are represented as fields of a virtual node, named following the fieldnames listed in the fields paramaters..

Specified by:
getList in interface Module
Parameters:
command - the info to obtain, i.e. "USER-OS".
parameters - a hashtable containing the named parameters of the list.
Returns:
info from a module (as a list of virtual nodes)

getList

public NodeList getList(String command,
                        Map parameters,
                        ServletRequest req,
                        ServletResponse resp)
Description copied from interface: Module
Retrieve info from a module based on a command string Similar to the LIST command in SCAN. The values retrieved are represented as fields of a virtual node, named following the fieldnames listed in the fields paramaters..

Specified by:
getList in interface Module
Parameters:
command - the info to obtain, i.e. "USER-OS".
parameters - a hashtable containing the named parameters of the list.
req - the Request item to use for obtaining user information. For backward compatibility.
resp - the Response item to use for redirecting users. For backward compatibility.
Returns:
info from a module (as a list of virtual nodes)

compareTo

public int compareTo(Object o)
Compares this module to the passed object. Returns 0 if they are equal, -1 if the object passed is a NodeManager and larger than this manager, and +1 if the object passed is a NodeManager and smaller than this manager. A module is 'larger' than another module if its name is larger (alphabetically, case sensitive) than that of the other module. If names are the same, the modules are compared on cloud context.

Specified by:
compareTo in interface Comparable
Parameters:
o - the object to compare it with

equals

public boolean equals(Object o)
Compares two modules, and returns true if they are equal.

Parameters:
o - the object to compare it with

getFunctions

public Collection getFunctions()
Description copied from interface: Module
Returns all the Function objects of this Module.

Specified by:
getFunctions in interface Module
Returns:
a Collection of Function objects.

getFunction

public Function getFunction(String functionName)
Description copied from interface: Module
Returns a Fuction object. The object returned is a Function object. You need to explixitly cast the result to this object, since not all bridge implementations (i.e. the RMMCI) support this class.

Specified by:
getFunction in interface Module
Parameters:
functionName - name of the function
Returns:
a Function object.

createParameters

public Parameters createParameters(String functionName)
Description copied from interface: Module
Creates a parameter list for a function. The list can be filled with parameter values by either using the List set(int, Object) method, to set values for parameters by psoition, or by using the set(String, Object) method to set parameters by name.
This object can then be passed to the getFunctionValue method. Note that adding extra parameters (with the add(Object) method) won't work and may cause exceptions.

Specified by:
createParameters in interface Module
Parameters:
functionName - name of the function
Returns:
a Parameters object.

getFunctionValue

public FieldValue getFunctionValue(String functionName,
                                   List parameters)
Description copied from interface: Module
Executes a function on this module with the given parameters, and returns the result.

Specified by:
getFunctionValue in interface Module
Parameters:
functionName - name of the function
parameters - list with parameters for the fucntion
Returns:
the result value of executing the function


MMBase build 1.8.1.20060716