• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.apache.velocity.runtime.parser.node;
2 
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "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 org.slf4j.Logger;
23 
24 import java.lang.reflect.InvocationTargetException;
25 import java.lang.reflect.Method;
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$
35  */
36 public abstract class AbstractExecutor
37 {
38     /** */
39     protected Logger log = null;
40 
41     /**
42      * Method to be executed.
43      */
44     private Method method = null;
45 
46     /**
47      * Execute method against context.
48      * @param o
49      * @return The resulting object.
50      * @throws IllegalAccessException
51      * @throws InvocationTargetException
52      */
execute(Object o)53      public abstract Object execute(Object o)
54          throws IllegalAccessException, InvocationTargetException;
55 
56     /**
57      * Tell whether the executor is alive by looking
58      * at the value of the method.
59      *
60      * @return True if executor is alive.
61      */
isAlive()62     public boolean isAlive()
63     {
64         return (method != null);
65     }
66 
67     /**
68      * @return The current method.
69      */
getMethod()70     public Method getMethod()
71     {
72         return method;
73     }
74 
75     /**
76      * @param method
77      * @since 1.5
78      */
setMethod(final Method method)79     protected void setMethod(final Method method)
80     {
81         this.method = method;
82     }
83 }
84