Package org.kissweb.restServer
Class GroovyService
java.lang.Object
org.kissweb.restServer.GroovyService
Author: Blake McBride
Date: 5/5/18
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
constructor
(String relativePath, String className, Object... args) Execute a Groovy constructor.static Method
getMethod
(boolean ignoreMissing, String filePath, String className, String methodName, Object... args) This method is used to obtain a class or instance method from a groovy class.static Method
This method is used to obtain a method from a groovy class.static Object
run
(boolean ignoreMissing, String filePath, String className, String methodName, Object inst, Object... args) This method allows calls to Groovy microservices.static Object
This method is used to run a method on a groovy class.static Object
This method is used to execute a microservice.
-
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 therun
method (the one that doesn't take the method object) should be used instead.- Parameters:
ignoreMissing
- iftrue
ignore missing classes or methods and return nullfilePath
- relative to the "backend" directory unless it is an absolute pathclassName
-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 therun
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 pathclassName
-methodName
-args
- the actual arguments or the argument types (classes)- Returns:
- Throws:
Exception
- See Also:
-
run
This method is used to run a method on a groovy class. The method would normally be returned from thegetMethod
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 evokeinst
- instance or null if a class methodargs
- 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
istrue
and the file, class, or method are missing aNULL
is returned. IfignoreMissing
isfalse
and the file, class, or method are missing an exception is thrown.filePath
is relative to thebackend
directory unless it is an absolute path.- Parameters:
ignoreMissing
-filePath
- relative to the "backend" directory unless it is an absolute pathclassName
-methodName
-inst
- the instance the method is evoked against or null if static methodargs
- 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 thebackend
directory unless it is an absolute path.- Parameters:
filePath
- relative to the "backend" directory unless it is an absolute pathclassName
-methodName
-inst
- the instance the method is evoked against or null if static methodargs
- 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
-