org.springframework.binding.support
Class AnnotationAwareBeanPropertyAccessStrategy

java.lang.Object
  extended by org.springframework.binding.support.AbstractPropertyAccessStrategy
      extended by org.springframework.binding.support.BeanPropertyAccessStrategy
          extended by org.springframework.binding.support.AnnotationAwareBeanPropertyAccessStrategy
All Implemented Interfaces:
MutablePropertyAccessStrategy, PropertyAccessStrategy

public class AnnotationAwareBeanPropertyAccessStrategy
extends BeanPropertyAccessStrategy

A JavaBean PropertyAccessStrategy that exposes JDK 1.5 Annotations for each property in the form of property level user metadata. In order to remain backward compatible with 1.4 code, the annotations will be parsed by an installed AnnotationTranslator which typically stores the content of each annotation as key + value pairs in the user metadata. If no translator is explicitly set, then this implementation will use ReflectionAnnotationTranslator by default.

Note that this implementation will scan for annotations on both the getter and setter methods of the property. If both getter and setter happen to define the same annotation, then the annotation on the getter will override the annotation on the setter.

Since:
May 8, 2006 1:57:46 PM
Author:
andy

Constructor Summary
protected AnnotationAwareBeanPropertyAccessStrategy(BeanPropertyAccessStrategy parent, String basePropertyPath)
           
  AnnotationAwareBeanPropertyAccessStrategy(Object bean)
           
  AnnotationAwareBeanPropertyAccessStrategy(ValueModel domainObjectHolder)
           
 
Method Summary
protected  Map<String,Object> getAllUserMetadataFor(String propertyPath)
          Retrieves annotations for the specified property as user metadata.
 AnnotationTranslator getAnnotationTranslator()
           
 void setAnnotationTranslator(AnnotationTranslator annotationTranslator)
           
 
Methods inherited from class org.springframework.binding.support.BeanPropertyAccessStrategy
domainObjectChanged, getBeanWrapper, getPropertyAccessor, getPropertyAccessStrategyForPath, newPropertyAccessStrategy
 
Methods inherited from class org.springframework.binding.support.AbstractPropertyAccessStrategy
getDomainObject, getDomainObjectHolder, getFullPropertyPath, getLastPropertySeparatorIndex, getMetadataAccessStrategy, getParentPropertyPath, getPropertyName, getPropertyValue, getPropertyValueModel, getUserMetadataFor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationAwareBeanPropertyAccessStrategy

public AnnotationAwareBeanPropertyAccessStrategy(Object bean)

AnnotationAwareBeanPropertyAccessStrategy

public AnnotationAwareBeanPropertyAccessStrategy(ValueModel domainObjectHolder)

AnnotationAwareBeanPropertyAccessStrategy

protected AnnotationAwareBeanPropertyAccessStrategy(BeanPropertyAccessStrategy parent,
                                                    String basePropertyPath)
Method Detail

getAllUserMetadataFor

protected Map<String,Object> getAllUserMetadataFor(String propertyPath)
Retrieves annotations for the specified property as user metadata. Uses the intalled annotation translator to "parse" annotations to their key + value pair components.

Note that currently annotations are retranslated and the returned map is rebuilt on every invocation of this method. No caching is attempted because the current use case of this method is a single call for each property during FormModel construction. If this use case or usage pattern should be changed, then we may want to consider caching the result of this method.

Overrides:
getAllUserMetadataFor in class AbstractPropertyAccessStrategy
Parameters:
propertyPath -
Returns:
all metadata for the specified property in the form of a Map containing String keys and Object values. This method may return null if there is no metadata for the property.

getAnnotationTranslator

public AnnotationTranslator getAnnotationTranslator()

setAnnotationTranslator

public void setAnnotationTranslator(AnnotationTranslator annotationTranslator)


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.