org.broadleafcommerce.common.util
Class InvocationHandlerForUnitTestingByteWeavedClasses

java.lang.Object
  extended by org.broadleafcommerce.common.util.InvocationHandlerForUnitTestingByteWeavedClasses
All Implemented Interfaces:
InvocationHandler

public class InvocationHandlerForUnitTestingByteWeavedClasses
extends Object
implements InvocationHandler

Invocation handler for unit testing byte-weaved classes. Use this InvocationHandler and utility method when Spring is unavailable to complete byte-weaving.

Author:
Joshua Skorton (jskorton)

Field Summary
protected  Object[] objectsForByteWeaving
           
 
Constructor Summary
InvocationHandlerForUnitTestingByteWeavedClasses(Object[] objectsForByteWeaving)
           
 
Method Summary
static
<T> T
createProxy(Class<T> proxyType, Class<?>[] interfaces, Object[] objectsForByteWeaving)
          This utility method will return a Proxy of a chosen type that response to an array of chose Interfaces and uses a InvocationHandlerForUnitTestingByteWeavedClasses that is backed by an array of chosen Objects.
 Object[] getObjectsForByteWeaving()
          Returns an array of Objects that are meant to be byte-weaved.
 Object invoke(Object proxy, Method method, Object[] args)
          Will invoke a chosen method against an array of Objects that are meant to be byte-weaved together.
 void setObjectsForByteWeaving(Object[] objects)
          Sets an array of Objects that are meant to be byte-weaved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectsForByteWeaving

protected Object[] objectsForByteWeaving
Constructor Detail

InvocationHandlerForUnitTestingByteWeavedClasses

public InvocationHandlerForUnitTestingByteWeavedClasses(Object[] objectsForByteWeaving)
Method Detail

createProxy

public static <T> T createProxy(Class<T> proxyType,
                                Class<?>[] interfaces,
                                Object[] objectsForByteWeaving)
This utility method will return a Proxy of a chosen type that response to an array of chose Interfaces and uses a InvocationHandlerForUnitTestingByteWeavedClasses that is backed by an array of chosen Objects.

Parameters:
proxyType -
interfaces -
objectsForByteWeaving -
Returns:

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Will invoke a chosen method against an array of Objects that are meant to be byte-weaved together. Invoke will return when the first object is found that can be successfully used with the chosen method. If no objects are found to work with the chosen method, null will be returned.

Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

getObjectsForByteWeaving

public Object[] getObjectsForByteWeaving()
Returns an array of Objects that are meant to be byte-weaved.

Returns:

setObjectsForByteWeaving

public void setObjectsForByteWeaving(Object[] objects)
Sets an array of Objects that are meant to be byte-weaved.

Parameters:
objects -


Copyright © 2013. All Rights Reserved.