Class GroovyService

java.lang.Object
org.kissweb.restServer.GroovyService

public class GroovyService extends Object
Author: Blake McBride Date: 5/5/18
  • Constructor Details

    • GroovyService

      public GroovyService()
  • Method Details

    • getMethod

      public static Method getMethod(boolean ignoreMissing, String filePath, String className, String methodName, Object... args) throws Exception
      This method is used to obtain a class or instance method from a groovy class. The Groovy file is treated as a microservice. This means you will always get the most current definition of the method. Once the method is obtained, it may be evoked any number of times.

      This method is mainly used in cases where a method will be evoked multiple times. If it is only going to be evoked once, then the run method (the one that doesn't take the method object) should be used instead.
      Parameters:
      ignoreMissing - if true ignore missing classes or methods and return null
      filePath - relative to the "backend" directory unless it is an absolute path
      className -
      methodName -
      args - the actual arguments or the argument types (classes)
      Returns:
      Throws:
      Exception
      See Also:
    • getMethod

      public static Method getMethod(String filePath, String className, String methodName, Object... args) throws Exception
      This method is used to obtain a method from a groovy class. The Groovy file is treated as a microservice. This means you will always get the most current definition of the method. Once the method is obtained, it may be evoked any number of times.

      This method is mainly used in cases where a method will be evoked multiple times. If it is only going to be evoked once, then the run method (the one that doesn't take the method object) should be used instead.

      On the Groovy side, all arguments are received in boxed form. Groovy must also return a boxed object.
      Parameters:
      filePath - relative to the "backend" directory unless it is an absolute path
      className -
      methodName -
      args - the actual arguments or the argument types (classes)
      Returns:
      Throws:
      Exception
      See Also:
    • run

      public static Object run(Method methp, Object inst, Object... args) throws Exception
      This method is used to run a method on a groovy class. The method would normally be returned from the getMethod method.

      The calling method may use boxed or unboxed arguments, but a boxed type will always be returned.

      All arguments to the method being executed are received in boxed form. It must also return a boxed object.
      Parameters:
      methp - the method to evoke
      inst - instance or null if a class method
      args - boxed or unboxed
      Returns:
      boxed
      Throws:
      Exception
      See Also:
    • run

      public static Object run(boolean ignoreMissing, String filePath, String className, String methodName, Object inst, Object... args) throws Exception
      This method allows calls to Groovy microservices. It can be used to execute a static or instance methods.

      The calling method may use boxed or unboxed arguments, but a boxed type will always be returned.

      All arguments to the method being executed are received in boxed form. It must also return a boxed object.

      If ignoreMissing is true and the file, class, or method are missing a NULL is returned. If ignoreMissing is false and the file, class, or method are missing an exception is thrown.

      filePath is relative to the backend directory unless it is an absolute path.

      Parameters:
      ignoreMissing -
      filePath - relative to the "backend" directory unless it is an absolute path
      className -
      methodName -
      inst - the instance the method is evoked against or null if static method
      args - boxed or unboxed arguments (variable number)
      Returns:
      The boxed value returned by the Groovy method call
      Throws:
      Exception
      See Also:
    • run

      public static Object run(String filePath, String className, String methodName, Object inst, Object... args) throws Exception
      This method is used to execute a microservice. It can be used to execute a static or instance method.

      The calling method may use boxed or unboxed arguments, but a boxed type will always be returned.

      All arguments to the method being executed are received in boxed form. It must also return a boxed object.

      filePath is relative to the backend directory unless it is an absolute path.
      Parameters:
      filePath - relative to the "backend" directory unless it is an absolute path
      className -
      methodName -
      inst - the instance the method is evoked against or null if static method
      args - boxed or unboxed arguments (variable number)
      Returns:
      The boxed value returned by the Groovy method call
      Throws:
      Exception
      See Also:
    • constructor

      public static Object constructor(String relativePath, String className, Object... args) throws Exception
      Execute a Groovy constructor.
      Parameters:
      relativePath -
      className -
      args -
      Returns:
      Throws:
      Exception