Class DelayedCopyableHandler

java.lang.Object
org.kuali.rice.krad.uif.util.DelayedCopyableHandler
All Implemented Interfaces:
InvocationHandler

public class DelayedCopyableHandler extends Object implements InvocationHandler
Proxy invocation handler for delaying deep copy for framework objects that may not need to be fully traversed by each transaction.

Proxied objects served by this handler will refer to the original source object until a potentially read-write method is invoked. Once such a method is invoked, then the original source is copied to a new object on the fly and the call is forwarded to the copy.

Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Method Details

    • invoke

      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
      Intercept method calls, and copy the original source object as needed. The determination that a method is read-write is made based on the method name and/or return type as follows:
      • Methods starting with "get" or "is", are considered read-only
      • Methods returning Copyable, List, Map, or an array, are considered read-write regardless of name
      Specified by:
      invoke in interface InvocationHandler
      Throws:
      Throwable
    • isPendingDelayedCopy

      public static boolean isPendingDelayedCopy(Copyable source)
      Determins if a source object is a delayed copy proxy that hasn't been copied yet.
      Parameters:
      source - The object to check.
      Returns:
      True if source is a delayed copy proxy instance, and hasn't been copied yet.
    • getDelayedCopy

      public static Copyable getDelayedCopy(Copyable source)
      Get a proxy instance providing delayed copy behavior on a source component.
      Parameters:
      source - The source object
      Returns:
      proxy instance wrapping the object