jfun.yan.etc
Class InjectorHelper

java.lang.Object
  extended by jfun.yan.etc.InjectorHelper

public class InjectorHelper
extends java.lang.Object

This class provides helper functions to help dependency injections on objects not created by Yan.

Author:
Michelle Lei

Constructor Summary
InjectorHelper()
           
 
Method Summary
static Component getInjectorComponent(java.lang.Class injector_itf, Binder binder)
          To create a Component object that will instantiate an object that implements a certain injector interface.
static Component getProxyComponentReturningInjected(java.lang.Class itf, Component proxied, java.lang.Class injectee_type, Binder binder)
          To create a Component that instantiates proxy.
static Component getProxyComponentReturningInjected(java.lang.ClassLoader cloader, java.lang.Class itf, Component proxied, java.lang.Class injectee_type, Binder binder)
          To create a Component that instantiates proxy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InjectorHelper

public InjectorHelper()
Method Detail

getInjectorComponent

public static Component getInjectorComponent(java.lang.Class injector_itf,
                                             Binder binder)
To create a Component object that will instantiate an object that implements a certain injector interface.

The injector interface should describe at least one method that expects one and only one parameter object. This method is responsible for injecting dependencies into this parameter object.

The injection logic is encapsulated in a Binder object.

Parameters:
injector_itf - The injector interface class.
binder - the Binder object encapsulating the dependency injection logic.
Returns:
the Component that instantiates the injector object.

getProxyComponentReturningInjected

public static Component getProxyComponentReturningInjected(java.lang.ClassLoader cloader,
                                                           java.lang.Class itf,
                                                           Component proxied,
                                                           java.lang.Class injectee_type,
                                                           Binder binder)
To create a Component that instantiates proxy.

The proxy object is responsible for injecting dependencies into return values from the proxied methods.

The dependency injection logic is described by the binder object.

The instance instantiated by the proxied Component is proxied.

Only the dependencies of return values of injectee_type are injected.

Parameters:
cloader - The ClassLoader used by the dynamic proxy.
itf - the interface that the proxy implements.
proxied - the Component that instantiates the proxied object.
injectee_type - only return values of this type gets injected.
binder - this object encapsulates the injection logic.
Returns:
the new Component that instantiates the proxied object.

getProxyComponentReturningInjected

public static Component getProxyComponentReturningInjected(java.lang.Class itf,
                                                           Component proxied,
                                                           java.lang.Class injectee_type,
                                                           Binder binder)
To create a Component that instantiates proxy.

The proxy object is responsible for injecting dependencies into return values from the proxied methods.

The dependency injection logic is described by the binder object.

The instance instantiated by the proxied Component is proxied.

Only the dependencies of return values of injectee_type are injected.

The ClassLoader that loads the proxied instance is used to load the dynamic proxy.

Parameters:
itf - the interface that the proxy implements.
proxied - the Component that instantiates the proxied object.
injectee_type - only return values of this type gets injected.
binder - this object encapsulates the injection logic.
Returns:
the new Component that instantiates the proxied object.