01: /*
02: * Copyright 2000-2001,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.commons.jexl.util;
18:
19: import java.lang.reflect.InvocationTargetException;
20: import java.lang.reflect.Method;
21:
22: import org.apache.commons.logging.Log;
23:
24: /**
25: * Abstract class that is used to execute an arbitrary
26: * method that is in introspected. This is the superclass
27: * for the GetExecutor and PropertyExecutor.
28: *
29: * @since 1.0
30: * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
31: * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
32: * @version $Id: AbstractExecutor.java 398171 2006-04-29 14:57:29Z dion $
33: */
34: public abstract class AbstractExecutor {
35: /** The executor instance log. */
36: protected Log rlog = null;
37:
38: /**
39: * Method to be executed.
40: */
41: protected Method method = null;
42:
43: /**
44: * Execute method against context.
45: *
46: * @param o The owner.
47: * @return The return value.
48: * @throws IllegalAccessException Method is inaccessible.
49: * @throws InvocationTargetException Method body throws an exception.
50: */
51: public abstract Object execute(Object o)
52: throws IllegalAccessException, InvocationTargetException;
53:
54: /**
55: * Tell whether the executor is alive by looking
56: * at the value of the method.
57: *
58: * @return boolean Whether the executor is alive.
59: */
60: public boolean isAlive() {
61: return (method != null);
62: }
63:
64: /**
65: * Get the method to be executed.
66: *
67: * @return Method The method to be executed.
68: */
69: public Method getMethod() {
70: return method;
71: }
72: }
|