|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.asm.MethodVisitor
org.objectweb.asm.commons.LocalVariablesSorter
org.objectweb.asm.commons.GeneratorAdapter
org.apache.aries.proxy.impl.common.AbstractWovenProxyMethodAdapter
public abstract class AbstractWovenProxyMethodAdapter
This class weaves dispatch and listener code into a method, there are two known
subclasses WovenProxyConcreteMethodAdapter
is used for weaving instance methods
WovenProxyAbstractMethodAdapter
is used to provide a delegating
implementation of an interface method.
Roughly (but not exactly because it's easier to write working bytecode
if you don't have to exactly recreate the Java!) this is trying to
do the following:
if(dispatcher != null) {
int returnValue;
Object token = null;
boolean inInvoke = false;
try {
Object toInvoke = dispatcher.call();
if(listener != null)
token = listener.preInvoke(toInvoke, method, args);
inInvoke = true;
returnValue = ((Template) toInvoke).doStuff(args);
inInvoke = false;
if(listener != null)
listener.postInvoke(token, toInvoke, method, args);
} catch (Throwable e){
// whether the the exception is an error is an application decision
// if we catch an exception we decide carefully which one to
// throw onwards
Throwable exceptionToRethrow = null;
// if the exception came from a precall or postcall
// we will rethrow it
if (!inInvoke) {
exceptionToRethrow = e;
}
// if the exception didn't come from precall or postcall then it
// came from invoke
// we will rethrow this exception if it is not a runtime
// exception, but we must unwrap InvocationTargetExceptions
else {
if (!(e instanceof RuntimeException)) {
exceptionToRethrow = e;
}
}
try {
if(listener != null)
listener.postInvokeExceptionalReturn(token, method, null, e);
} catch (Throwable f) {
// we caught an exception from
// postInvokeExceptionalReturn
// if we haven't already chosen an exception to rethrow then
// we will throw this exception
if (exceptionToRethrow == null) {
exceptionToRethrow = f;
}
}
// if we made it this far without choosing an exception we
// should throw e
if (exceptionToRethrow == null) {
exceptionToRethrow = e;
}
throw exceptionToRethrow;
}
}
//...original method body
Field Summary | |
---|---|
protected org.objectweb.asm.commons.Method |
currentTransformMethod
The current method |
protected org.objectweb.asm.Type |
typeBeingWoven
The type of this |
Fields inherited from class org.objectweb.asm.commons.GeneratorAdapter |
---|
ADD, AND, DIV, EQ, GE, GT, LE, LT, MUL, NE, NEG, OR, REM, SHL, SHR, SUB, USHR, XOR |
Fields inherited from class org.objectweb.asm.commons.LocalVariablesSorter |
---|
firstLocal, nextLocal |
Fields inherited from class org.objectweb.asm.MethodVisitor |
---|
api, mv |
Constructor Summary | |
---|---|
AbstractWovenProxyMethodAdapter(org.objectweb.asm.MethodVisitor mv,
int access,
String name,
String desc,
String methodStaticFieldName,
org.objectweb.asm.commons.Method currentTransformMethod,
org.objectweb.asm.Type typeBeingWoven,
org.objectweb.asm.Type methodDeclaringType,
boolean isMethodDeclaringTypeInterface)
Construct a new method adapter |
Method Summary | |
---|---|
protected void |
unwrapEqualsArgument()
This method unwraps woven proxy instances for use in the right-hand side of equals methods |
abstract void |
visitCode()
|
abstract void |
visitMaxs(int stack,
int locals)
|
protected void |
writeDispatcher()
Write out the bytecode instructions necessary to do the dispatch. |
Methods inherited from class org.objectweb.asm.commons.GeneratorAdapter |
---|
arrayLength, arrayLoad, arrayStore, box, cast, catchException, checkCast, dup, dup2, dup2X1, dup2X2, dupX1, dupX2, endMethod, getField, getLocalType, getStatic, goTo, ifCmp, ifICmp, ifNonNull, ifNull, ifZCmp, iinc, instanceOf, invokeConstructor, invokeDynamic, invokeInterface, invokeStatic, invokeVirtual, loadArg, loadArgArray, loadArgs, loadArgs, loadLocal, loadLocal, loadThis, mark, mark, math, monitorEnter, monitorExit, newArray, newInstance, newLabel, not, pop, pop2, push, push, push, push, push, push, push, push, putField, putStatic, ret, returnValue, setLocalType, storeArg, storeLocal, storeLocal, swap, swap, tableSwitch, tableSwitch, throwException, throwException, unbox, valueOf |
Methods inherited from class org.objectweb.asm.commons.LocalVariablesSorter |
---|
newLocal, newLocalMapping, visitFrame, visitIincInsn, visitLocalVariable, visitVarInsn |
Methods inherited from class org.objectweb.asm.MethodVisitor |
---|
visitAnnotation, visitAnnotationDefault, visitAttribute, visitEnd, visitFieldInsn, visitInsn, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLookupSwitchInsn, visitMethodInsn, visitMultiANewArrayInsn, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchBlock, visitTypeInsn |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.objectweb.asm.commons.Method currentTransformMethod
protected final org.objectweb.asm.Type typeBeingWoven
this
Constructor Detail |
---|
public AbstractWovenProxyMethodAdapter(org.objectweb.asm.MethodVisitor mv, int access, String name, String desc, String methodStaticFieldName, org.objectweb.asm.commons.Method currentTransformMethod, org.objectweb.asm.Type typeBeingWoven, org.objectweb.asm.Type methodDeclaringType, boolean isMethodDeclaringTypeInterface)
mv
- - the method visitor to write toaccess
- - the access modifiers on this methodname
- - the name of this methoddesc
- - the descriptor of this methodmethodStaticFieldName
- - the name of the static field that will hold
the Method
representing
this method.currentTransformMethod
- - the ASM representation of this methodproxyType
- - the type being woven that contains this methodMethod Detail |
---|
public abstract void visitCode()
visitCode
in class org.objectweb.asm.MethodVisitor
public abstract void visitMaxs(int stack, int locals)
visitMaxs
in class org.objectweb.asm.commons.LocalVariablesSorter
protected final void writeDispatcher()
protected final void unwrapEqualsArgument()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |