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>
Factory for producing subclasses that are used by the combined interceptors and decorators stack.
- Author:
- Marius Bogoevici
-
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionInterceptedSubclassFactory(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
Modifier and TypeMethodDescriptionvoidaddInterfacesFromTypeClosure(Set<? extends Type> typeClosure, Class<?> proxiedBeanType) protected voidaddMethods(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor) protected voidaddMethodsFromClass(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor) protected voidaddSpecialMethods(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor) Adds methods requiring special implementations rather than just delegation.protected voidcreateForwardingMethodBody(org.jboss.classfilewriter.ClassMethod classMethod, MethodInformation method, org.jboss.classfilewriter.ClassMethod staticConstructor) protected voidcreateInterceptorBody(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<?>protected Class<? extends MethodHandler>protected StringReturns a suffix to append to the name of the proxy class.protected voidinvokeMethodHandler(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 booleanstatic <T> voidsetPrivateMethodHandler(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, instantiateProxy, invokeMethodHandler, isMethodAccepted, setBeanInstance, toClass
-
Field Details
-
PROXY_SUFFIX
- See Also:
-
PRIVATE_METHOD_HANDLER_FIELD_NAME
- See Also:
-
-
Constructor Details
-
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 Details
-
addInterfacesFromTypeClosure
- Overrides:
addInterfacesFromTypeClosurein classProxyFactory<T>
-
getProxyNameSuffix
Returns a suffix to append to the name of the proxy class. The name already consists of <class-name>_$$_Weld, to which the suffix is added. This allows the creation of different types of proxies for the same class.- Overrides:
getProxyNameSuffixin classProxyFactory<T>- Returns:
- a name suffix
-
addMethods
protected void addMethods(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor) - Overrides:
addMethodsin classProxyFactory<T>
-
addMethodsFromClass
protected void addMethodsFromClass(org.jboss.classfilewriter.ClassFile proxyClassType, org.jboss.classfilewriter.ClassMethod staticConstructor) - Overrides:
addMethodsFromClassin classProxyFactory<T>
-
createForwardingMethodBody
protected void createForwardingMethodBody(org.jboss.classfilewriter.ClassMethod classMethod, MethodInformation method, org.jboss.classfilewriter.ClassMethod staticConstructor) - Overrides:
createForwardingMethodBodyin 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:
addSpecialMethodsin classProxyFactory<T>- Parameters:
proxyClassType- the Javassist class description for the proxy type
-
getBeanType
- Overrides:
getBeanTypein classProxyFactory<T>
-
getMethodHandlerType
- Overrides:
getMethodHandlerTypein classProxyFactory<T>
-
isUsingProxyInstantiator
protected boolean isUsingProxyInstantiator()- Overrides:
isUsingProxyInstantiatorin classProxyFactory<T>- Returns:
trueifProxyInstantiatoris 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-
-