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 StringPRIVATE_METHOD_HANDLER_FIELD_NAMEstatic StringPROXY_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, String proxyName, 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-serializationInterceptedSubclassFactory(String contextId, Class<?> proxiedBeanType, Set<? extends Type> typeClosure, Bean<?> bean, Set<MethodSignature> enhancedMethodSignatures, Set<MethodSignature> interceptedMethodSignatures)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInterfacesFromTypeClosure(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<?>getBeanType()protected Class<? extends MethodHandler>getMethodHandlerType()protected StringgetProxyNameSuffix()Returns 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 booleanisUsingProxyInstantiator()static <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, 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, Bean<?> bean, Set<MethodSignature> enhancedMethodSignatures, Set<MethodSignature> interceptedMethodSignatures)
-
InterceptedSubclassFactory
public InterceptedSubclassFactory(String contextId, Class<?> proxiedBeanType, Set<? extends Type> typeClosure, String proxyName, 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:
addInterfacesFromTypeClosurein 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:
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
public Class<?> getBeanType()
- Overrides:
getBeanTypein classProxyFactory<T>
-
getMethodHandlerType
protected Class<? extends MethodHandler> 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-
-
-