org.mmbase.bridge.implementation
Class ModuleHandler

java.lang.Object
  extended by org.mmbase.bridge.implementation.ModuleHandler
All Implemented Interfaces:
Comparable<Module>, InvocationHandler, Descriptor, Module

public class ModuleHandler
extends Object
implements Module, InvocationHandler

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

Version:
$Id: ModuleHandler.java 34936 2009-05-04 14:41:51Z michiel $
Author:
Pierre van Rooden, Rob Vermeulen

Method Summary
 int compareTo(Module m)
          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()
          Returns the description of this object for the default locale.
 String getDescription(Locale locale)
          Returns the description of this object.
 Function<?> getFunction(String functionName)
          Returns a Function object.
 Collection<Function<?>> 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 getGUIName()
          Returns the GUI name for this object.
 String getGUIName(Locale locale)
          Returns the GUI name for this object in a specified preferred language.
 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<String,?> parameters)
          Retrieve info (as a list of virtual nodes) from a module based on a command string.
 NodeList getList(String command, Map<String,?> parameters, ServletRequest req, ServletResponse resp)
          Retrieve info from a module based on a command string Similar to the LIST command in SCAN.
 LocalizedString getLocalizedDescription()
          Returns the set of (localized) descriptions of this object.
 LocalizedString getLocalizedGUIName()
          Returns the set of (localized) gui names of this object.
static Module getModule(Module mod, CloudContext cloudcontext)
           
 String getName()
          Retrieve the name of the module (in the default language defined in mmbaseroot.xml).
 Map<String,String> getProperties()
          Retrieve a copy of the module's properties
 String getProperty(String name)
          Retrieve a property of the module.
 int hashCode()
           
 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<String,Object> auxparameters)
          Runs the command with the given parameter(s).
 void process(String command, Object parameter, Map<String,Object> auxparameters, ServletRequest req, ServletResponse resp)
          Runs the command with the given parameter(s).
 void setDescription(String desc)
          Sets the description of this object for the default locale.
 void setDescription(String desc, Locale locale)
          Sets the description of this object.
 void setGUIName(String g)
          Sets the GUI name of this object for the default locale.
 void setGUIName(String g, Locale locale)
          Sets the GUI name of this object.
protected  void setLocalizedDescription(LocalizedString description)
           
protected  void setLocalizedGUIName(LocalizedString value)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, 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 Descriptor
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<String,String> 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: Descriptor
Returns the description of this object for the default locale.

Specified by:
getDescription in interface Descriptor
Returns:
the description as a String

getDescription

public String getDescription(Locale locale)
Description copied from interface: Descriptor
Returns the description of this object.

Specified by:
getDescription in interface Descriptor
Parameters:
locale - The locale for which this must be returned, or null for a default locale. If no fitting description for the given locale is available, getName() can be returned.
Returns:
the description as a String

getLocalizedDescription

public LocalizedString getLocalizedDescription()
Description copied from interface: Descriptor
Returns the set of (localized) descriptions of this object.

Specified by:
getLocalizedDescription in interface Descriptor
Returns:
the description as a LocalizedString

setLocalizedDescription

protected void setLocalizedDescription(LocalizedString description)

setDescription

public void setDescription(String desc,
                           Locale locale)
Description copied from interface: Descriptor
Sets the description of this object.

Specified by:
setDescription in interface Descriptor
Parameters:
desc - the description as a String
locale - The locale for which this is valid, or null for a default locale.

setDescription

public void setDescription(String desc)
Description copied from interface: Descriptor
Sets the description of this object for the default locale.

Specified by:
setDescription in interface Descriptor
Parameters:
desc - the description as a String

getGUIName

public String getGUIName(Locale locale)
Description copied from interface: Descriptor
Returns the GUI name for this object in a specified preferred language.

Specified by:
getGUIName in interface Descriptor
Parameters:
locale - the locale that determines the language for the GUI name
Returns:
the GUI name for this object

getGUIName

public String getGUIName()
Description copied from interface: Descriptor
Returns the GUI name for this object.

Specified by:
getGUIName in interface Descriptor
Returns:
the GUI name for this object

setGUIName

public void setGUIName(String g,
                       Locale locale)
Description copied from interface: Descriptor
Sets the GUI name of this object.

Specified by:
setGUIName in interface Descriptor
Parameters:
g - the description as a String
locale - The locale for which this is valid, or null for the default locale.

setGUIName

public void setGUIName(String g)
Description copied from interface: Descriptor
Sets the GUI name of this object for the default locale.

Specified by:
setGUIName in interface Descriptor
Parameters:
g - the description as a String

getLocalizedGUIName

public LocalizedString getLocalizedGUIName()
Description copied from interface: Descriptor
Returns the set of (localized) gui names of this object.

Specified by:
getLocalizedGUIName in interface Descriptor
Returns:
the description as a LocalizedString

setLocalizedGUIName

protected void setLocalizedGUIName(LocalizedString value)

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<String,Object> 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<String,Object> 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<String,?> 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<String,?> 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(Module m)
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<Module>
Parameters:
m - the Module to compare it with
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
See Also:
Comparable.compareTo(Object)

equals

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

Overrides:
equals in class Object
Parameters:
o - the object to compare it with

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getFunctions

public Collection<Function<?>> 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 Function object. The object returned is a Function object. You need to explicitly 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 position, 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 function
Returns:
the result value of executing the function


MMBase 2.0-SNAPSHOT - null