Package org.jboss.weld.bean.proxy
Class InterceptedSubclassFactory<T>
- java.lang.Object
-
- org.jboss.weld.bean.proxy.ProxyFactory<T>
-
- org.jboss.weld.bean.proxy.InterceptedSubclassFactory<T>
-
- All Implemented Interfaces:
PrivilegedAction<T>
public class InterceptedSubclassFactory<T> extends ProxyFactory<T>
Factory for producing subclasses that are used by the combined interceptors and decorators stack.- Author:
- Marius Bogoevici
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
PRIVATE_METHOD_HANDLER_FIELD_NAME
static String
PROXY_SUFFIX
-
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, WELD_PROXY_PREFIX
-
-
Constructor Summary
Constructors Constructor Description InterceptedSubclassFactory(String contextId, Class<?> proxiedBeanType, Set<? extends Type> typeClosure, jakarta.enterprise.inject.spi.Bean<?> bean, Set<MethodSignature> enhancedMethodSignatures, Set<MethodSignature> interceptedMethodSignatures)
InterceptedSubclassFactory(String contextId, Class<?> proxiedBeanType, Set<? extends Type> typeClosure, String proxyName, jakarta.enterprise.inject.spi.Bean<?> bean, Set<MethodSignature> enhancedMethodSignatures, Set<MethodSignature> interceptedMethodSignatures)
Creates a new proxy factory when the name of the proxy class is already known, such as during de-serialization
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInterfacesFromTypeClosure(Set<? extends Type> typeClosure, Class<?> proxiedBeanType)
protected void
addMethods(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor)
protected void
addMethodsFromClass(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor)
protected void
addSpecialMethods(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor)
Adds methods requiring special implementations rather than just delegation.protected void
createForwardingMethodBody(org.jboss.classfilewriter.ClassMethod classMethod, MethodInformation method, org.jboss.classfilewriter.ClassMethod staticConstructor)
protected void
createInterceptorBody(org.jboss.classfilewriter.ClassMethod method, MethodInformation methodInfo, boolean delegateToSuper, org.jboss.classfilewriter.ClassMethod staticConstructor)
Creates the given method on the proxy class where the implementation forwards the call directly to the method handler.Class<?>
getBeanType()
protected Class<? extends MethodHandler>
getMethodHandlerType()
protected String
getProxyNameSuffix()
Returns a suffix to append to the name of the proxy class.protected void
invokeMethodHandler(org.jboss.classfilewriter.ClassMethod method, MethodInformation methodInfo, boolean addReturnInstruction, BytecodeMethodResolver bytecodeMethodResolver, boolean addProceed, org.jboss.classfilewriter.ClassMethod staticConstructor)
calls methodHandler.invoke for a given methodprotected boolean
isUsingProxyInstantiator()
static <T> void
setPrivateMethodHandler(T instance)
If the given instance represents a proxy and its class is synthetic and its class name ends with "Subclass", attempt to find the "privateMethodHandler" field and set its value toPrivateMethodHandler.INSTANCE
.-
Methods inherited from class org.jboss.weld.bean.proxy.ProxyFactory
addAdditionalInterfaces, addConstructedGuardToMethodBody, addConstructedGuardToMethodBody, addConstructors, addFields, addInterface, addSerializationSupport, create, createInterceptorBody, createSpecialMethodBody, generateEqualsMethod, generateGetMethodHandlerBody, generateHashCodeMethod, generateSetMethodHandlerBody, getAdditionalInterfaces, getBaseProxyName, getBean, getContextId, getMethodHandlerField, getProxiedBeanType, getProxyClass, getProxySuperclass, invokeMethodHandler, isMethodAccepted, run, setBeanInstance, toClass
-
-
-
-
Field Detail
-
PROXY_SUFFIX
public static final String PROXY_SUFFIX
- See Also:
- Constant Field Values
-
PRIVATE_METHOD_HANDLER_FIELD_NAME
protected static final String PRIVATE_METHOD_HANDLER_FIELD_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InterceptedSubclassFactory
public InterceptedSubclassFactory(String contextId, Class<?> proxiedBeanType, Set<? extends Type> typeClosure, jakarta.enterprise.inject.spi.Bean<?> bean, Set<MethodSignature> enhancedMethodSignatures, Set<MethodSignature> interceptedMethodSignatures)
-
InterceptedSubclassFactory
public InterceptedSubclassFactory(String contextId, Class<?> proxiedBeanType, Set<? extends Type> typeClosure, String proxyName, jakarta.enterprise.inject.spi.Bean<?> bean, Set<MethodSignature> enhancedMethodSignatures, Set<MethodSignature> interceptedMethodSignatures)
Creates a new proxy factory when the name of the proxy class is already known, such as during de-serialization- Parameters:
proxiedBeanType
- the super-class for this proxy classtypeClosure
- the bean types of the beanenhancedMethodSignatures
- a restricted set of methods that need to be intercepted
-
-
Method Detail
-
addInterfacesFromTypeClosure
public void addInterfacesFromTypeClosure(Set<? extends Type> typeClosure, Class<?> proxiedBeanType)
- Overrides:
addInterfacesFromTypeClosure
in classProxyFactory<T>
-
getProxyNameSuffix
protected String getProxyNameSuffix()
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
-
addMethods
protected void addMethods(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor)
- Overrides:
addMethods
in classProxyFactory<T>
-
addMethodsFromClass
protected void addMethodsFromClass(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor)
- Overrides:
addMethodsFromClass
in classProxyFactory<T>
-
createForwardingMethodBody
protected void createForwardingMethodBody(org.jboss.classfilewriter.ClassMethod classMethod, MethodInformation method, org.jboss.classfilewriter.ClassMethod staticConstructor)
- Overrides:
createForwardingMethodBody
in classProxyFactory<T>
-
createInterceptorBody
protected void createInterceptorBody(org.jboss.classfilewriter.ClassMethod method, MethodInformation methodInfo, boolean delegateToSuper, org.jboss.classfilewriter.ClassMethod staticConstructor)
Creates the given method on the proxy class where the implementation forwards the call directly to the method handler. the generated bytecode is equivalent to: return (RetType) methodHandler.invoke(this,param1,param2);- Parameters:
methodInfo
- any JLR methoddelegateToSuper
-
-
invokeMethodHandler
protected void invokeMethodHandler(org.jboss.classfilewriter.ClassMethod method, MethodInformation methodInfo, boolean addReturnInstruction, BytecodeMethodResolver bytecodeMethodResolver, boolean addProceed, org.jboss.classfilewriter.ClassMethod staticConstructor)
calls methodHandler.invoke for a given method- Parameters:
methodInfo
- declaring class of the methodaddReturnInstruction
- set to true you want to return the result ofbytecodeMethodResolver
- The method resolveraddProceed
-
-
addSpecialMethods
protected void addSpecialMethods(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor)
Adds methods requiring special implementations rather than just delegation.- Overrides:
addSpecialMethods
in classProxyFactory<T>
- Parameters:
proxyClassType
- the Javassist class description for the proxy type
-
getBeanType
public Class<?> getBeanType()
- Overrides:
getBeanType
in classProxyFactory<T>
-
getMethodHandlerType
protected Class<? extends MethodHandler> getMethodHandlerType()
- Overrides:
getMethodHandlerType
in classProxyFactory<T>
-
isUsingProxyInstantiator
protected boolean isUsingProxyInstantiator()
- Overrides:
isUsingProxyInstantiator
in classProxyFactory<T>
- Returns:
true
ifProxyInstantiator
is used to instantiate proxy instances
-
setPrivateMethodHandler
public static <T> void setPrivateMethodHandler(T instance)
If the given instance represents a proxy and its class is synthetic and its class name ends with "Subclass", attempt to find the "privateMethodHandler" field and set its value toPrivateMethodHandler.INSTANCE
.- Parameters:
instance
-
-
-