com.atlassian.confluence.velocity.introspection
Class AnnotationBoxingUberspect

java.lang.Object
  extended by org.apache.velocity.util.introspection.UberspectImpl
      extended by 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 ReturnValueAnnotations and box the result of calling or accessing the target with these annotations.


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 inherited from class org.apache.velocity.util.introspection.UberspectImpl
introspector
 
Constructor Summary
AnnotationBoxingUberspect()
           
 
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
 

Constructor Detail

AnnotationBoxingUberspect

public AnnotationBoxingUberspect()
Method Detail

init

public void init()
          throws Exception
Specified by:
init in interface org.apache.velocity.util.introspection.Uberspect
Overrides:
init in class org.apache.velocity.util.introspection.UberspectImpl
Throws:
Exception

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 on
methodName - Name of the method to locate
args - Method call arguments
info - 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 for
info - 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 retrieved
identifier - Property identifier
info - 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


Copyright © 2003-2012 Atlassian. All Rights Reserved.