org.xwiki.velocity.introspection
Class LinkingUberspector
java.lang.Object
org.apache.velocity.util.introspection.UberspectImpl
org.xwiki.velocity.introspection.LinkingUberspector
- All Implemented Interfaces:
- org.apache.velocity.util.introspection.Uberspect, org.apache.velocity.util.introspection.UberspectLoggable, org.apache.velocity.util.RuntimeServicesAware
public class LinkingUberspector
- extends org.apache.velocity.util.introspection.UberspectImpl
- implements org.apache.velocity.util.introspection.Uberspect, org.apache.velocity.util.RuntimeServicesAware, org.apache.velocity.util.introspection.UberspectLoggable
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 an array of uberspectors, loading the classes in the order
defined in the "runtime.introspector.uberspect.arrayClasses" property, and after that forwards calls to
each of the uberspectors, in order, until one of them returns something different than null. Note that
the calls will be made from the leftmost class to the rightmost one. This allows building and combining different
small uberspectors that perform a specialised search for methods, instead of bloating a single class with different
introspection tricks.
This is not actually part of the array, but is more of a handle that allows the calls intended for only one
uberspector to reach the array. It duplicates some of the code from the velocity runtime initialization code, hoping
that a future version of the engine will support this natively.
The array is defined using the configuration parameter runtime.introspector.uberspect.arrayClasses. 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 a SecureUberspector is used
as the only entry in the array.
- Since:
- 1.5RC1
- Version:
- $Id$
- See Also:
ChainingUberspector
| 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 |
| Fields inherited from class org.apache.velocity.util.introspection.UberspectImpl |
introspector, log |
| Methods inherited from class org.apache.velocity.util.introspection.UberspectImpl |
setLog, setRuntimeLogger |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.velocity.util.introspection.UberspectLoggable |
setLog, setRuntimeLogger |
UBERSPECT_ARRAY_CLASSNAMES
public static final String UBERSPECT_ARRAY_CLASSNAMES
- The key of the parameter that allows defining the array of uberspectors.
- See Also:
- Constant Field Values
LinkingUberspector
public LinkingUberspector()
setRuntimeServices
public void setRuntimeServices(org.apache.velocity.runtime.RuntimeServices rs)
- Specified by:
setRuntimeServices in interface org.apache.velocity.util.RuntimeServicesAware
init
public void init()
-
This implementation initializes the array of uberspectors.
- Specified by:
init in interface org.apache.velocity.util.introspection.Uberspect- Overrides:
init in class org.apache.velocity.util.introspection.UberspectImpl
- See Also:
Uberspect.init()
initializeUberspector
protected void initializeUberspector(String classname)
- Instantiates and initializes an uberspector class and adds it to the array. Also set the log and runtime
services, if the class implements the proper interfaces.
- Parameters:
classname - The name of the uberspector class to add to the chain.
instantiateUberspector
protected org.apache.velocity.util.introspection.Uberspect instantiateUberspector(String classname)
- 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.
getIterator
public Iterator getIterator(Object obj,
org.apache.velocity.util.introspection.Info i)
throws Exception
- Specified by:
getIterator in interface org.apache.velocity.util.introspection.Uberspect- Overrides:
getIterator in class org.apache.velocity.util.introspection.UberspectImpl
- Throws:
Exception
getMethod
public org.apache.velocity.util.introspection.VelMethod getMethod(Object obj,
String methodName,
Object[] args,
org.apache.velocity.util.introspection.Info i)
throws Exception
- Specified by:
getMethod in interface org.apache.velocity.util.introspection.Uberspect- Overrides:
getMethod in class org.apache.velocity.util.introspection.UberspectImpl
- Throws:
Exception
getPropertyGet
public org.apache.velocity.util.introspection.VelPropertyGet getPropertyGet(Object obj,
String identifier,
org.apache.velocity.util.introspection.Info i)
throws Exception
- Specified by:
getPropertyGet in interface org.apache.velocity.util.introspection.Uberspect- Overrides:
getPropertyGet in class org.apache.velocity.util.introspection.UberspectImpl
- Throws:
Exception
getPropertySet
public org.apache.velocity.util.introspection.VelPropertySet getPropertySet(Object obj,
String identifier,
Object arg,
org.apache.velocity.util.introspection.Info i)
throws Exception
- Specified by:
getPropertySet in interface org.apache.velocity.util.introspection.Uberspect- Overrides:
getPropertySet in class org.apache.velocity.util.introspection.UberspectImpl
- Throws:
Exception
Copyright © 2004-2011 XWiki. All Rights Reserved.