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