Class ChainingUberspector
- java.lang.Object
-
- org.apache.velocity.util.introspection.UberspectImpl
-
- org.apache.velocity.util.introspection.AbstractChainableUberspector
-
- org.xwiki.velocity.introspection.AbstractChainableUberspector
-
- org.xwiki.velocity.introspection.ChainingUberspector
-
- All Implemented Interfaces:
org.apache.velocity.util.introspection.ChainableUberspector
,org.apache.velocity.util.introspection.Uberspect
,org.apache.velocity.util.RuntimeServicesAware
,ChainableUberspector
@Deprecated public class ChainingUberspector extends AbstractChainableUberspector implements org.apache.velocity.util.introspection.Uberspect, org.apache.velocity.util.RuntimeServicesAware
Deprecated.since 8.0M1; Velocity supports the same functionality natively since 1.6; just move the configuration fromruntime.introspector.uberspect.chainClasses
toruntime.introspector.uberspect
Since the current version of the Velocity engine (1.5) does not allow more than one uberspector, this class is a workaround. It manually constructs a chain of uberspectors, loading the classes in the order defined in the
"runtime.introspector.uberspect.chainClasses"
property, and after that simply forwarding all calls to the top of the chain. Note that the calls will be made from the rightmost class to the leftmost one. Along the chain, each uberspectors can forward the call to the rest of the chain, build its own result, and/or process in any way the resulting value. This allows uberspectors to enhance the list of returned methods, block out methods returned by other uberspectors, or take various actions on the returned method (for example add or remove parameters before searching the method, log executed method names, or catch exceptions when executing those methods).This is not actually part of the chain, but is more of a handle that allows the calls intended for only one uberspector to reach the chain. It duplicates some of the code from the velocity runtime initialization code, hoping that a future version of the engine will support chaining natively.
The chain is defined using the configuration parameter
runtime.introspector.uberspect.chainClasses
. This property should contain a list of canonical class names. Any wrong entry in the list will be ignored. If this property is not defined or contains only wrong classnames, then by default aSecureUberspector
is used as the only entry in the chain. The first (leftmost) uberspector does not have to be chainable (as it will not need to forward calls). If a uberspector in the middle of the chain is not chainable, then it will break the chain at that point (all previos uberspectors will be discarded from the chain).- Since:
- 1.5M1
- Version:
- $Id: f6c6d9a3669094cd5af96342267dcc9fef488960 $
- See Also:
ChainableUberspector
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.velocity.util.introspection.UberspectImpl
org.apache.velocity.util.introspection.UberspectImpl.VelGetterImpl, org.apache.velocity.util.introspection.UberspectImpl.VelMethodImpl, org.apache.velocity.util.introspection.UberspectImpl.VelSetterImpl
-
-
Field Summary
Fields Modifier and Type Field Description static String
UBERSPECT_CHAIN_CLASSNAMES
Deprecated.The key of the parameter that allows defining the list of chained uberspectors.
-
Constructor Summary
Constructors Constructor Description ChainingUberspector()
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
init()
Deprecated.protected void
initializeUberspector(String classname)
Deprecated.Instantiates an uberspector class and adds it to the chain.protected org.apache.velocity.util.introspection.Uberspect
instantiateUberspector(String classname)
Deprecated.Tries to create an uberspector instance using reflection.-
Methods inherited from class org.apache.velocity.util.introspection.AbstractChainableUberspector
getIterator, getMethod, getPropertyGet, getPropertySet, wrap
-
Methods inherited from class org.apache.velocity.util.introspection.UberspectImpl
getConversionHandler, setLog, setRuntimeServices
-
-
-
-
Field Detail
-
UBERSPECT_CHAIN_CLASSNAMES
public static final String UBERSPECT_CHAIN_CLASSNAMES
Deprecated.The key of the parameter that allows defining the list of chained uberspectors.- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init()
Deprecated.This implementation initializes the uberspector chain.
- Specified by:
init
in interfaceorg.apache.velocity.util.introspection.Uberspect
- Overrides:
init
in classorg.apache.velocity.util.introspection.AbstractChainableUberspector
- See Also:
Uberspect.init()
-
initializeUberspector
protected void initializeUberspector(String classname)
Deprecated.Instantiates an uberspector class and adds it to the chain. Also set the log and runtime services, if the class implements the proper interfaces. TheUberspect.init()
method is not called.- Parameters:
classname
- The name of the uberspector class to add to the chain.
-
instantiateUberspector
protected org.apache.velocity.util.introspection.Uberspect instantiateUberspector(String classname)
Deprecated.Tries to create an uberspector instance using reflection.- Parameters:
classname
- The name of the uberspector class to instantiate.- Returns:
- An instance of the specified Uberspector. If the class cannot be instantiated using the default
constructor, or does not implement
Uberspect
,null
is returned.
-
-