* <p>Alternatively, override getSessionBeanInstance and
   * releaseSessionBeanInstance to change EJB instance creation,
   * for example to hold a single shared EJB instance.
   */
  public Object invoke(MethodInvocation invocation) throws Throwable {
    EJBLocalObject ejb = null;
    try {
      ejb = getSessionBeanInstance();
      Method method = invocation.getMethod();
      if (method.getDeclaringClass().isInstance(ejb)) {
        // directly implemented
        return method.invoke(ejb, invocation.getArguments());
      }
      else {
        // not directly implemented
        Method ejbMethod = ejb.getClass().getMethod(method.getName(), method.getParameterTypes());
        return ejbMethod.invoke(ejb, invocation.getArguments());
      }
    }
    catch (InvocationTargetException ex) {
      Throwable targetEx = ex.getTargetException();