Class DefaultExecutionStrategy
- java.lang.Object
-
- ch.obermuhlner.scriptengine.java.execution.DefaultExecutionStrategy
-
- All Implemented Interfaces:
ExecutionStrategy
public class DefaultExecutionStrategy extends java.lang.Object implements ExecutionStrategy
The defaultExecutionStrategy
implementation.- class implements `Supplier`: the `get()` method is called
- class implements `Runnable`: the `run()` method is called
- class has exactly one public method without arguments: call it
-
-
Constructor Summary
Constructors Constructor Description DefaultExecutionStrategy(java.lang.Class<?> clazz)
Constructs aDefaultExecutionStrategy
for the specifiedClass
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
execute(java.lang.Object instance)
Executes a method on an object instance, or a static method if the specified instance isnull
.private static java.lang.reflect.Method
findCallableMethod(java.lang.Class<?> clazz)
-
-
-
Constructor Detail
-
DefaultExecutionStrategy
public DefaultExecutionStrategy(java.lang.Class<?> clazz)
Constructs aDefaultExecutionStrategy
for the specifiedClass
.- Parameters:
clazz
- theClass
-
-
Method Detail
-
execute
public java.lang.Object execute(java.lang.Object instance) throws javax.script.ScriptException
Description copied from interface:ExecutionStrategy
Executes a method on an object instance, or a static method if the specified instance isnull
.- Specified by:
execute
in interfaceExecutionStrategy
- Parameters:
instance
- the object instance to be executed ornull
to execute a static method- Returns:
- the return value of the method, or
null
- Throws:
javax.script.ScriptException
- if no method to execute was found
-
findCallableMethod
private static java.lang.reflect.Method findCallableMethod(java.lang.Class<?> clazz)
-
-