com.aurorasoftworks.signal.runtime.core.context.proxy
Class ProxyFactory

java.lang.Object
  extended by com.aurorasoftworks.signal.runtime.core.context.proxy.ProxyFactory
All Implemented Interfaces:
IProxyFactory

public class ProxyFactory
extends java.lang.Object
implements IProxyFactory

Default implementation of the IProxyFactory interface.

Author:
Marek

Field Summary
static java.lang.String PROXY_CLASS_SUFFIX
           
static java.lang.String PROXY_META_CLASS_SUFFIX
           
 
Constructor Summary
ProxyFactory()
           
 
Method Summary
 IProxy createLazyInitProxy(IBeanDelegate reference)
          Creates a lazy init proxy for the specified bean reference.
 IProxy createProxy(IProxyTarget target, IInvocationHandler handler)
          Creates a new proxy for the specified object.
 IProxy createProxy(IProxyTarget target, IMethodInterceptor[] interceptors)
          Creates a new proxy for the specified object using the specified interceptors.
protected  AbstractProxy doCreateProxy(java.lang.Class targetClass)
           
protected  AbstractProxy doCreateProxy(IProxyTarget target)
           
static IProxyFactory getInstance()
           
 IProxyClass getProxyClass(java.lang.Class targetClass)
          Returns an IProxyClass object for the specified class.
static java.lang.String getProxyClassName(java.lang.Class proxyClass)
           
static java.lang.String getProxyClassName(IProxyTarget proxyTarget)
           
static java.lang.String getProxyMetaClassName(java.lang.Class proxyClass)
           
static java.lang.String getProxyMetaClassName(IProxyTarget proxyTarget)
           
protected  java.lang.Class loadClass(java.lang.String className)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROXY_CLASS_SUFFIX

public static final java.lang.String PROXY_CLASS_SUFFIX
See Also:
Constant Field Values

PROXY_META_CLASS_SUFFIX

public static final java.lang.String PROXY_META_CLASS_SUFFIX
See Also:
Constant Field Values
Constructor Detail

ProxyFactory

public ProxyFactory()
Method Detail

getInstance

public static IProxyFactory getInstance()

getProxyClassName

public static java.lang.String getProxyClassName(java.lang.Class proxyClass)

getProxyClassName

public static java.lang.String getProxyClassName(IProxyTarget proxyTarget)

getProxyMetaClassName

public static java.lang.String getProxyMetaClassName(java.lang.Class proxyClass)

getProxyMetaClassName

public static java.lang.String getProxyMetaClassName(IProxyTarget proxyTarget)

createProxy

public IProxy createProxy(IProxyTarget target,
                          IInvocationHandler handler)
                   throws java.lang.Exception
Creates a new proxy for the specified object. All method calls are forwarded to the provided handler. Depending on how the handler is implemented calls may or may not be invoked on the target object. This method is similar to Proxy.newProxyInstance(ClassLoader, Class[], java.lang.reflect.InvocationHandler).

Specified by:
createProxy in interface IProxyFactory
Parameters:
target - an object to create a proxy for
handler - an invocation handler to forward intercepted method calls to
Returns:
value to be returned by the intercepted call
Throws:
java.lang.Exception

doCreateProxy

protected AbstractProxy doCreateProxy(IProxyTarget target)
                               throws java.lang.Exception
Throws:
java.lang.Exception

doCreateProxy

protected AbstractProxy doCreateProxy(java.lang.Class targetClass)
                               throws java.lang.Exception
Throws:
java.lang.Exception

createLazyInitProxy

public IProxy createLazyInitProxy(IBeanDelegate reference)
                           throws java.lang.Exception
Creates a lazy init proxy for the specified bean reference. When any method is invoked on the returned proxy the bean wrapped by the reference is created by calling IBeanReference#getBean().

Specified by:
createLazyInitProxy in interface IProxyFactory
Parameters:
reference - a bean reference to be wrapped by a lazy init proxy
Returns:
a lazy init proxy
Throws:
java.lang.Exception

createProxy

public IProxy createProxy(IProxyTarget target,
                          IMethodInterceptor[] interceptors)
                   throws java.lang.Exception
Creates a new proxy for the specified object using the specified interceptors. This method creates a sequence of method invocation handlers that contains the specified interceptors and the target object at the end. Each handler in the chain can choose whether to forward the call to the next handler or not.

Specified by:
createProxy in interface IProxyFactory
Parameters:
target - an object to create a proxy for
interceptors - an array of method interceptors
Returns:
Throws:
java.lang.Exception

getProxyClass

public IProxyClass getProxyClass(java.lang.Class targetClass)
                          throws java.lang.Exception
Returns an IProxyClass object for the specified class.

Specified by:
getProxyClass in interface IProxyFactory
Parameters:
targetClass - a class to return a proxy class for
Returns:
proxy class
Throws:
java.lang.Exception

loadClass

protected java.lang.Class loadClass(java.lang.String className)
                             throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2010. All Rights Reserved.