View Javadoc

1   /*
2    * Copyright (C) 2004 TiongHiang Lee
3    *
4    * This library is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Lesser General Public
6    * License as published by the Free Software Foundation; either
7    * version 2.1 of the License, or (at your option) any later version.
8    *
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   * Lesser General Public License for more details.
13   *
14   * You should have received a copy of the GNU Lesser General Public
15   * License along with this library; if not,  write to the Free Software
16   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17   *
18   * Email: thlee@onemindsoft.org
19   */
20  package org.onemind.commons.invoke;
21  
22  
23  /***
24   * An interface for a object provide information about
25   * functions that can be invoked on itself (through a key)
26   * and API for invoke the method on on itself
27   * @author TiongHiang Lee (thlee@onemindsoft.org)
28   * @version $Id: Invocable.java,v 1.2 2004/08/26 16:08:23 thlee Exp $ $Name:  $
29   */
30  public interface Invocable
31  {
32      /***
33       * whether the function can be invoke with the arguments
34       * @param functionName the function name
35       * @param args the arguments
36       * @return true if can invoke
37       */
38      public boolean canInvoke(String functionName, Object[] args);
39  
40      /***
41       * Get the function
42       * @param functionName the function name
43       * @param args the arguments
44       * @return the function, or null if the function cannot be found
45       */
46      public InvocableFunction getFunction(String functionName, Object[] args);
47      
48      /***
49       * invoke the function with the arguments provided
50       * @param functionName the function name
51       * @param args the arguments
52       * @return the object returns from the invocation
53       * @throws Exception if there's problem invoking the function
54       */
55      public Object invoke(String functionName, Object[] args)
56          throws Exception;
57  }