001: /*
002:
003: This software is OSI Certified Open Source Software.
004: OSI Certified is a certification mark of the Open Source Initiative.
005:
006: The license (Mozilla version 1.0) can be read at the MMBase site.
007: See http://www.MMBase.org/license
008:
009: */
010:
011: package org.mmbase.bridge;
012:
013: import java.util.*;
014: import org.mmbase.util.functions.Function;
015: import org.mmbase.util.functions.Parameters;
016: import javax.servlet.*;
017:
018: /**
019: * Modules are pieces of functionality that are not MMBase objects.
020: * e.g. Session, Mail, Upload and other functionality
021: *
022: * @author Rob Vermeulen
023: * @author Pierre van Rooden
024: * @version $Id: Module.java,v 1.18 2007/02/10 15:47:42 nklasens Exp $
025: */
026: public interface Module extends Descriptor, Comparable<Module> {
027:
028: /**
029: * Retrieves the CloudContext to which this module belongs
030: * @return CloudContext
031: */
032: public CloudContext getCloudContext();
033:
034: /**
035: * Retrieve the name of the module (in the default language defined in mmbaseroot.xml).
036: * @return name of the module
037: */
038: public String getName();
039:
040: /**
041: * Retrieve a property of the module.
042: * @param name the name of the property
043: * @return the property value (null if not given)
044: * @since MMBase-1.7
045: */
046: public String getProperty(String name);
047:
048: /**
049: * Retrieve a copy of the module's properties
050: * @return a map of module properties
051: * @since MMBase-1.7
052: */
053: public Map getProperties();
054:
055: /**
056: * Runs the command with the given parameter(s).
057: * @param command the command to run, i.e. "MESSAGE-UPDATE".
058: * @param parameter the main parameter for the command. Depends on the command issued. Not all
059: * commands make use of this parameter.
060: */
061: public void process(String command, Object parameter);
062:
063: /**
064: * Runs the command with the given parameter(s).
065: * @param command the command to run, i.e. "MESSAGE-UPDATE".
066: * @param parameter the main parameter for the command. Depends on the command issued. Not all
067: * commands make use of this parameter.
068: * @param auxparameters additional parameters for this command.
069: */
070: public void process(String command, Object parameter,
071: Map auxparameters);
072:
073: /**
074: * Runs the command with the given parameter(s).
075: * @param command the command to run, i.e. "MESSAGE-UPDATE".
076: * @param parameter the main parameter for the command. Depends on the command issued. Not all
077: * commands make use of this parameter.
078: * @param auxparameters additional parameters for this command.
079: * @param req the Request item to use for obtaining user information. For backward compatibility.
080: * @param resp the Response item to use for redirecting users. For backward compatibility.
081: */
082: public void process(String command, Object parameter,
083: Map auxparameters, ServletRequest req, ServletResponse resp);
084:
085: /**
086: * Retrieve info from a module based on a command string.
087: * Similar to the $MOD command in SCAN.
088: * @param command the info to obtain, i.e. "USER-OS".
089: * @return info from a module
090: */
091: public String getInfo(String command);
092:
093: /**
094: * Retrieve info from a module based on a command string
095: * Similar to the $MOD command in SCAN.
096: * @param command the info to obtain, i.e. "USER-OS".
097: * @param req the Request item to use for obtaining user information. For backward compatibility.
098: * @param resp the Response item to use for redirecting users. For backward compatibility.
099: * @return info from a module
100: */
101: public String getInfo(String command, ServletRequest req,
102: ServletResponse resp);
103:
104: /**
105: * Retrieve info (as a list of virtual nodes) from a module based on a command string.
106: * Similar to the LIST command in SCAN.
107: * The values retrieved are represented as fields of a virtual node, named following the fieldnames listed in the fields paramaters..
108: * @param command the info to obtain, i.e. "USER-OS".
109: * @param parameters a hashtable containing the named parameters of the list.
110: * @return info from a module (as a list of virtual nodes)
111: */
112: public NodeList getList(String command, Map parameters);
113:
114: /**
115: * Retrieve info from a module based on a command string
116: * Similar to the LIST command in SCAN.
117: * The values retrieved are represented as fields of a virtual node, named following the fieldnames listed in the fields paramaters..
118: * @param command the info to obtain, i.e. "USER-OS".
119: * @param parameters a hashtable containing the named parameters of the list.
120: * @param req the Request item to use for obtaining user information. For backward compatibility.
121: * @param resp the Response item to use for redirecting users. For backward compatibility.
122: * @return info from a module (as a list of virtual nodes)
123: */
124: public NodeList getList(String command, Map parameters,
125: ServletRequest req, ServletResponse resp);
126:
127: /**
128: * Returns all the Function objects of this Module.
129: *
130: * @since MMBase-1.8
131: * @return a Collection of {@link org.mmbase.util.functions.Function} objects.
132: */
133: public Collection getFunctions();
134:
135: /**
136: * Returns a Fuction object.
137: * The object returned is a {@link org.mmbase.util.functions.Function} object.
138: * You need to explixitly cast the result to this object, since not all bridge
139: * implementations (i.e. the RMMCI) support this class.
140: *
141: * @since MMBase-1.8
142: * @param functionName name of the function
143: * @return a {@link org.mmbase.util.functions.Function} object.
144: * @throws NotFoundException if the function does not exist
145: */
146: public Function getFunction(String functionName);
147:
148: /**
149: * Creates a parameter list for a function.
150: * The list can be filled with parameter values by either using the List set(int, Object) method, to
151: * set values for parameters by psoition, or by using the set(String, Object) method to
152: * set parameters by name.<br />
153: * This object can then be passed to the getFunctionValue method.
154: * Note that adding extra parameters (with the add(Object) method) won't work and may cause exceptions.
155: * @since MMBase-1.8
156: * @param functionName name of the function
157: * @return a {@link org.mmbase.util.functions.Parameters} object.
158: * @throws NotFoundException if the function does not exist
159: */
160: public Parameters createParameters(String functionName);
161:
162: /**
163: * Executes a function on this module with the given parameters, and returns the result.
164: *
165: * @since MMBase-1.8
166: * @param functionName name of the function
167: * @param parameters list with parameters for the fucntion
168: * @return the result value of executing the function
169: * @throws NotFoundException if the function does not exist
170: */
171: public FieldValue getFunctionValue(String functionName,
172: List parameters);
173:
174: }
|