Interface PlasticProxyFactory
-
- All Superinterfaces:
PlasticClassListenerHub
- All Known Implementing Classes:
PlasticProxyFactoryImpl
public interface PlasticProxyFactory extends PlasticClassListenerHub
A service used to create proxies of varying types. As a secondary concern, manages to identify the location of methods and constructors, which is important for exception reporting.- Since:
- 5.3
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclearCache()Clears any cached information stored by the proxy factory; this is useful in Tapestry development mode when a class loader may have been discarded (because the proxy factory may indirectly keep references to classes loaded by the old class loader).<T> TcreateProxy(java.lang.Class<T> interfaceType, java.lang.Class<? extends T> implementationType, ObjectCreator<T> creator, java.lang.String description)Creates a proxy instance that delegates all methods through a corresponding ObjectCreator.<T> ClassInstantiator<T>createProxy(java.lang.Class<T> interfaceType, java.lang.Class<? extends T> implementationType, PlasticClassTransformer callback)Same ascreateProxy(interfacetype, implementationType, callback, true)<T> ClassInstantiator<T>createProxy(java.lang.Class<T> interfaceType, java.lang.Class<? extends T> implementationType, PlasticClassTransformer callback, boolean introduceInterface)Creates a proxy object that implements the indicated interface and indicated service implementation type, then invokes the callback to further configure the proxy.<T> TcreateProxy(java.lang.Class<T> interfaceType, ObjectCreator<T> creator, java.lang.String description)Creates a proxy instance that delegates all methods through a corresponding ObjectCreator.<T> ClassInstantiator<T>createProxy(java.lang.Class<T> interfaceType, PlasticClassTransformer callback)Creates a proxy object that implements the indicated interface, then invokes the callback to further configure the proxy.<T> PlasticClassTransformation<T>createProxyTransformation(java.lang.Class<T> interfaceType)Creates the underlyingPlasticClassTransformationfor an interface proxy.<T> PlasticClassTransformation<T>createProxyTransformation(java.lang.Class<T> interfaceType, java.lang.Class<? extends T> implementationType)Creates the underlyingPlasticClassTransformationfor an interface proxy with a given implementation class.java.lang.ClassLoadergetClassLoader()Returns the class loader used when creating new classes, this is a child class loader of another class loader (usually, the thread's context class loader).LocationgetConstructorLocation(java.lang.reflect.Constructor constructor)Return a string representation for the constructor (including class and parameters) and (if available) file name and line number.LocationgetMethodLocation(java.lang.reflect.Method method)Converts a method to aLocation, which includes information about the source file name and line number.PlasticManagergetPlasticManager()Returns the PlasticManager instance used by this PlasticProxyFactory.default PlasticProxyFactorygetProxyFactory(java.lang.String className)Returns the PlasticProxyFactory instance to be used for a given class.-
Methods inherited from interface org.apache.tapestry5.plastic.PlasticClassListenerHub
addPlasticClassListener, removePlasticClassListener
-
-
-
-
Method Detail
-
getClassLoader
java.lang.ClassLoader getClassLoader()
Returns the class loader used when creating new classes, this is a child class loader of another class loader (usually, the thread's context class loader).
-
createProxy
<T> ClassInstantiator<T> createProxy(java.lang.Class<T> interfaceType, PlasticClassTransformer callback)
Creates a proxy object that implements the indicated interface, then invokes the callback to further configure the proxy.- Parameters:
interfaceType- interface implemented by proxycallback- configures the proxy- Returns:
- instantiator that can be used to create an instance of the proxy class
-
createProxy
@IncompatibleChange(release="5.4.5", details="TAP5-2528") <T> ClassInstantiator<T> createProxy(java.lang.Class<T> interfaceType, java.lang.Class<? extends T> implementationType, PlasticClassTransformer callback, boolean introduceInterface)
Creates a proxy object that implements the indicated interface and indicated service implementation type, then invokes the callback to further configure the proxy.- Parameters:
interfaceType- interface implemented by proxyimplementationType- a class that implements the interfaceType. It can be null.callback- configures the proxy- Returns:
- instantiator that can be used to create an instance of the proxy class
-
createProxy
@IncompatibleChange(release="5.4", details="TAP5-2029") <T> ClassInstantiator<T> createProxy(java.lang.Class<T> interfaceType, java.lang.Class<? extends T> implementationType, PlasticClassTransformer callback)
Same ascreateProxy(interfacetype, implementationType, callback, true)- Parameters:
interfaceType- interface implemented by proxyimplementationType- a class that implements the interfaceType. It can be null.callback- configures the proxy- Returns:
- instantiator that can be used to create an instance of the proxy class
-
createProxyTransformation
<T> PlasticClassTransformation<T> createProxyTransformation(java.lang.Class<T> interfaceType)
Creates the underlyingPlasticClassTransformationfor an interface proxy. This should only be used in the cases where encapsulating the PlasticClass construction into a callback is not feasible (which is the case for some of the older APIs inside Tapestry IoC).- Parameters:
interfaceType- class proxy will extend from- Returns:
- transformation from which an instantiator may be created
-
createProxyTransformation
@IncompatibleChange(release="5.4", details="TAP5-2029") <T> PlasticClassTransformation<T> createProxyTransformation(java.lang.Class<T> interfaceType, java.lang.Class<? extends T> implementationType)
Creates the underlyingPlasticClassTransformationfor an interface proxy with a given implementation class. This should only be used in the cases where encapsulating the PlasticClass construction into a callback is not feasible (which is the case for some of the older APIs inside Tapestry IoC).- Parameters:
interfaceType- class proxy will extend fromimplementationType- a class that implements the interfaceType. It can be null.- Returns:
- transformation from which an instantiator may be created
-
createProxy
<T> T createProxy(java.lang.Class<T> interfaceType, ObjectCreator<T> creator, java.lang.String description)
Creates a proxy instance that delegates all methods through a corresponding ObjectCreator. Each method invocation on the proxy will route throughObjectCreator.createObject()(the creator implementation may decide to cache the return value as appropriate).- Type Parameters:
T- type of proxy- Parameters:
interfaceType- interface class for proxycreator- object responsible for creating the real objectdescription- thetoString()of the proxy- Returns:
- proxy instance
-
createProxy
@IncompatibleChange(release="5.4", details="Added for TAP5-2029") <T> T createProxy(java.lang.Class<T> interfaceType, java.lang.Class<? extends T> implementationType, ObjectCreator<T> creator, java.lang.String description)
Creates a proxy instance that delegates all methods through a corresponding ObjectCreator. Each method invocation on the proxy will route throughObjectCreator.createObject()(the creator implementation may decide to cache the return value as appropriate).- Type Parameters:
T- type of proxy- Parameters:
interfaceType- interface class for proxyimplementationType- class that implements the interface type. It may be nullcreator- object responsible for creating the real objectdescription- thetoString()of the proxy- Returns:
- proxy instance
-
getMethodLocation
Location getMethodLocation(java.lang.reflect.Method method)
Converts a method to aLocation, which includes information about the source file name and line number.- Parameters:
method- to look up- Returns:
- the location (identifying the method and possibly, the line number within the method)
-
getConstructorLocation
Location getConstructorLocation(java.lang.reflect.Constructor constructor)
Return a string representation for the constructor (including class and parameters) and (if available) file name and line number.- Returns:
- the location (identifying the constructor and possibly, the line number within the method)
-
clearCache
@IncompatibleChange(release="5.3.3", details="Added method") void clearCache()
Clears any cached information stored by the proxy factory; this is useful in Tapestry development mode when a class loader may have been discarded (because the proxy factory may indirectly keep references to classes loaded by the old class loader).- Since:
- 5.3.3
-
getPlasticManager
@IncompatibleChange(release="5.8.3", details="Added method") PlasticManager getPlasticManager()
Returns the PlasticManager instance used by this PlasticProxyFactory.- Since:
- 5.8.3
-
getProxyFactory
default PlasticProxyFactory getProxyFactory(java.lang.String className)
Returns the PlasticProxyFactory instance to be used for a given class. Default implementation returnsthis.- Since:
- 5.8.3
-
-