Class NormalScopeProxyFactory

java.lang.Object
org.apache.webbeans.proxy.AbstractProxyFactory
org.apache.webbeans.proxy.NormalScopeProxyFactory

public class NormalScopeProxyFactory extends AbstractProxyFactory
This factory creates proxies which delegate the method invocations 1:1 to an instance which gets resolved via a Provider.
  • Field Details

    • FIELD_INSTANCE_PROVIDER

      public static final String FIELD_INSTANCE_PROVIDER
      the name of the field which stores the Provider for the Contextual Instance
      See Also:
    • FIELD_PROTECTED_METHODS

      public static final String FIELD_PROTECTED_METHODS
      the Method[] for all protected methods. We need to invoke them via reflection.
      See Also:
  • Constructor Details

    • NormalScopeProxyFactory

      public NormalScopeProxyFactory(WebBeansContext webBeansContext)
  • Method Details

    • getMarkerInterface

      protected Class getMarkerInterface()
      Specified by:
      getMarkerInterface in class AbstractProxyFactory
      Returns:
      the marker interface which should be used for this proxy.
    • unwrapInstance

      public static <T> T unwrapInstance(T proxyInstance)
    • getInstanceProvider

      public jakarta.inject.Provider getInstanceProvider(OwbNormalScopeProxy proxyInstance)
      Returns:
      the internal instance which gets proxied.
    • createNormalScopeProxy

      public <T> T createNormalScopeProxy(jakarta.enterprise.inject.spi.Bean<T> bean)
    • getInstanceProvider

      public jakarta.inject.Provider getInstanceProvider(ClassLoader classLoader, jakarta.enterprise.inject.spi.Bean<?> bean)
    • createProxyClass

      public <T> Class<T> createProxyClass(jakarta.enterprise.inject.spi.Bean<T> bean, ClassLoader classLoader, Class<T> classToProxy)
    • createSerialisation

      protected void createSerialisation(org.apache.xbean.asm9.ClassWriter cw, String proxyClassFileName, Class<?> classToProxy, String classFileName)
      Description copied from class: AbstractProxyFactory
      generate the bytecode for serialization.
      Specified by:
      createSerialisation in class AbstractProxyFactory
    • createProxyClass

      public <T> Class<T> createProxyClass(ClassLoader classLoader, Class<T> classToProxy) throws ProxyGenerationException
      Type Parameters:
      T -
      Parameters:
      classLoader - to use for creating the class in
      classToProxy - the class for which a subclass will get generated
      Returns:
      the proxy class
      Throws:
      ProxyGenerationException
    • createProxyInstance

      public <T> T createProxyInstance(Class<T> proxyClass, jakarta.inject.Provider provider) throws ProxyGenerationException
      Throws:
      ProxyGenerationException
    • createConstructor

      protected void createConstructor(org.apache.xbean.asm9.ClassWriter cw, String proxyClassFileName, Class<?> classToProxy, String classFileName, Constructor<?> ignored) throws ProxyGenerationException
      Description copied from class: AbstractProxyFactory
      Each of our interceptor/decorator proxies has exactly 1 constructor which invokes the super ct + sets the delegation field.
      Specified by:
      createConstructor in class AbstractProxyFactory
      Throws:
      ProxyGenerationException
    • createInstanceVariables

      protected void createInstanceVariables(org.apache.xbean.asm9.ClassWriter cw, Class<?> classToProxy, String classFileName)
      Description copied from class: AbstractProxyFactory
      generate the bytecode for creating the instance variables of the class
      Specified by:
      createInstanceVariables in class AbstractProxyFactory
    • delegateInterceptedMethods

      protected void delegateInterceptedMethods(ClassLoader classLoader, org.apache.xbean.asm9.ClassWriter cw, String proxyClassFileName, Class<?> classToProxy, Method[] interceptedMethods) throws ProxyGenerationException
      In the NormalScope proxying case this is used for all the protected methods as they need to get invoked via reflection.
      Specified by:
      delegateInterceptedMethods in class AbstractProxyFactory
      Throws:
      ProxyGenerationException
    • delegateNonInterceptedMethods

      protected void delegateNonInterceptedMethods(ClassLoader classLoader, org.apache.xbean.asm9.ClassWriter cw, String proxyClassFileName, Class<?> classToProxy, Method[] noninterceptedMethods) throws ProxyGenerationException
      Description copied from class: AbstractProxyFactory
      generate the bytecode for invoking all non-intercepted methods
      Specified by:
      delegateNonInterceptedMethods in class AbstractProxyFactory
      Throws:
      ProxyGenerationException
    • delegateProtectedMethod

      public static Object delegateProtectedMethod(Method method, Object instance, Object[] params)
      This method get invoked via generated ASM code. It delegates to the underlying protected Method so we don't need to do all the reflection stuff in our generated bytecode. This is needed as we cannot invoke instanceProvider.get().targetMethod() directly if targetMethod is protected. Please see Java LangSpec 6.6.2 about the complex rules for calling 'protected' methods.
      See Also:
      • generateDelegationMethod(org.apache.xbean.asm9.ClassWriter, java.lang.reflect.Method, int, Class, String)