Class 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
    • 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 class
        typeClosure - the bean types of the bean
        enhancedMethodSignatures - a restricted set of methods that need to be intercepted
    • Method Detail

      • 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 class ProxyFactory<T>
        Returns:
        a name suffix
      • addMethods

        protected void addMethods​(org.jboss.classfilewriter.ClassFile proxyClassType,
                                  org.jboss.classfilewriter.ClassMethod staticConstructor)
        Overrides:
        addMethods in class ProxyFactory<T>
      • addMethodsFromClass

        protected void addMethodsFromClass​(org.jboss.classfilewriter.ClassFile proxyClassType,
                                           org.jboss.classfilewriter.ClassMethod staticConstructor)
        Overrides:
        addMethodsFromClass in class ProxyFactory<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 method
        delegateToSuper -
      • 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 method
        addReturnInstruction - set to true you want to return the result of
        bytecodeMethodResolver - The method resolver
        addProceed -
      • 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 class ProxyFactory<T>
        Parameters:
        proxyClassType - the Javassist class description for the proxy type
      • 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 to PrivateMethodHandler.INSTANCE.
        Parameters:
        instance -