Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.chaoswg.xtc4y.proxy
Class InvocationStack  view InvocationStack download InvocationStack.java

java.lang.Object
  extended bycom.chaoswg.xtc4y.proxy.InvocationStack
All Implemented Interfaces:
java.lang.reflect.InvocationHandler

public class InvocationStack
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

Invocation stack, used to trace calls on a class


Field Summary
private  java.lang.Object proxy
           
private  java.util.HashMap returnValues
           
private  java.util.Stack stack
           
private  java.lang.Class targetClass
           
private  java.lang.Object targetObject
           
 
Constructor Summary
InvocationStack(java.lang.Class target)
          Creates a new invocation stack and a proxy of a class if methods are invoked on this proxy, they are traced and default values are returned.
InvocationStack(java.lang.Object target)
          Creates a new invocationstack and a proxy of the given object.
 
Method Summary
 void emptyStack()
          Empty stack
 java.lang.reflect.Method getMethod(java.lang.String name)
           
 java.lang.reflect.Method getMethod(java.lang.String name, java.lang.Class[] params)
           
 java.lang.Object getProxyObject()
           
 java.lang.Object invoke(java.lang.Object obj, java.lang.reflect.Method method, java.lang.Object[] args)
          Implementation of a InvocationHandler
 MethodContainer peekStack()
           
 MethodContainer popStack()
           
 void removeReturnValue(java.lang.reflect.Method method)
          Remove a previously defined return value for a method
 void setReturnValue(java.lang.reflect.Method method, java.lang.Object value)
          set a return value for a specific method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stack

private java.util.Stack stack

proxy

private java.lang.Object proxy

targetObject

private java.lang.Object targetObject

targetClass

private java.lang.Class targetClass

returnValues

private java.util.HashMap returnValues
Constructor Detail

InvocationStack

public InvocationStack(java.lang.Class target)
Creates a new invocation stack and a proxy of a class if methods are invoked on this proxy, they are traced and default values are returned.


InvocationStack

public InvocationStack(java.lang.Object target)
Creates a new invocationstack and a proxy of the given object. if methods are invoked in the proxy, they are traced and the invocations are redirected to the target object

Method Detail

getProxyObject

public java.lang.Object getProxyObject()

popStack

public MethodContainer popStack()

peekStack

public MethodContainer peekStack()

emptyStack

public void emptyStack()
Empty stack


getMethod

public java.lang.reflect.Method getMethod(java.lang.String name)

getMethod

public java.lang.reflect.Method getMethod(java.lang.String name,
                                          java.lang.Class[] params)

setReturnValue

public void setReturnValue(java.lang.reflect.Method method,
                           java.lang.Object value)
set a return value for a specific method


removeReturnValue

public void removeReturnValue(java.lang.reflect.Method method)
Remove a previously defined return value for a method


invoke

public java.lang.Object invoke(java.lang.Object obj,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Implementation of a InvocationHandler

Specified by:
invoke in interface java.lang.reflect.InvocationHandler