@Module public abstract class AbstractAspectGenerator<X> extends java.lang.Object implements AspectGenerator<X>
Modifier | Constructor and Description |
---|---|
protected |
AbstractAspectGenerator(AspectFactory<X> factory,
AnnotatedMethod<? super X> method,
AspectGenerator<X> next) |
Modifier and Type | Method and Description |
---|---|
void |
generate(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> prologueMap)
Top-level generator.
|
void |
generateApplicationException(JavaWriter out,
java.lang.Class<?> exn)
Generates application (checked) exception code for
the method.
|
void |
generateAsync(JavaWriter out)
Generates pre-async dispatch code.
|
void |
generateBeanConstructor(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> map)
Generates initialization in the constructor
|
void |
generateBeanPrologue(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> map)
Generates the static class prologue
|
void |
generateCall(JavaWriter out)
Generates the method interception code
|
protected void |
generateContent(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> map)
Generates the body of the method.
|
void |
generateDestroy(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> map)
Generates destroy code
|
void |
generateEpilogue(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> map)
Generates epilogue
|
void |
generateFinally(JavaWriter out)
Generates finally code for the method
|
void |
generateInject(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> map)
Generates extra inject code
|
void |
generateMethodPrologue(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> map)
Generates the static class prologue
|
void |
generatePostCall(JavaWriter out)
Generates code after the call, before the return.
|
void |
generatePostConstruct(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> map)
Generates @PostConstruct code
|
void |
generatePostFinally(JavaWriter out)
Generates finally code for the method
|
void |
generatePreCall(JavaWriter out)
Generates code before the call, in the try block.
|
void |
generatePreDestroy(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> map)
Generates @PreDestroy code
|
void |
generatePreTry(JavaWriter out)
Generates code before the try block
|
void |
generateProxyConstructor(JavaWriter out,
java.util.HashMap<java.lang.String,java.lang.Object> map)
Generates initialization in the proxy constructor
|
void |
generateSystemException(JavaWriter out,
java.lang.Class<?> exn)
Generates system (runtime) exception code for
the method.
|
protected <Z extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<Z> annotationType,
AnnotatedMethod<?> apiMethod,
AnnotatedMethod<?> implMethod) |
protected <Z extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<Z> annotationType,
AnnotatedMethod<?> apiMethod,
AnnotatedType<?> apiClass,
AnnotatedMethod<?> implementationMethod,
AnnotatedType<?> implementationClass) |
protected <Z extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<Z> annotationType,
AnnotatedType<?> apiClass,
AnnotatedType<?> implClass) |
protected AspectBeanFactory<X> |
getBeanFactory() |
protected AnnotatedType<X> |
getBeanType()
Returns the owning bean type.
|
protected AspectFactory<X> |
getFactory() |
protected java.lang.String |
getInstanceName() |
protected java.lang.Class<X> |
getJavaClass() |
protected java.lang.reflect.Method |
getJavaMethod()
Returns the JavaMethod for this aspect.
|
AnnotatedMethod<? super X> |
getMethod()
Returns the underlying method.
|
protected java.lang.Class<?>[] |
getThrowsExceptions() |
protected java.util.Set<VarType<?>> |
getTypeVariables() |
boolean |
isApplicationExceptionThrown()
Returns true if the application exception can be thrown.
|
java.lang.String |
toString() |
protected AbstractAspectGenerator(AspectFactory<X> factory, AnnotatedMethod<? super X> method, AspectGenerator<X> next)
protected AspectFactory<X> getFactory()
protected AspectBeanFactory<X> getBeanFactory()
protected java.lang.String getInstanceName()
protected AnnotatedType<X> getBeanType()
protected java.lang.Class<X> getJavaClass()
public AnnotatedMethod<? super X> getMethod()
AspectGenerator
getMethod
in interface AspectGenerator<X>
protected java.util.Set<VarType<?>> getTypeVariables()
protected java.lang.reflect.Method getJavaMethod()
public void generate(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> prologueMap) throws java.io.IOException
generate
in interface AspectGenerator<X>
java.io.IOException
protected void generateContent(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> map) throws java.io.IOException
MyType myMethod(...)
{
[pre-try]
try {
[pre-call]
[call] // retValue = super.myMethod(...)
[post-call]
return retValue;
} catch (RuntimeException e) {
[system-exception]
throw e;
} catch (Exception e) {
[application-exception]
throw e;
} finally {
[finally]
}
java.io.IOException
protected java.lang.Class<?>[] getThrowsExceptions()
public void generateBeanPrologue(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> map) throws java.io.IOException
generateBeanPrologue
in interface AspectGenerator<X>
java.io.IOException
public void generateBeanConstructor(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> map) throws java.io.IOException
generateBeanConstructor
in interface AspectGenerator<X>
java.io.IOException
public void generateProxyConstructor(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> map) throws java.io.IOException
generateProxyConstructor
in interface AspectGenerator<X>
java.io.IOException
public void generateInject(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> map) throws java.io.IOException
generateInject
in interface AspectGenerator<X>
java.io.IOException
public void generatePostConstruct(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> map) throws java.io.IOException
generatePostConstruct
in interface AspectGenerator<X>
java.io.IOException
public void generatePreDestroy(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> map) throws java.io.IOException
generatePreDestroy
in interface AspectGenerator<X>
java.io.IOException
public void generateEpilogue(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> map) throws java.io.IOException
generateEpilogue
in interface AspectGenerator<X>
java.io.IOException
public void generateDestroy(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> map) throws java.io.IOException
generateDestroy
in interface AspectGenerator<X>
java.io.IOException
public void generateMethodPrologue(JavaWriter out, java.util.HashMap<java.lang.String,java.lang.Object> map) throws java.io.IOException
generateMethodPrologue
in interface AspectGenerator<X>
java.io.IOException
public void generateAsync(JavaWriter out) throws java.io.IOException
generateAsync
in interface AspectGenerator<X>
java.io.IOException
public void generatePreTry(JavaWriter out) throws java.io.IOException
generatePreTry
in interface AspectGenerator<X>
java.io.IOException
public void generatePreCall(JavaWriter out) throws java.io.IOException
retType myMethod(...)
{
try {
[pre-call]
value = bean.myMethod(...);
...
}
generatePreCall
in interface AspectGenerator<X>
java.io.IOException
public void generateCall(JavaWriter out) throws java.io.IOException
generateCall
in interface AspectGenerator<X>
java.io.IOException
public void generatePostCall(JavaWriter out) throws java.io.IOException
retType myMethod(...)
{
try {
...
value = bean.myMethod(...);
[post-call]
return value;
} finally {
...
}
}
generatePostCall
in interface AspectGenerator<X>
java.io.IOException
public boolean isApplicationExceptionThrown()
isApplicationExceptionThrown
in interface AspectGenerator<X>
public void generateApplicationException(JavaWriter out, java.lang.Class<?> exn) throws java.io.IOException
generateApplicationException
in interface AspectGenerator<X>
java.io.IOException
public void generateSystemException(JavaWriter out, java.lang.Class<?> exn) throws java.io.IOException
generateSystemException
in interface AspectGenerator<X>
java.io.IOException
public void generateFinally(JavaWriter out) throws java.io.IOException
generateFinally
in interface AspectGenerator<X>
java.io.IOException
public void generatePostFinally(JavaWriter out) throws java.io.IOException
AspectGenerator
retType myMethod(...)
{
try {
...
value = bean.myMethod(...);
...
return value;
} finally {
...
}
[post-finally]
}
generatePostFinally
in interface AspectGenerator<X>
java.io.IOException
protected <Z extends java.lang.annotation.Annotation> Z getAnnotation(java.lang.Class<Z> annotationType, AnnotatedMethod<?> apiMethod, AnnotatedMethod<?> implMethod)
protected <Z extends java.lang.annotation.Annotation> Z getAnnotation(java.lang.Class<Z> annotationType, AnnotatedType<?> apiClass, AnnotatedType<?> implClass)
protected <Z extends java.lang.annotation.Annotation> Z getAnnotation(java.lang.Class<Z> annotationType, AnnotatedMethod<?> apiMethod, AnnotatedType<?> apiClass, AnnotatedMethod<?> implementationMethod, AnnotatedType<?> implementationClass)
public java.lang.String toString()
toString
in class java.lang.Object