org.jboss.weld.bean.proxy
Class ClientProxyFactory<T>

java.lang.Object
  extended by org.jboss.weld.bean.proxy.ProxyFactory<T>
      extended by org.jboss.weld.bean.proxy.ClientProxyFactory<T>

public class ClientProxyFactory<T>
extends ProxyFactory<T>

Proxy factory that generates client proxies, it uses optimizations that are not valid for other proxy types.

Author:
Stuart Douglas, Marius Bogoevici

Field Summary
static String CLIENT_PROXY_SUFFIX
           
 
Fields inherited from class org.jboss.weld.bean.proxy.ProxyFactory
CONSTRUCTED_FLAG_NAME, DEFAULT_METHOD_RESOLVER, DEFAULT_PROXY_PACKAGE, log, PROXY_SUFFIX
 
Constructor Summary
ClientProxyFactory(Class<?> proxiedBeanType, Set<? extends Type> typeClosure, javax.enterprise.inject.spi.Bean<?> bean)
           
 
Method Summary
protected  void addFields(javassist.bytecode.ClassFile proxyClassType, javassist.bytecode.Bytecode initialValueBytecode)
           
protected  void addSerializationSupport(javassist.bytecode.ClassFile proxyClassType)
          Adds special serialization code.
 T create(BeanInstance beanInstance)
          Method to create a new proxy that wraps the bean instance.
protected  javassist.bytecode.Bytecode createForwardingMethodBody(javassist.bytecode.ClassFile file, MethodInformation methodInfo)
          Calls methodHandler.invoke with a null method parameter in order to get the underlying instance.
protected  javassist.bytecode.MethodInfo generateEqualsMethod(javassist.bytecode.ClassFile proxyClassType)
          Client proxies are equal to other client proxies for the same bean.
protected  javassist.bytecode.MethodInfo generateHashCodeMethod(javassist.bytecode.ClassFile proxyClassType)
          Client proxies use the following hashCode: MyProxyName.class.hashCode()
protected  String getProxyNameSuffix()
          Returns a suffix to append to the name of the proxy class.
 
Methods inherited from class org.jboss.weld.bean.proxy.ProxyFactory
addAdditionalInterfaces, addConstructedGuardToMethodBody, addConstructors, addInterface, addMethods, addMethodsFromClass, addSpecialMethods, createInterceptorBody, createSpecialMethodBody, getAdditionalInterfaces, getBaseProxyName, getBean, getBeanType, getProxyClass, invokeMethodHandler, isProxy, resolveClassLoaderForBeanProxy, resolveClassLoaderForBeanProxy, setBeanInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLIENT_PROXY_SUFFIX

public static final String CLIENT_PROXY_SUFFIX
See Also:
Constant Field Values
Constructor Detail

ClientProxyFactory

public ClientProxyFactory(Class<?> proxiedBeanType,
                          Set<? extends Type> typeClosure,
                          javax.enterprise.inject.spi.Bean<?> bean)
Method Detail

create

public T create(BeanInstance beanInstance)
Description copied from class: ProxyFactory
Method to create a new proxy that wraps the bean instance.

Overrides:
create in class ProxyFactory<T>
Parameters:
beanInstance - the bean instance
Returns:
a new proxy object

addFields

protected void addFields(javassist.bytecode.ClassFile proxyClassType,
                         javassist.bytecode.Bytecode initialValueBytecode)
Overrides:
addFields in class ProxyFactory<T>

addSerializationSupport

protected void addSerializationSupport(javassist.bytecode.ClassFile proxyClassType)
Description copied from class: ProxyFactory
Adds special serialization code. By default this is a nop

Overrides:
addSerializationSupport in class ProxyFactory<T>
Parameters:
proxyClassType - the Javassist class for the proxy class

createForwardingMethodBody

protected javassist.bytecode.Bytecode createForwardingMethodBody(javassist.bytecode.ClassFile file,
                                                                 MethodInformation methodInfo)
                                                          throws javassist.NotFoundException
Calls methodHandler.invoke with a null method parameter in order to get the underlying instance. The invocation is then forwarded to this instance with generated bytecode.

Overrides:
createForwardingMethodBody in class ProxyFactory<T>
Throws:
javassist.NotFoundException

generateHashCodeMethod

protected javassist.bytecode.MethodInfo generateHashCodeMethod(javassist.bytecode.ClassFile proxyClassType)
Client proxies use the following hashCode: MyProxyName.class.hashCode()

Overrides:
generateHashCodeMethod in class ProxyFactory<T>

generateEqualsMethod

protected javassist.bytecode.MethodInfo generateEqualsMethod(javassist.bytecode.ClassFile proxyClassType)
Client proxies are equal to other client proxies for the same bean.

The corresponding java code: return other instanceof MyProxyClassType.class

Overrides:
generateEqualsMethod in class ProxyFactory<T>
Parameters:
proxyClassType - The class file

getProxyNameSuffix

protected String getProxyNameSuffix()
Description copied from class: ProxyFactory
Returns a suffix to append to the name of the proxy class. The name already consists of _$$_Weld, to which the suffix is added. This allows the creation of different types of proxies for the same class.

Overrides:
getProxyNameSuffix in class ProxyFactory<T>
Returns:
a name suffix


Copyright © 2013 Seam Framework. All Rights Reserved.