Class InvocationHandlerForUnitTestingByteWeavedClasses

java.lang.Object
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 Details

    • objectsForByteWeaving

      protected Object[] objectsForByteWeaving
  • Constructor Details

    • InvocationHandlerForUnitTestingByteWeavedClasses

      public InvocationHandlerForUnitTestingByteWeavedClasses(Object[] objectsForByteWeaving)
  • Method Details

    • 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 -