jfun.yan.etc
Class InjectingProxy

java.lang.Object
  extended by jfun.yan.etc.InjectingProxy
All Implemented Interfaces:
java.lang.reflect.InvocationHandler

public final class InjectingProxy
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

A proxy class that injects dependencies into objects returned from the proxied methods.

a Mutation object is used to fulfill the injection.

Author:
Ben Yu

Method Summary
 boolean equals(java.lang.Object obj)
           
static java.lang.Object getInjectingProxy(java.lang.ClassLoader cloader, java.lang.Class[] itfs, java.lang.Object proxied, java.lang.Class injectee_type, Mutation injector)
          To create a proxy that injects dependency into return values of the proxied methods.
static java.lang.Object getInjectingProxy(java.lang.ClassLoader cloader, java.lang.Class itf, java.lang.Object proxied, java.lang.Class injectee_type, Mutation injector)
          To create a proxy that injects dependency into return values of the proxied methods.
static java.lang.Object getInjectingProxy(java.lang.Class itf, java.lang.Object proxied, java.lang.Class injectee_type, Mutation injector)
          To create a proxy that injects dependency into return values of the proxied methods.
static java.lang.Object getInjectingProxy(java.lang.Object proxied, java.lang.Class injectee_type, Mutation injector)
          To create a proxy that injects dependency into return values of the proxied methods.
 int hashCode()
           
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method mtd, java.lang.Object[] args)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method mtd,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getInjectingProxy

public static java.lang.Object getInjectingProxy(java.lang.ClassLoader cloader,
                                                 java.lang.Class[] itfs,
                                                 java.lang.Object proxied,
                                                 java.lang.Class injectee_type,
                                                 Mutation injector)
To create a proxy that injects dependency into return values of the proxied methods.

Parameters:
cloader - the ClassLoader used by the dynamic proxy.
itfs - the interfaces that the proxy object implements.
proxied - the object to be proxied.
injectee_type - For return values of this type, dependencies are injected.
injector - the object responsible for injecting dependencies.
Returns:
the proxy object.

getInjectingProxy

public static java.lang.Object getInjectingProxy(java.lang.ClassLoader cloader,
                                                 java.lang.Class itf,
                                                 java.lang.Object proxied,
                                                 java.lang.Class injectee_type,
                                                 Mutation injector)
To create a proxy that injects dependency into return values of the proxied methods.

Parameters:
cloader - the ClassLoader used by the dynamic proxy.
itf - the interface that the proxy object implements.
proxied - the object to be proxied.
injectee_type - For return values of this type, dependencies are injected.
injector - the object responsible for injecting dependencies.
Returns:
the proxy object.

getInjectingProxy

public static java.lang.Object getInjectingProxy(java.lang.Class itf,
                                                 java.lang.Object proxied,
                                                 java.lang.Class injectee_type,
                                                 Mutation injector)
To create a proxy that injects dependency into return values of the proxied methods.

The ClassLoader of the proxied object is used to load the proxy class.

Parameters:
itf - the interface that the proxy object implements.
proxied - the object to be proxied.
injectee_type - For return values of this type, dependencies are injected.
injector - the object responsible for injecting dependencies.
Returns:
the proxy object.

getInjectingProxy

public static java.lang.Object getInjectingProxy(java.lang.Object proxied,
                                                 java.lang.Class injectee_type,
                                                 Mutation injector)
To create a proxy that injects dependency into return values of the proxied methods. The proxy implements all interfaces implemented by the proxied object.

The ClassLoader of the proxied object is used to load the proxy class.

Parameters:
proxied - the object to be proxied.
injectee_type - For return values of this type, dependencies are injected.
injector - the object responsible for injecting dependencies.
Returns:
the proxy object.