com.atlassian.confluence.velocity.introspection
Class AnnotationBoxingUberspect
java.lang.Object
org.apache.velocity.util.introspection.UberspectImpl
com.atlassian.confluence.velocity.introspection.AnnotationBoxingUberspect
- All Implemented Interfaces:
- org.apache.velocity.util.introspection.Uberspect, org.apache.velocity.util.introspection.UberspectLoggable, org.apache.velocity.util.RuntimeServicesAware
- Direct Known Subclasses:
- ConfluenceAnnotationBoxingUberspect
public class AnnotationBoxingUberspect
- extends org.apache.velocity.util.introspection.UberspectImpl
- implements org.apache.velocity.util.RuntimeServicesAware
A Velocity uberspect that boxes return values in an annotated form and unboxes them again when used as arguments
to or targets of method calls
More specifically this uberspect will inspect any target method call or property for annotations that are marked as
ReturnValueAnnotation
s and box the result of calling or accessing the target with these annotations.
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 |
Method Summary |
protected Class |
getClassForTargetObject(Object targetObject)
Template method for returning the actual concrete class of a the provided object. |
Iterator |
getIterator(Object obj,
org.apache.velocity.util.introspection.Info info)
Get an iterator responsible for preserving annotations while iterating over a collection that has collection
inheritable return value annotations.' |
org.apache.velocity.util.introspection.VelMethod |
getMethod(Object obj,
String methodName,
Object[] args,
org.apache.velocity.util.introspection.Info info)
Return a method that knows how to unbox method call targets and parameters and to box return values
according to the return value boxing policy. |
protected Collection<Annotation> |
getMethodAnnotations(Method method)
Retrieve any annotations on the supplied method that are meta-annotated as a ReturnValueAnnotation |
org.apache.velocity.util.introspection.VelPropertyGet |
getPropertyGet(Object obj,
String identifier,
org.apache.velocity.util.introspection.Info info)
Get a property getting strategy that will box the end result with any return value annotations on the property getter |
void |
init()
|
void |
setRuntimeServices(org.apache.velocity.runtime.RuntimeServices runtimeServices)
|
Methods inherited from class org.apache.velocity.util.introspection.UberspectImpl |
getPropertySet, setLog, setRuntimeLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AnnotationBoxingUberspect
public AnnotationBoxingUberspect()
init
public void init()
- Specified by:
init
in interface org.apache.velocity.util.introspection.Uberspect
- Overrides:
init
in class org.apache.velocity.util.introspection.UberspectImpl
getMethod
public final org.apache.velocity.util.introspection.VelMethod getMethod(Object obj,
String methodName,
Object[] args,
org.apache.velocity.util.introspection.Info info)
throws Exception
- Return a method that knows how to unbox method call targets and parameters and to box return values
according to the return value boxing policy.
- Specified by:
getMethod
in interface org.apache.velocity.util.introspection.Uberspect
- Overrides:
getMethod
in class org.apache.velocity.util.introspection.UberspectImpl
- Parameters:
obj
- Object to locate the method onmethodName
- Name of the method to locateargs
- Method call argumentsinfo
- Current template info
- Returns:
- Method calling strategy that will transparently handle boxed arguments and targets while automatically
boxing method return values with return value annotations.
- Throws:
Exception
getIterator
public final Iterator getIterator(Object obj,
org.apache.velocity.util.introspection.Info info)
throws Exception
- Get an iterator responsible for preserving annotations while iterating over a collection that has collection
inheritable return value annotations.'
- Specified by:
getIterator
in interface org.apache.velocity.util.introspection.Uberspect
- Overrides:
getIterator
in class org.apache.velocity.util.introspection.UberspectImpl
- Parameters:
obj
- object to get an iterator forinfo
- current template info
- Returns:
- Inheritable annotation preserving iterator
- Throws:
Exception
getPropertyGet
public final org.apache.velocity.util.introspection.VelPropertyGet getPropertyGet(Object obj,
String identifier,
org.apache.velocity.util.introspection.Info info)
throws Exception
- Get a property getting strategy that will box the end result with any return value annotations on the property getter
- Specified by:
getPropertyGet
in interface org.apache.velocity.util.introspection.Uberspect
- Overrides:
getPropertyGet
in class org.apache.velocity.util.introspection.UberspectImpl
- Parameters:
obj
- Object on which a property is being retrievedidentifier
- Property identifierinfo
- Current template info
- Returns:
- A return value boxing property getter
- Throws:
Exception
setRuntimeServices
public void setRuntimeServices(org.apache.velocity.runtime.RuntimeServices runtimeServices)
- Specified by:
setRuntimeServices
in interface org.apache.velocity.util.RuntimeServicesAware
getMethodAnnotations
protected Collection<Annotation> getMethodAnnotations(Method method)
- Retrieve any annotations on the supplied method that are meta-annotated as a
ReturnValueAnnotation
- Parameters:
method
- Method to search
- Returns:
- Collection of annotations that have been marked as a
ReturnValueAnnotation
on the provided method.
getClassForTargetObject
protected Class getClassForTargetObject(Object targetObject)
- Template method for returning the actual concrete class of a the provided object.
This method should be overridden in environments where objects may be proxied in such a way that
method annotations are not reflected by the proxying object class.
This implementation simply returns targetObject.getClass()
- Parameters:
targetObject
- The object for which the class is being queried
- Returns:
- The actual class that should be queried for return value annotations