org.openejb.util.proxy
Class ProxyManager

java.lang.Object
  extended by org.openejb.util.proxy.ProxyManager

public class ProxyManager
extends Object

Author:
David Blevins, Richard Monson-Haefel, Aaron Mulder (ammulder@alumni.princeton.edu)

Constructor Summary
ProxyManager()
           
 
Method Summary
static void checkDefaultFactory()
           
static ProxyFactory getDefaultFactory()
           
static String getDefaultFactoryName()
           
static ProxyFactory getFactory(String factoryName)
           
static InvocationHandler getInvocationHandler(Object proxy)
          Casts the object passed in to the appropriate proxy type and retreives the InvocationHandler assigned to it.
static Class getProxyClass(Class interfaceType)
          Loads and returns the proxy implementation for the specified interface.
static Class getProxyClass(Class[] interfaces)
           
static boolean isProxyClass(Class cl)
           
static Object newProxyInstance(Class proxyClass)
          Create a new proxy instance given a proxy class.
static Object newProxyInstance(Class[] interfaces, InvocationHandler h)
           
static Object newProxyInstance(Class interfaceType, InvocationHandler h)
          Throws a RuntimeException if there is a problem instantiating the new proxy instance.
static ProxyFactory registerFactory(String factoryName, ProxyFactory factory)
           
static ProxyFactory setDefaultFactory(String factoryName)
          Sets the default factory.
static Object setInvocationHandler(Object proxy, InvocationHandler handler)
          Casts the object passed in to the appropriate proxy type and sets the InvocationHandler assigned to it.
static ProxyFactory unregisterFactory(String factoryName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxyManager

public ProxyManager()
Method Detail

registerFactory

public static ProxyFactory registerFactory(String factoryName,
                                           ProxyFactory factory)

unregisterFactory

public static ProxyFactory unregisterFactory(String factoryName)

checkDefaultFactory

public static void checkDefaultFactory()

getFactory

public static ProxyFactory getFactory(String factoryName)

setDefaultFactory

public static ProxyFactory setDefaultFactory(String factoryName)
Sets the default factory. The factory must already be registered.

Parameters:
factoryName -

getDefaultFactory

public static ProxyFactory getDefaultFactory()

getDefaultFactoryName

public static String getDefaultFactoryName()

getInvocationHandler

public static InvocationHandler getInvocationHandler(Object proxy)
Casts the object passed in to the appropriate proxy type and retreives the InvocationHandler assigned to it. Executes on the default ProxyFactory instance.

Parameters:
proxy - The Proxy object to retreive the InvocationHandler from.
Returns:
The implementation of InvocationHandler handling invocations on the specified Proxy object.

setInvocationHandler

public static Object setInvocationHandler(Object proxy,
                                          InvocationHandler handler)
Casts the object passed in to the appropriate proxy type and sets the InvocationHandler assigned to it.

Parameters:
proxy - The Proxy object to retreive the InvocationHandler from.
Returns:
The Proxy object with the new InvocationHandler.

getProxyClass

public static Class getProxyClass(Class interfaceType)
                           throws IllegalAccessException
Loads and returns the proxy implementation for the specified interface. The Class object is loaded using ProxyClassLoader.loadClass. If the class definition is not found, the findClass method will be called by the VM; at which point, the proxy class byte code will be generated by ProxyFactory and resolved by the VM.

Parameters:
interfaceType -
Returns:
Class
Throws:
IllegalAccessException

getProxyClass

public static Class getProxyClass(Class[] interfaces)
                           throws IllegalAccessException
Throws:
IllegalAccessException

newProxyInstance

public static Object newProxyInstance(Class interfaceType,
                                      InvocationHandler h)
                               throws IllegalAccessException
Throws a RuntimeException if there is a problem instantiating the new proxy instance.

Parameters:
interfaceType - A bean's home or remote interface that the Proxy object should implement.
h -
Returns:
Object
Throws:
IllegalAccessException

newProxyInstance

public static Object newProxyInstance(Class[] interfaces,
                                      InvocationHandler h)
                               throws IllegalAccessException
Throws:
IllegalAccessException

isProxyClass

public static boolean isProxyClass(Class cl)
Parameters:
cl -
Returns:
boolean

newProxyInstance

public static Object newProxyInstance(Class proxyClass)
                               throws IllegalAccessException
Create a new proxy instance given a proxy class.

Throws:
IllegalAccessException


Copyright © 1999-2008 OpenEJB. All Rights Reserved.