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 PutExecutor and SetPropertyExecutor.
31: *
32: * There really should be a superclass for this and AbstractExecutor (which should
33: * be refactored to GetExecutor) because they differ only in the execute() method.
34: *
35: * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
36: * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
37: * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
38: * @version $Id: SetExecutor.java 463298 2006-10-12 16:10:32Z henning $
39: */
40: public abstract class SetExecutor {
41: /** Class logger */
42: protected Log log = null;
43:
44: /**
45: * Method to be executed.
46: */
47: private Method method = null;
48:
49: /**
50: * Execute method against context.
51: * @param o
52: * @param value
53: * @return The result of the invocation.
54: * @throws IllegalAccessException
55: * @throws InvocationTargetException
56: */
57: public abstract Object execute(Object o, Object value)
58: throws IllegalAccessException, InvocationTargetException;
59:
60: /**
61: * Tell whether the executor is alive by looking
62: * at the value of the method.
63: * @return True if the executor is alive.
64: */
65: public boolean isAlive() {
66: return (method != null);
67: }
68:
69: /**
70: * @return The method to invoke.
71: */
72: public Method getMethod() {
73: return method;
74: }
75:
76: /**
77: * @param method
78: */
79: protected void setMethod(final Method method) {
80: this.method = method;
81: }
82: }
|