public class TransactionalIntercessor extends java.lang.Object implements IIntercessor
SimpleIntercessor, this class supports the execution of several primitives
simultaneously as a transaction.| Modifier and Type | Field and Description |
|---|---|
protected java.util.Queue<Primitive> |
primitives |
| Constructor and Description |
|---|
TransactionalIntercessor() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAnnotation(Method method,
java.lang.reflect.Type... annotationObjects) |
void |
addAnnotation(java.lang.reflect.Type clazz,
java.lang.reflect.Type... annotationObjects)
Add the provided annotations to the specified class.
|
void |
addField(java.lang.reflect.Type clazz,
Field... fields) |
void |
addGenericType(Method method,
TypeVariable<?>... types) |
void |
addGenericType(java.lang.reflect.Type clazz,
TypeVariable<?>... types)
Add the provided generic type to the specified class.
|
void |
addImport(java.lang.reflect.Type clazz,
Class<?>... importObjects) |
void |
addImport(java.lang.reflect.Type clazz,
java.lang.Package... importObjects)
Add the provided imports to the source file that defines the specified class.
|
void |
addInterface(java.lang.reflect.Type clazz,
java.util.Map<java.lang.reflect.Type,java.lang.reflect.Type[]> interfs)
Version of the previous method able to add multiple interfaces.
|
void |
addInterface(java.lang.reflect.Type clazz,
java.lang.reflect.Type interf,
java.lang.reflect.Type... typeParameters)
Adds an interface to the provided class.
|
void |
addMethod(java.lang.reflect.Type clazz,
Method... methods) |
void |
addPublicInterfaceOf(java.lang.reflect.Type origin,
java.lang.reflect.Type destination)
Adds all the members of the public interface of the specified class to
another class
|
void |
commit()
Performs the operations indicated to the intercessor, if the intercessor has
the ability to store the operations until they are executed at the same time.
|
Class<?> |
createClassClone(java.lang.String packageName,
java.lang.String className,
java.lang.reflect.Type origin)
Creates a class clone of the specified class with the specified name and
belonging to the provided package
|
IIntercessor |
createIntercessor()
Creates an instance of the intercessor implementing this interface
|
java.lang.reflect.AnnotatedElement[] |
getImports(java.lang.reflect.Type clazz)
Get the imports of the source file that defines the specified class.
|
void |
implementInterface(java.lang.reflect.Type clazz,
java.lang.reflect.Type interf,
Method[] methods,
java.lang.Class<?>... typeParameters) |
void |
removeField(java.lang.reflect.Type clazz,
Field... fields) |
void |
removeInterface(java.lang.reflect.Type clazz,
java.lang.reflect.Type interf)
Removes an interface from a class
|
void |
removeMethod(java.lang.reflect.Type clazz,
Method... methods) |
void |
removeSuperclass(java.lang.reflect.Type clazz)
Removes the superclass of an existing class, setting it to Object.
|
void |
replaceField(java.lang.reflect.Type clazz,
Field... fields) |
void |
replaceImplementation(java.lang.reflect.Type clazz,
Method... methods) |
void |
replaceMethod(java.lang.reflect.Type clazz,
java.util.Map<Method,Method> methods)
Replaces a series of methods from the specified class
For example, modifying the method to acept a more generic type (Dog ->
Animal):
// Creating MethodType
MethodType newType = MethodType.methodType(void.class, Pet.class);
// Modifying the method
Intercessor.replaceMethod(Owner.class, new jmplib.reflect.Method("addPet", newType,
"this.pet = dog;"));
|
void |
replaceMethod(java.lang.reflect.Type clazz,
Method method,
Method newMethod) |
void |
setAnnotation(Method method,
java.lang.reflect.Type... annotationObjects) |
void |
setAnnotation(java.lang.reflect.Type clazz,
java.lang.reflect.Type... annotationObjects)
Replace the annotations of the specified class with the provided ones.
|
void |
setGenericType(Method method,
TypeVariable<?>... types) |
void |
setGenericType(java.lang.reflect.Type clazz,
TypeVariable<?>... types)
Replace the generic types of the specified class with the provided ones.
|
void |
setImports(java.lang.reflect.Type clazz,
java.lang.reflect.AnnotatedElement... importObjects)
Replace the imports of the source file that defines the specified class with
the provided ones.
|
void |
setSuperclass(java.lang.reflect.Type clazz,
java.lang.reflect.Type superclazz,
java.lang.reflect.Type... typeParameters)
Changes the superclass of an existing class, modifying member visibilities
accordingly.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddAnnotation, addField, addGenericType, addImport, addMethod, implementInterface, removeField, removeMethod, replaceField, replaceImplementation, replaceMethod, setAnnotation, setGenericTypeprotected final java.util.Queue<Primitive> primitives
public IIntercessor createIntercessor()
createIntercessor in interface IIntercessorpublic void addField(java.lang.reflect.Type clazz,
Field... fields)
throws StructuralIntercessionException
addField in interface IIntercessorStructuralIntercessionExceptionIIntercessor.addField(Type, java.lang.reflect.Field...)public void replaceField(java.lang.reflect.Type clazz,
Field... fields)
throws StructuralIntercessionException
replaceField in interface IIntercessorStructuralIntercessionExceptionIIntercessor.replaceField(Type, java.lang.reflect.Field...)public void removeField(java.lang.reflect.Type clazz,
Field... fields)
throws StructuralIntercessionException
removeField in interface IIntercessorStructuralIntercessionExceptionIIntercessor.removeField(Type, java.lang.reflect.Field...)public void addMethod(java.lang.reflect.Type clazz,
Method... methods)
throws StructuralIntercessionException
addMethod in interface IIntercessorStructuralIntercessionExceptionIIntercessor.addMethod(Type, java.lang.reflect.Method...)public void replaceMethod(java.lang.reflect.Type clazz,
Method method,
Method newMethod)
throws StructuralIntercessionException
replaceMethod in interface IIntercessorStructuralIntercessionExceptionIIntercessor.replaceMethod(Type, java.lang.reflect.Method, java.lang.reflect.Method)public void replaceMethod(java.lang.reflect.Type clazz,
java.util.Map<Method,Method> methods)
throws StructuralIntercessionException
For example, modifying the method to acept a more generic type (Dog -> Animal):
// Creating MethodType
MethodType newType = MethodType.methodType(void.class, Pet.class);
// Modifying the method
Intercessor.replaceMethod(Owner.class, new jmplib.reflect.Method("addPet", newType,
"this.pet = dog;"));
replaceMethod in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.Classmethods - Set of jmplib.reflect.Method or java.lang.reflect.Method to
replace. The method name and type is used to identify the method
to replace. The rest of the information is taken from the Method
class.StructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void replaceImplementation(java.lang.reflect.Type clazz,
Method... methods)
throws StructuralIntercessionException
replaceImplementation in interface IIntercessorStructuralIntercessionExceptionIIntercessor.replaceImplementation(Type, java.lang.reflect.Method...)public void removeMethod(java.lang.reflect.Type clazz,
Method... methods)
throws StructuralIntercessionException
removeMethod in interface IIntercessorStructuralIntercessionExceptionIIntercessor.removeMethod(Type, java.lang.reflect.Method...)public void addPublicInterfaceOf(java.lang.reflect.Type origin,
java.lang.reflect.Type destination)
throws StructuralIntercessionException
addPublicInterfaceOf in interface IIntercessororigin - A java.lang.Class or a jmplib.reflect.Classdestination - A java.lang.Class or a jmplib.reflect.ClassStructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public Class<?> createClassClone(java.lang.String packageName, java.lang.String className, java.lang.reflect.Type origin) throws StructuralIntercessionException
This operation works independently from the current transaction and does not commit it or modify its pending operations.
createClassClone in interface IIntercessorpackageName - Package name of the new class to be createdclassName - Name of the newly created classorigin - A java.lang.Class or a jmplib.reflect.ClassStructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void addInterface(java.lang.reflect.Type clazz,
java.lang.reflect.Type interf,
java.lang.reflect.Type... typeParameters)
throws StructuralIntercessionException
addInterface in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.Classinterf - A java.lang.Class or a jmplib.reflect.Class representing an
interface to addtypeParameters - Types of the generic parameters of the interface to be added. This
is an optional parameter. However, if specified, it must comply
with the expected type parameter number of the passed interface.
Example:
To add the Comparable interface to the Dog object, the call should be:
Intercessor.addInterface(Dog.class, Comparable.class);
The call will fail if the Dog class do not have a compareTo(Object) method already added.
If we need to add the Comparable
Intercessor.addInterface(Dog.class, Comparable.class, Dog.class);
The call will fail if the Dog class do not have a compareTo(Dog)
method already added.
StructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void addInterface(java.lang.reflect.Type clazz,
java.util.Map<java.lang.reflect.Type,java.lang.reflect.Type[]> interfs)
throws StructuralIntercessionException
addInterface in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.Classinterfs - A collection of objects representing interfaces and their type
parametersStructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void removeInterface(java.lang.reflect.Type clazz,
java.lang.reflect.Type interf)
throws StructuralIntercessionException
removeInterface in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.Classinterf - A java.lang.Class or a jmplib.reflect.Class representing an
interfaceStructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void implementInterface(java.lang.reflect.Type clazz,
java.lang.reflect.Type interf,
Method[] methods,
java.lang.Class<?>... typeParameters)
throws StructuralIntercessionException
implementInterface in interface IIntercessorStructuralIntercessionExceptionIIntercessor.implementInterface(Type, Type, java.lang.reflect.Method[],
Class...)public void setSuperclass(java.lang.reflect.Type clazz,
java.lang.reflect.Type superclazz,
java.lang.reflect.Type... typeParameters)
throws StructuralIntercessionException
setSuperclass in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.Classsuperclazz - A java.lang.Class or a jmplib.reflect.ClasstypeParameters - Type parameters of the new superclassStructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void removeSuperclass(java.lang.reflect.Type clazz)
throws StructuralIntercessionException
removeSuperclass in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.ClassStructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void addImport(java.lang.reflect.Type clazz,
Class<?>... importObjects)
throws StructuralIntercessionException
addImport in interface IIntercessorStructuralIntercessionExceptionIIntercessor.addImport(Type, Class...)public void addImport(java.lang.reflect.Type clazz,
java.lang.Package... importObjects)
throws StructuralIntercessionException
addImport in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.ClassimportObjects - Packages to add as imports to the source file of the classStructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public java.lang.reflect.AnnotatedElement[] getImports(java.lang.reflect.Type clazz)
throws StructuralIntercessionException
getImports in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.ClassStructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void setImports(java.lang.reflect.Type clazz,
java.lang.reflect.AnnotatedElement... importObjects)
throws StructuralIntercessionException
setImports in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.ClassimportObjects - Modifies the import set of the file that defines the provided classStructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void addAnnotation(java.lang.reflect.Type clazz,
java.lang.reflect.Type... annotationObjects)
throws StructuralIntercessionException
addAnnotation in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.ClassannotationObjects - Set of annotations to be used to add to the existing ones.StructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void setAnnotation(java.lang.reflect.Type clazz,
java.lang.reflect.Type... annotationObjects)
throws StructuralIntercessionException
setAnnotation in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.ClassannotationObjects - Set of annotations to be used to replace the existing ones.StructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void addAnnotation(Method method, java.lang.reflect.Type... annotationObjects) throws StructuralIntercessionException
addAnnotation in interface IIntercessorStructuralIntercessionExceptionpublic void setAnnotation(Method method, java.lang.reflect.Type... annotationObjects) throws StructuralIntercessionException
setAnnotation in interface IIntercessorStructuralIntercessionExceptionpublic void addGenericType(java.lang.reflect.Type clazz,
TypeVariable<?>... types)
throws StructuralIntercessionException
addGenericType in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.Classtypes - Set of generic types to be used to add to the existing ones.StructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void setGenericType(java.lang.reflect.Type clazz,
TypeVariable<?>... types)
throws StructuralIntercessionException
setGenericType in interface IIntercessorclazz - A java.lang.Class or a jmplib.reflect.Classtypes - Set of generic types to be used to replace the existing ones.StructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)public void addGenericType(Method method, TypeVariable<?>... types) throws StructuralIntercessionException
addGenericType in interface IIntercessorStructuralIntercessionExceptionpublic void setGenericType(Method method, TypeVariable<?>... types) throws StructuralIntercessionException
setGenericType in interface IIntercessorStructuralIntercessionExceptionIIntercessor.setGenericType(Method, TypeVariable[])public void commit()
throws StructuralIntercessionException
commit in interface IIntercessorStructuralIntercessionException - If problems with the metaprogramming primitives are detected (exception
message indicates the concrete problem, as it wraps the inner exception)