Package org.apache.webbeans.proxy
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 aProvider.
-
-
Field Summary
Fields Modifier and Type Field Description static StringFIELD_INSTANCE_PROVIDERthe name of the field which stores theProviderfor the Contextual Instancestatic StringFIELD_PROTECTED_METHODSthe Method[] for all protected methods.-
Fields inherited from class org.apache.webbeans.proxy.AbstractProxyFactory
FIELD_BEAN_PASSIVATION_ID, MAX_CLASSLOAD_TRIES, MODIFIER_VARARGS, unsafe, webBeansContext
-
-
Constructor Summary
Constructors Constructor Description NormalScopeProxyFactory(WebBeansContext webBeansContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcreateConstructor(org.apache.xbean.asm9.ClassWriter cw, String proxyClassFileName, Class<?> classToProxy, String classFileName, Constructor<?> ignored)Each of our interceptor/decorator proxies has exactly 1 constructor which invokes the super ct + sets the delegation field.protected voidcreateInstanceVariables(org.apache.xbean.asm9.ClassWriter cw, Class<?> classToProxy, String classFileName)generate the bytecode for creating the instance variables of the class<T> TcreateNormalScopeProxy(javax.enterprise.inject.spi.Bean<T> bean)<T> Class<T>createProxyClass(ClassLoader classLoader, Class<T> classToProxy)<T> Class<T>createProxyClass(javax.enterprise.inject.spi.Bean<T> bean, ClassLoader classLoader, Class<T> classToProxy)<T> TcreateProxyInstance(Class<T> proxyClass, javax.inject.Provider provider)protected voidcreateSerialisation(org.apache.xbean.asm9.ClassWriter cw, String proxyClassFileName, Class<?> classToProxy, String classFileName)generate the bytecode for serialization.protected voiddelegateInterceptedMethods(ClassLoader classLoader, org.apache.xbean.asm9.ClassWriter cw, String proxyClassFileName, Class<?> classToProxy, Method[] interceptedMethods)In the NormalScope proxying case this is used for all the protected methods as they need to get invoked via reflection.protected voiddelegateNonInterceptedMethods(ClassLoader classLoader, org.apache.xbean.asm9.ClassWriter cw, String proxyClassFileName, Class<?> classToProxy, Method[] noninterceptedMethods)generate the bytecode for invoking all non-intercepted methodsstatic ObjectdelegateProtectedMethod(Method method, Object instance, Object[] params)This method get invoked via generated ASM code.javax.inject.ProvidergetInstanceProvider(ClassLoader classLoader, javax.enterprise.inject.spi.Bean<?> bean)javax.inject.ProvidergetInstanceProvider(OwbNormalScopeProxy proxyInstance)protected ClassgetMarkerInterface()static <T> TunwrapInstance(T proxyInstance)-
Methods inherited from class org.apache.webbeans.proxy.AbstractProxyFactory
createArrayDefinition, createProxyClass, createProxyClass, fixPreservedPackages, generateReturn, getCastType, getPrimitiveMethod, getProxyClassLoader, getReturnInsn, getSignedClassProxyName, getUnusedProxyClassName, getUnusedProxyClassName, getVarInsn, getWrapperType, newInstance, pushIntOntoStack, pushMethodParameterArray, uniqueHash, unproxyableMethod
-
-
-
-
Field Detail
-
FIELD_INSTANCE_PROVIDER
public static final String FIELD_INSTANCE_PROVIDER
the name of the field which stores theProviderfor the Contextual Instance- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
-
Constructor Detail
-
NormalScopeProxyFactory
public NormalScopeProxyFactory(WebBeansContext webBeansContext)
-
-
Method Detail
-
getMarkerInterface
protected Class getMarkerInterface()
- Specified by:
getMarkerInterfacein classAbstractProxyFactory- Returns:
- the marker interface which should be used for this proxy.
-
unwrapInstance
public static <T> T unwrapInstance(T proxyInstance)
-
getInstanceProvider
public javax.inject.Provider getInstanceProvider(OwbNormalScopeProxy proxyInstance)
- Returns:
- the internal instance which gets proxied.
-
createNormalScopeProxy
public <T> T createNormalScopeProxy(javax.enterprise.inject.spi.Bean<T> bean)
-
getInstanceProvider
public javax.inject.Provider getInstanceProvider(ClassLoader classLoader, javax.enterprise.inject.spi.Bean<?> bean)
-
createProxyClass
public <T> Class<T> createProxyClass(javax.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:AbstractProxyFactorygenerate the bytecode for serialization.- Specified by:
createSerialisationin classAbstractProxyFactory
-
createProxyClass
public <T> Class<T> createProxyClass(ClassLoader classLoader, Class<T> classToProxy) throws ProxyGenerationException
- Type Parameters:
T-- Parameters:
classLoader- to use for creating the class inclassToProxy- the class for which a subclass will get generated- Returns:
- the proxy class
- Throws:
ProxyGenerationException
-
createProxyInstance
public <T> T createProxyInstance(Class<T> proxyClass, javax.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 ProxyGenerationExceptionDescription copied from class:AbstractProxyFactoryEach of our interceptor/decorator proxies has exactly 1 constructor which invokes the super ct + sets the delegation field.- Specified by:
createConstructorin classAbstractProxyFactory- Throws:
ProxyGenerationException
-
createInstanceVariables
protected void createInstanceVariables(org.apache.xbean.asm9.ClassWriter cw, Class<?> classToProxy, String classFileName)Description copied from class:AbstractProxyFactorygenerate the bytecode for creating the instance variables of the class- Specified by:
createInstanceVariablesin classAbstractProxyFactory
-
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:
delegateInterceptedMethodsin classAbstractProxyFactory- 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:AbstractProxyFactorygenerate the bytecode for invoking all non-intercepted methods- Specified by:
delegateNonInterceptedMethodsin classAbstractProxyFactory- 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.
-
-