KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > util > functions > FunctionFactory


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.util.functions;
11
12 import java.lang.reflect.Method JavaDoc;
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.mmbase.bridge.*;
16
17 /**
18  * The FunctionFactory instanciates {@link Function} objects. There are 6 static getFunctions
19  * objects in this class, which correspond to 6 different kind of Function objects.
20  *
21  * The function factory was more important in the 1.7 version of MMBase. Since MMBase 1.8 there are
22  * {@link FunctionProvider}s, so often, it is just as easy and straight forward to simply call the
23  * getFunction method on the relevant FunctionProvider (like {@link FunctionSet}, {@link Cloud},
24  * {@link Module}, or {@link Node}) or to simply instantiate the Function object (e.g. {@link BeanFunction})
25  *
26  * @author Michiel Meeuwissen
27  * @version $Id: FunctionFactory.java,v 1.8 2005/12/10 11:47:41 michiel Exp $
28  * @since MMBase-1.7
29  */

30 public class FunctionFactory {
31
32     /**
33      * Gets a function from a function set
34      */

35     public static Function getFunction(String JavaDoc setName, String JavaDoc functionName) {
36         return FunctionSets.getFunction(setName, functionName);
37     }
38
39     /**
40      * Gets a function from a function set on a certain cloud
41      */

42     public static Function getFunction(Cloud cloud, String JavaDoc setName, String JavaDoc functionName) {
43         return cloud.getFunction(setName, functionName);
44     }
45
46     /**
47      * Gets a function object for a Node.
48      */

49     public static Function getFunction(Node node, String JavaDoc functionName) {
50         return node.getFunction(functionName);
51 // return NodeFunction.getFunction(node, functionName);
52
}
53
54     /**
55      * Gets a function object for a NodeManager
56      */

57     public static Function getFunction(NodeManager nodeManager, String JavaDoc functionName) {
58         return nodeManager.getFunction(functionName);
59     }
60
61
62     /**
63      * Gets a function object for a Module
64      */

65     public static Function getFunction(Module module, String JavaDoc functionName) {
66        return module.getFunction(functionName);
67     }
68
69     /**
70      * Gets a function object for a certain Method
71      */

72     public static Function getFunction(Method JavaDoc method, String JavaDoc functionName) {
73         return new MethodFunction(method, functionName);
74     }
75
76     /**
77      * Gets a function object for a Bean
78      */

79     public static Function getFunction(Class JavaDoc claz, String JavaDoc functionName) throws java.lang.IllegalAccessException JavaDoc, InstantiationException JavaDoc, InvocationTargetException JavaDoc {
80         return BeanFunction.getFunction(claz,functionName);
81     }
82
83 }
84
Popular Tags