Package org.jboss.weld.bean.proxy
Class ClientProxyFactory<T>
- java.lang.Object
-
- org.jboss.weld.bean.proxy.ProxyFactory<T>
-
- org.jboss.weld.bean.proxy.ClientProxyFactory<T>
-
- All Implemented Interfaces:
PrivilegedAction<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
-
Fields inherited from class org.jboss.weld.bean.proxy.ProxyFactory
CONSTRUCTED_FLAG_NAME, DEFAULT_METHOD_RESOLVER, DEFAULT_PROXY_PACKAGE, INIT_METHOD_NAME, INVOKE_METHOD_NAME, LBEAN_IDENTIFIER, LJAVA_LANG_BYTE, LJAVA_LANG_CLASS, LJAVA_LANG_OBJECT, LJAVA_LANG_REFLECT_METHOD, LJAVA_LANG_STRING, LJAVA_LANG_THREAD_LOCAL, METHOD_HANDLER_FIELD_NAME, PROXY_SUFFIX, WELD_PROXY_PREFIX
-
-
Constructor Summary
Constructors Constructor Description ClientProxyFactory(String contextId, Class<?> proxiedBeanType, Set<? extends Type> typeClosure, jakarta.enterprise.inject.spi.Bean<?> bean)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAdditionalInterfaces(Set<Class<?>> interfaces)
Sub classes may override to specify additional interfaces the proxy should implementprotected void
addFields(org.jboss.classfilewriter.ClassFile proxyClassType, List<DeferredBytecode> initialValueBytecode)
protected void
addMethods(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor)
protected void
addSerializationSupport(org.jboss.classfilewriter.ClassFile proxyClassType)
Adds special serialization code.T
create(BeanInstance beanInstance)
Method to create a new proxy that wraps the bean instance.protected void
createForwardingMethodBody(org.jboss.classfilewriter.ClassMethod classMethod, MethodInformation methodInfo, org.jboss.classfilewriter.ClassMethod staticConstructor)
Calls methodHandler.invoke with a null method parameter in order to get the underlying instance.protected void
generateEqualsMethod(org.jboss.classfilewriter.ClassFile proxyClassType)
Client proxies are equal to other client proxies for the same bean.protected void
generateHashCodeMethod(org.jboss.classfilewriter.ClassFile proxyClassType)
Client proxies use the following hashCode:MyProxyName.class.hashCode()
protected Class<? extends MethodHandler>
getMethodHandlerType()
protected String
getProxyNameSuffix()
Returns a suffix to append to the name of the proxy class.protected boolean
isMethodAccepted(Method method, Class<?> proxySuperclass)
-
Methods inherited from class org.jboss.weld.bean.proxy.ProxyFactory
addConstructedGuardToMethodBody, addConstructedGuardToMethodBody, addConstructors, addInterface, addInterfacesFromTypeClosure, addMethodsFromClass, addSpecialMethods, createInterceptorBody, createSpecialMethodBody, generateGetMethodHandlerBody, generateSetMethodHandlerBody, getAdditionalInterfaces, getBaseProxyName, getBean, getBeanType, getContextId, getMethodHandlerField, getProxiedBeanType, getProxyClass, getProxySuperclass, invokeMethodHandler, isUsingProxyInstantiator, run, setBeanInstance, toClass
-
-
-
-
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 classProxyFactory<T>
- Parameters:
beanInstance
- the bean instance- Returns:
- a new proxy object
-
addAdditionalInterfaces
protected void addAdditionalInterfaces(Set<Class<?>> interfaces)
Description copied from class:ProxyFactory
Sub classes may override to specify additional interfaces the proxy should implement- Overrides:
addAdditionalInterfaces
in classProxyFactory<T>
-
addMethods
protected void addMethods(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor)
- Overrides:
addMethods
in classProxyFactory<T>
-
addFields
protected void addFields(org.jboss.classfilewriter.ClassFile proxyClassType, List<DeferredBytecode> initialValueBytecode)
- Overrides:
addFields
in classProxyFactory<T>
-
getMethodHandlerType
protected Class<? extends MethodHandler> getMethodHandlerType()
- Overrides:
getMethodHandlerType
in classProxyFactory<T>
-
addSerializationSupport
protected void addSerializationSupport(org.jboss.classfilewriter.ClassFile proxyClassType)
Description copied from class:ProxyFactory
Adds special serialization code. By default this is a nop- Overrides:
addSerializationSupport
in classProxyFactory<T>
- Parameters:
proxyClassType
- the Javassist class for the proxy class
-
createForwardingMethodBody
protected void createForwardingMethodBody(org.jboss.classfilewriter.ClassMethod classMethod, MethodInformation methodInfo, org.jboss.classfilewriter.ClassMethod staticConstructor)
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 classProxyFactory<T>
-
generateHashCodeMethod
protected void generateHashCodeMethod(org.jboss.classfilewriter.ClassFile proxyClassType)
Client proxies use the following hashCode:MyProxyName.class.hashCode()
- Overrides:
generateHashCodeMethod
in classProxyFactory<T>
-
generateEqualsMethod
protected void generateEqualsMethod(org.jboss.classfilewriter.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 classProxyFactory<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 classProxyFactory<T>
- Returns:
- a name suffix
-
isMethodAccepted
protected boolean isMethodAccepted(Method method, Class<?> proxySuperclass)
- Overrides:
isMethodAccepted
in classProxyFactory<T>
-
-