Class PropertyAccessStrategy
java.lang.Object
org.axonframework.common.property.PropertyAccessStrategy
- All Implemented Interfaces:
Comparable<PropertyAccessStrategy>
- Direct Known Subclasses:
AbstractMethodPropertyAccessStrategy,DirectPropertyAccessStrategy
public abstract class PropertyAccessStrategy
extends Object
implements Comparable<PropertyAccessStrategy>
Abstract Strategy that provides access to all PropertyAccessStrategy implementations.
Application developers may provide custom PropertyAccessStrategy implementations using the ServiceLoader
mechanism. To do so, place a file called
org.axonframework.common.property.PropertyAccessStrategy
in the META-INF/services folder. In this file, place the fully qualified class names of all available
implementations.
The factory implementations must be public, non-abstract, have a default public constructor and extend the
PropertyAccessStrategy class.
Note that this class is not considered public API and may undergo incompatible changes between versions.- Since:
- 2.0
- Author:
- Maxim Fedorov, Allard Buijze
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal intprotected abstract intThe priority of this strategy.static <T> Property<T> getProperty(Class<? extends T> targetClass, String propertyName) Iterates over all known PropertyAccessStrategy implementations to create aPropertyinstance for the given parameters.protected abstract <T> Property<T> propertyFor(Class<? extends T> targetClass, String property) Returns a Property instance for the givenproperty, defined in giventargetClass, ornullif no such property is found on the class.static voidregister(PropertyAccessStrategy strategy) Registers a PropertyAccessStrategy implementation at runtime.static voidunregister(PropertyAccessStrategy strategy) Removes all strategies registered using theregister(PropertyAccessStrategy)method.
-
Constructor Details
-
PropertyAccessStrategy
public PropertyAccessStrategy()
-
-
Method Details
-
register
Registers a PropertyAccessStrategy implementation at runtime. Annotated handlers that have already been inspected will not be able to use the newly added strategy.- Parameters:
strategy- implementation to register
-
unregister
Removes all strategies registered using theregister(PropertyAccessStrategy)method.- Parameters:
strategy- The strategy instance to deregister.
-
getProperty
Iterates over all known PropertyAccessStrategy implementations to create aPropertyinstance for the given parameters. Strategies are invoked in the order they are found on the classpath. The first to provide a suitable Property instance will be used.- Type Parameters:
T- Thy type defining the property- Parameters:
targetClass- class that contains propertypropertyName- name of the property to create propertyReader for- Returns:
- suitable
Property, ornullif none is found
-
compareTo
- Specified by:
compareToin interfaceComparable<PropertyAccessStrategy>
-
getPriority
protected abstract int getPriority()The priority of this strategy. In general, implementations that have a higher certainty to provide a good Property instance for any given property name should have a higher priority. When two instances have the same priority, their relative order is undefined. The JavaBean Property strategy has a value of 0. To ensure evaluation before that strategy, use any value higher than that number, otherwise lower.- Returns:
- a value reflecting relative priority,
Integer.MAX_VALUEbeing evaluated first
-
propertyFor
Returns a Property instance for the givenproperty, defined in giventargetClass, ornullif no such property is found on the class.- Type Parameters:
T- The type of class on which to find the property- Parameters:
targetClass- The class on which to find the propertyproperty- The name of the property to find- Returns:
- the Property instance providing access to the property value, or
nullif property could not be found.
-