This document describes the steps required to get spring-config up and running in your application using a custom (in-house) configuration agent.
When spring-config finds a placeholder in one of your bean definition files, it delegates to the defined implementation of PlaceholderEvaluator to evaluate and substitute the value. So, first create an implementation of the PlaceholderEvaluator interface that collaborates with your configuration agent.
If you're using a simple key value based configuration agent (something similar to the java.util.Properties class) your task couldn't be easier. Check out the PropertiesPlaceholderEvaluator class for an example.
If your configuration agent provides the ability to retrieve complex objects (e.g. a java.util.Set object) you need to do a bit more work. The Placeholder objects passed to the evaluate method has a type property that tells you the type of object that should be returned. Take a look at AbstractPlaceholderEvaluator and CommonsPlaceholderEvaluator for examples.
The ConfigurationPlaceholderProcessor class performs the bulk of the work in spring-config. It coordinates between your configuration agent and spring's bean factory to substitute placeholders with objects returned from the configuration agent.
You will need to define the ConfigurationPlaceholderProcessor with your custom implementation of placeholder evaluator in order to look up the configured values from your configuration agent. In the below example we set the placeholderEvaluator property to a custom implementation of the PlaceholderEvaluator class.
<bean id="configurationPlaceholderProcessor" class="org.reactive.beans.factory.config.ConfigurationPlaceholderProcessor"> <property name="placeholderEvaluator"> <bean class="com.yourcompany.CustomPlaceholderEvaluator"> ... </bean> </property> </bean>
Now that we have told Spring about the configuration placeholder processor we can start adding placeholders to your bean definition files. Take a look at the syntax page for details on spring-config's place holder syntax.