Class InterceptedSubclassFactory<T>

java.lang.Object
org.jboss.weld.bean.proxy.ProxyFactory<T>
org.jboss.weld.bean.proxy.InterceptedSubclassFactory<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 Details

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

    • addInterfacesFromTypeClosure

      public void addInterfacesFromTypeClosure(Set<? extends Type> typeClosure, Class<?> proxiedBeanType)
      Overrides:
      addInterfacesFromTypeClosure in class ProxyFactory<T>
    • getProxyNameSuffix

      protected String 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:
      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>
    • createForwardingMethodBody

      protected void createForwardingMethodBody(org.jboss.classfilewriter.ClassMethod classMethod, MethodInformation method, org.jboss.classfilewriter.ClassMethod staticConstructor)
      Overrides:
      createForwardingMethodBody 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
    • getBeanType

      public Class<?> getBeanType()
      Overrides:
      getBeanType in class ProxyFactory<T>
    • getMethodHandlerType

      protected Class<? extends MethodHandler> getMethodHandlerType()
      Overrides:
      getMethodHandlerType in class ProxyFactory<T>
    • isUsingProxyInstantiator

      protected boolean isUsingProxyInstantiator()
      Overrides:
      isUsingProxyInstantiator in class ProxyFactory<T>
      Returns:
      true if ProxyInstantiator 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 to PrivateMethodHandler.INSTANCE.
      Parameters:
      instance -