org.jboss.weld.bean.proxy
Class InterceptedSubclassFactory<T>

java.lang.Object
  extended by org.jboss.weld.bean.proxy.ProxyFactory<T>
      extended by 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 Summary
static String PROXY_SUFFIX
           
 
Fields inherited from class org.jboss.weld.bean.proxy.ProxyFactory
CONSTRUCTED_FLAG_NAME, DEFAULT_METHOD_RESOLVER, DEFAULT_PROXY_PACKAGE, log
 
Constructor Summary
InterceptedSubclassFactory(Class<?> proxiedBeanType, Set<? extends Type> typeClosure, javax.enterprise.inject.spi.Bean<?> bean, Set<MethodSignature> enhancedMethodSignatures)
           
InterceptedSubclassFactory(Class<?> proxiedBeanType, Set<? extends Type> typeClosure, String proxyName, javax.enterprise.inject.spi.Bean<?> bean, Set<MethodSignature> enhancedMethodSignatures)
          Creates a new proxy factory when the name of the proxy class is already known, such as during de-serialization
 
Method Summary
protected  void addMethods(javassist.bytecode.ClassFile proxyClassType)
           
protected  void addMethodsFromClass(javassist.bytecode.ClassFile proxyClassType)
           
protected  void addSpecialMethods(javassist.bytecode.ClassFile proxyClassType)
          Adds methods requiring special implementations rather than just delegation.
protected  javassist.bytecode.Bytecode createForwardingMethodBody(javassist.bytecode.ClassFile proxyClassType, MethodInformation method)
           
protected  javassist.bytecode.Bytecode createInterceptorBody(javassist.bytecode.ClassFile file, MethodInformation methodInfo, boolean delegateToSuper)
          Creates the given method on the proxy class where the implementation forwards the call directly to the method handler.
protected  String getProxyNameSuffix()
          Returns a suffix to append to the name of the proxy class.
protected static void invokeMethodHandler(javassist.bytecode.ClassFile file, javassist.bytecode.Bytecode b, MethodInformation methodInfo, boolean addReturnInstruction, BytecodeMethodResolver bytecodeMethodResolver, boolean addProceed)
          calls methodHandler.invoke for a given method
 
Methods inherited from class org.jboss.weld.bean.proxy.ProxyFactory
addAdditionalInterfaces, addConstructedGuardToMethodBody, addConstructors, addFields, addInterface, addSerializationSupport, create, createInterceptorBody, createSpecialMethodBody, generateEqualsMethod, generateHashCodeMethod, getAdditionalInterfaces, getBaseProxyName, getBean, getBeanType, getProxyClass, invokeMethodHandler, isProxy, resolveClassLoaderForBeanProxy, resolveClassLoaderForBeanProxy, setBeanInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROXY_SUFFIX

public static final String PROXY_SUFFIX
See Also:
Constant Field Values
Constructor Detail

InterceptedSubclassFactory

public InterceptedSubclassFactory(Class<?> proxiedBeanType,
                                  Set<? extends Type> typeClosure,
                                  javax.enterprise.inject.spi.Bean<?> bean,
                                  Set<MethodSignature> enhancedMethodSignatures)

InterceptedSubclassFactory

public InterceptedSubclassFactory(Class<?> proxiedBeanType,
                                  Set<? extends Type> typeClosure,
                                  String proxyName,
                                  javax.enterprise.inject.spi.Bean<?> bean,
                                  Set<MethodSignature> enhancedMethodSignatures)
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(javassist.bytecode.ClassFile proxyClassType)
Overrides:
addMethods in class ProxyFactory<T>

addMethodsFromClass

protected void addMethodsFromClass(javassist.bytecode.ClassFile proxyClassType)
Overrides:
addMethodsFromClass in class ProxyFactory<T>

createForwardingMethodBody

protected javassist.bytecode.Bytecode createForwardingMethodBody(javassist.bytecode.ClassFile proxyClassType,
                                                                 MethodInformation method)
                                                          throws javassist.NotFoundException
Overrides:
createForwardingMethodBody in class ProxyFactory<T>
Throws:
javassist.NotFoundException

createInterceptorBody

protected javassist.bytecode.Bytecode createInterceptorBody(javassist.bytecode.ClassFile file,
                                                            MethodInformation methodInfo,
                                                            boolean delegateToSuper)
                                                     throws javassist.NotFoundException
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:
file - the class file
methodInfo - any JLR method
delegateToSuper -
Returns:
the method byte code
Throws:
javassist.NotFoundException

invokeMethodHandler

protected static void invokeMethodHandler(javassist.bytecode.ClassFile file,
                                          javassist.bytecode.Bytecode b,
                                          MethodInformation methodInfo,
                                          boolean addReturnInstruction,
                                          BytecodeMethodResolver bytecodeMethodResolver,
                                          boolean addProceed)
calls methodHandler.invoke for a given method

Parameters:
file - the current class file
b - the bytecode to add the methodHandler.invoke call to
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(javassist.bytecode.ClassFile proxyClassType)
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


Copyright © 2013 Seam Framework. All Rights Reserved.