Skip to end of metadata
Go to start of metadata

ConfigureMe supports following annotations:

Annotation

Target

Parameters

AbortedConfiguration

Method

 

AfterConfiguration

Method

 

AfterInitialConfiguration

Method

 

AfterReConfiguration

Method

 

BeforeConfiguration

Method

 

BeforeInitialConfiguration

Method

 

BeforeReConfiguration

Method

 

Configure

Field

 

ConfigureMe

Class

name,watch,type,allfields

DontConfigure

Field

 

Set

Method

value

SetAll

Method

 

SetIf

Method

value,condition

Details

AbortedConfiguration

Called if the configuration has been aborted due to a casting or parsing error, for example trying to set an int field with a unparseble string value.
Example:



AfterConfiguration

Called after each successful configuration.
Example:



AfterInitialConfiguration

Called after first successful configuration.
Example:



AfterReConfiguration

Called after each successful re-configuration.
Example:



BeforeConfiguration

Called before each configuration attempt.
Example:



BeforeInitialConfiguration

Called before first configuration attempt.
Example:



BeforeReConfiguration

Called before each configuration attempt except first.
Example:



Configure

Marks a field configureable. The field must be either public or have a setter (recommended).
Example:



ConfigureMe

Marks a class as configurable.

Parameter

default

Description

name

 

Configuration name. If skipped the class name (without package) is used.

watch

true

If true the configuration for the artefact will be watched and the artefact reconfigured as soon as the config changes. It implicitely means that the instance to the artefact will be stored in the configuration management. Don't use on objects which are supposed to die soon after usage (at the end of a request or similar cause it could lead to memory leaks.

type

Type.File

Type of configuration source. Currently supported are File and Fixture.

allfields

false

If true all fields are set from configuration regardless whether they are annotated Configure or not.

 

 

Only fields which are marked DontConfigure are ignored.

Example:



DontConfigure

Marks a field not configureable. In case the class is annotated with ConfigureMe(allfields=true) this field will be ignored.
Example:



Set

Calls the method with the value of the configuration property specified by the value (noname) attribute.

Parameter

default

Description

value

 

Name of the attribute in the configuration object


Example:



SetAll

Calls the method with each name, value pair in the configuration object. Requires the target method to have two string parameters.
Example:



SetIf

Calls the method with the name and the value of the configuration properties which match value and condition annotation parameters. Value is a string parameter, while condition is one of the SetIfCondition enum values. There are currently 3 of them :

  • startsWith (does the key start with given annotation value)
  • contains (does the key contain given annotation value)
  • matches (does the key match given annotation value)
    All of conditions are checked by calling the String methods of the same name on attribute name (so, the last condition supports regular expressions).

    Parameter

    default

    Description

    value

     

    Pattern of the attribute name in the configuration object

    condition

    SetIfCondition.matches

    Condition, which regulates the configuration properties to be passed to the annotated method


    Example:
    While processing SetIf annotation in the previous peace of code, the method will be called with all of the configuration properties, which have names starting with "server".

  • No labels