Package org.crsh.cli.impl.invocation

Examples of org.crsh.cli.impl.invocation.InvocationException


        T command = null;
        try {
          command = commandInstance.get();
        }
        catch (Exception e) {
          throw new InvocationException(e);
        }

        //
        if (owner != null) {
          bind(match.owner(), owner.getParameters(), command, Util.EMPTY_ARGS);
        }

        // Prepare invocation
        Method m = getMethod();
        Class<?>[] parameterTypes = m.getParameterTypes();
        Object[] mArgs = new Object[parameterTypes.length];

        // Bind method parameter first
        bind(match, getParameters(), command, mArgs);

        // Fill missing contextual parameters and make primitive check
        for (int i = 0;i < mArgs.length;i++) {
          Class<?> parameterType = parameterTypes[i];
          if (mArgs[i] == null) {
            Object v = commandInstance.resolve(parameterType);
            if (v != null) {
              mArgs[i] = v;
            }
          }
          if (mArgs[i] == null && parameterType.isPrimitive()) {
            throw new SyntaxException("Method argument at position " + i + " of " + m + " is missing");
          }
        }

        // Perform method invocation
        try {
          Object ret = m.invoke(command, mArgs);
          return returnType.cast(ret);
        }
        catch (InvocationTargetException e) {
          Throwable t = e.getTargetException();
          if (t instanceof Error) {
            throw (Error)t;
          } else {
            throw new InvocationException(t);
          }
        }
        catch (IllegalAccessException t) {
          throw new InvocationException(t);
        }
      }
    };
  }
View Full Code Here


    try {
      field.setAccessible(true);
      field.set(target, value);
    }
    catch (Exception e) {
      throw new InvocationException(e.getMessage(), e);
    }
  }
View Full Code Here

          T command;
          try {
            command = commandInstance.get();
          }
          catch (Exception e) {
            throw new InvocationException(e);
          }
          MethodDescriptor.bind(match, getParameters(), command, Util.EMPTY_ARGS);
          Runnable runnable = Runnable.class.cast(command);
          try {
            runnable.run();
          }
          catch (Exception e) {
            throw new InvocationException(e);
          }
          return null;
        }
      };
    } else {
View Full Code Here

TOP

Related Classes of org.crsh.cli.impl.invocation.InvocationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.