public interface IEvaluator
Modifier and Type | Method and Description |
---|---|
java.lang.Class<?> |
createEmptyClass(java.lang.String packageName,
java.lang.String className,
java.lang.reflect.AnnotatedElement... imports)
This method is a front-end of the exec method specially created to easily
return empty classes with a concrete name and package.
|
IEvaluator |
createEvaluator()
Creates an instance of the evaluator implementing this interface
|
java.lang.Class<?> |
exec(java.lang.String classSource)
Exec method allows the addition of new classes at runtime from its source
code to the application.
|
<T> T |
generateEvalInvoker(java.lang.String code,
EvalInvokerData<T> invokerData)
This method generates classes that implements generic functional interfaces,
that have to extend
EnvironmentSetUp interface. |
<T> T |
getFieldInvoker(java.lang.reflect.Type clazz,
java.lang.String name,
MemberInvokerData<T> info)
Generates an instance of the specified interface to provide one field getter.
|
<T> T |
getMethodInvoker(java.lang.reflect.Type clazz,
java.lang.String name,
MemberInvokerData<T> info)
Generates an instance of the specified interface to invoke one method.
|
<T> T |
setFieldInvoker(java.lang.reflect.Type clazz,
java.lang.String name,
MemberInvokerData<T> info)
Generates an instance of the specified interface to provide one field setter.
|
IEvaluator createEvaluator()
<T> T getMethodInvoker(java.lang.reflect.Type clazz, java.lang.String name, MemberInvokerData<T> info) throws StructuralIntercessionException
Generates an instance of the specified interface to invoke one method. The first parameter of the interface must be the class owner type, meaning, the class where the method is. This parameter is going to be the instance over the invokations are called.
clazz
- The class where the method isname
- The name of the methodinfo
- The invoker data needed to obtain the invoker of the specified
methodStructuralIntercessionException
- If a problem was encountered before finishing<T> T getFieldInvoker(java.lang.reflect.Type clazz, java.lang.String name, MemberInvokerData<T> info) throws StructuralIntercessionException
Generates an instance of the specified interface to provide one field getter. The first parameter of the interface must be the class owner type, meaning, the class where the field is.
clazz
- The class where the field isname
- The name of the fieldinfo
- The invoker data needed to obtain the invoker of the specified
fieldStructuralIntercessionException
- If a problem was encountered before finishing<T> T setFieldInvoker(java.lang.reflect.Type clazz, java.lang.String name, MemberInvokerData<T> info) throws StructuralIntercessionException
Generates an instance of the specified interface to provide one field setter. The first parameter of the interface must be the class owner type, meaning, the class where the field is.
clazz
- The class where the field isname
- The name of the fieldinfo
- The invoker data needed to obtain the invoker of the specified
fieldStructuralIntercessionException
- If a problem was encountered before finishingjava.lang.Class<?> createEmptyClass(java.lang.String packageName, java.lang.String className, java.lang.reflect.AnnotatedElement... imports) throws StructuralIntercessionException
packageName
- Package name of the class to be createdclassName
- Name of the class to be createdimports
- Import clauses to be included in the new file.StructuralIntercessionException
java.lang.Class<?> exec(java.lang.String classSource) throws StructuralIntercessionException
Exec method allows the addition of new classes at runtime from its source code to the application. These classes are incorporated to the specified package as they were there before the application start running, and can be used by other classes as normal.
The following example shows how does it works:
Class> clazz = Evaluator.exec("package pack.example; public class Foo {}");
This sentence adds a new class called Foo
to the package
package.example
of the application. This new class is compatible with
JMPlib modifications because a copy of its source code is located inside the
source code folder.
IMPORTANT: If you stop the application make sure you delete the added classes before launching it again.
classSource
- source code of the classStructuralIntercessionException
- If problems with the metaprogramming primitives are detected (exception
* message indicates the concrete problem, as it wraps the inner exception)<T> T generateEvalInvoker(java.lang.String code, EvalInvokerData<T> invokerData) throws StructuralIntercessionException
This method generates classes that implements generic functional interfaces,
that have to extend EnvironmentSetUp
interface. It allows to enclose
the code given and invoke it by the interface instance returned.
Additionally, this method define the global variables of the generated class
using the map environment
. All this variables are common for each
invokation and have to be initialized by the method
EnvironmentSetUp.setEnvironment
.
code
- the code to enclose in the interface methodinvokerData
- Data needed to perform the code evaluationStructuralIntercessionException
- If problems with the metaprogramming primitives are detected (exception
* message indicates the concrete problem, as it wraps the inner exception)