View Javadoc

    1   /*
    2    * Copyright 2000-2001,2004 The Apache Software Foundation.
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    *
    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
    20  import java.lang.reflect.InvocationTargetException;
    21  import java.lang.reflect.Method;
    22
    23  import org.apache.commons.logging.Log;
    24
    25  /***
    26   * Abstract class that is used to execute an arbitrary
    27   * method that is in introspected. This is the superclass
    28   * for the GetExecutor and PropertyExecutor.
    29   *
    30   * @since 1.0
    31   * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    32   * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
    33   * @version $Id: AbstractExecutor.java 398171 2006-04-29 14:57:29Z dion $
    34   */
    35  public abstract class AbstractExecutor {
    36      /*** The executor instance log. */
    37      protected Log rlog = null;
    38
    39      /***
    40       * Method to be executed.
    41       */
    42      protected Method method = null;
    43
    44      /***
    45       * Execute method against context.
    46       *
    47       * @param o The owner.
    48       * @return The return value.
    49       * @throws IllegalAccessException Method is inaccessible.
    50       * @throws InvocationTargetException Method body throws an exception.
    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 boolean Whether the executor is alive.
    60       */
    61      public boolean isAlive() {
    62          return (method != null);
    63      }
    64
    65      /***
    66       * Get the method to be executed.
    67       *
    68       * @return Method The method to be executed.
    69       */
    70      public Method getMethod() {
    71          return method;
    72      }
    73  }