org.openejb.util.proxy
Class ProxyManager

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

public class ProxyManager
extends java.lang.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 java.lang.String getDefaultFactoryName()
           
static ProxyFactory getFactory(java.lang.String factoryName)
           
static InvocationHandler getInvocationHandler(java.lang.Object proxy)
          Casts the object passed in to the appropriate proxy type and retreives the InvocationHandler assigned to it.
static java.lang.Class getProxyClass(java.lang.Class interfaceType)
          Loads and returns the proxy implementation for the specified interface.
static java.lang.Class getProxyClass(java.lang.Class[] interfaces)
           
static boolean isProxyClass(java.lang.Class cl)
           
static java.lang.Object newProxyInstance(java.lang.Class proxyClass)
          Create a new proxy instance given a proxy class.
static java.lang.Object newProxyInstance(java.lang.Class[] interfaces, InvocationHandler h)
           
static java.lang.Object newProxyInstance(java.lang.Class interfaceType, InvocationHandler h)
          Throws a RuntimeException if there is a problem instantiating the new proxy instance.
static ProxyFactory registerFactory(java.lang.String factoryName, ProxyFactory factory)
           
static ProxyFactory setDefaultFactory(java.lang.String factoryName)
          Sets the default factory.
static java.lang.Object setInvocationHandler(java.lang.Object proxy, InvocationHandler handler)
          Casts the object passed in to the appropriate proxy type and sets the InvocationHandler assigned to it.
static ProxyFactory unregisterFactory(java.lang.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(java.lang.String factoryName,
                                           ProxyFactory factory)

unregisterFactory

public static ProxyFactory unregisterFactory(java.lang.String factoryName)

checkDefaultFactory

public static void checkDefaultFactory()

getFactory

public static ProxyFactory getFactory(java.lang.String factoryName)

setDefaultFactory

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

Parameters:
factoryName -

getDefaultFactory

public static ProxyFactory getDefaultFactory()

getDefaultFactoryName

public static java.lang.String getDefaultFactoryName()

getInvocationHandler

public static InvocationHandler getInvocationHandler(java.lang.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 java.lang.Object setInvocationHandler(java.lang.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 java.lang.Class getProxyClass(java.lang.Class interfaceType)
                                     throws java.lang.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:
java.lang.IllegalAccessException

getProxyClass

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

newProxyInstance

public static java.lang.Object newProxyInstance(java.lang.Class interfaceType,
                                                InvocationHandler h)
                                         throws java.lang.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:
java.lang.IllegalAccessException

newProxyInstance

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

isProxyClass

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

newProxyInstance

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

Throws:
java.lang.IllegalAccessException


Copyright © 1999-2011 OpenEJB. All Rights Reserved.