org.kuali.rice.core.impl.resourceloader
Class ContextClassLoaderProxy

java.lang.Object
  extended by org.kuali.rice.core.impl.proxy.BaseInvocationHandler
      extended by org.kuali.rice.core.impl.proxy.BaseTargetedInvocationHandler
          extended by org.kuali.rice.core.impl.resourceloader.ContextClassLoaderProxy
All Implemented Interfaces:
InvocationHandler, TargetedInvocationHandler

public class ContextClassLoaderProxy
extends BaseTargetedInvocationHandler

A Proxy that sets the thread Context ClassLoader before invocation of the proxied object, and resets it back afterwards.

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

Constructor Summary
ContextClassLoaderProxy(ClassLoader classLoader, Object target)
           
 
Method Summary
static Class[] getInterfacesToProxy(ClassLoader proxyClassLoader, Object proxiedObject)
          Determines the interfaces which need to be proxied and are visable to the given proxy ClassLoader.
static Class[] getInterfacesToProxy(Object proxiedObject)
           
protected  Object invokeInternal(Object proxy, Method m, Object[] args)
           
static Object wrap(Object proxiedObject)
           
static Object wrap(Object proxiedObject, Class[] classesToProxy)
           
static Object wrap(Object proxiedObject, Class[] classesToProxy, ClassLoader classLoader)
           
static Object wrap(Object proxiedObject, Class[] classesToProxy, ClassLoader proxyClassLoader, ClassLoader objectClassLoader)
          Convenience method that wraps a specified object with a ContextClassLoaderProxy, with a specified handler classloader and proxy classloader.
static Object wrap(Object proxiedObject, ClassLoader classLoader)
           
static Object wrap(Object proxiedObject, ClassLoader proxyClassLoader, ClassLoader objectClassLoader)
           
 
Methods inherited from class org.kuali.rice.core.impl.proxy.BaseTargetedInvocationHandler
getTarget, setTarget
 
Methods inherited from class org.kuali.rice.core.impl.proxy.BaseInvocationHandler
invoke, proxyEquals, proxyHashCode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.reflect.InvocationHandler
invoke
 

Constructor Detail

ContextClassLoaderProxy

public ContextClassLoaderProxy(ClassLoader classLoader,
                               Object target)
Method Detail

wrap

public static Object wrap(Object proxiedObject,
                          Class[] classesToProxy,
                          ClassLoader proxyClassLoader,
                          ClassLoader objectClassLoader)
Convenience method that wraps a specified object with a ContextClassLoaderProxy, with a specified handler classloader and proxy classloader. If the specified object is null, or the object classloader equals the proxy classloader, the object is returned unwrapped.

Parameters:
proxiedObject - the object to proxy
proxyClassLoader - the classloader OF THE PROXY INSTANCE
objectClassLoader - the classloader to set as the context classloader prior to any invocations on the proxiedObject
Returns:
a ContextClassLoaderProxy Proxy for the proxiedObject

wrap

public static Object wrap(Object proxiedObject,
                          ClassLoader proxyClassLoader,
                          ClassLoader objectClassLoader)

wrap

public static Object wrap(Object proxiedObject,
                          ClassLoader classLoader)

wrap

public static Object wrap(Object proxiedObject,
                          Class[] classesToProxy)

wrap

public static Object wrap(Object proxiedObject,
                          Class[] classesToProxy,
                          ClassLoader classLoader)

wrap

public static Object wrap(Object proxiedObject)

getInterfacesToProxy

public static Class[] getInterfacesToProxy(Object proxiedObject)

getInterfacesToProxy

public static Class[] getInterfacesToProxy(ClassLoader proxyClassLoader,
                                           Object proxiedObject)
Determines the interfaces which need to be proxied and are visable to the given proxy ClassLoader.


invokeInternal

protected Object invokeInternal(Object proxy,
                                Method m,
                                Object[] args)
                         throws Throwable
Specified by:
invokeInternal in class BaseInvocationHandler
Throws:
Throwable


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.