Configuration should be thought of as an xpath with {@link ApplicationDefinition} at the root element and {@link ClusterDefinition}s as the child elements. It's used to layout the topology of an entire Dempsy appliation. Let's say the following simple processing pipeline constitutes a Dempsy application:
SimpleAdaptor -> SimpleMessageProcessor
The straightforward configuration that accepts all of the defaults would be:
new ApplicationDefinition("my-application").add( new ClusterDefinition("adaptor-stage",new SimpleMessageAdaptor()), new ClusterDefinition("processor-stage",new SimpleMessageProcessor()));
As an example using Spring, your application context would contain:
<bean class="com.nokia.dempsy.config.ApplicationDefinition"> <property name="applicationName" value="my-application" /> <property name="clusterDefinitions"> <list> <bean class="com.nokia.dempsy.config.ClusterDefinition"> <constructor-arg name="clusterName" value="adaptor-stage" /> <property name="adaptor" > <bean class="SimpleMessageAdaptor" /> </property> </bean> <bean class="com.nokia.dempsy.config.ClusterDefinition"> <constructor-arg name="clusterName" value="processor-stage" /> <property name="messageProcessorPrototype"> <bean class="SimpleMessageProcessor" /> </property> </bean> </list> </property> </bean>
Notice, when using a dependency injection framework, you have the ability to configure your prototypes ( {@link MessageProcessor}s) and {@link Adaptor}s independently from Dempsy. The Dempsy {@link ApplicationDefinition} would then be the point where you definethe topology of processing chain. This nicely decouples the two concerns.
While any DI framework can be used if you then join the {@link ApplicationDefinition} toa Dempy instance (by hand), this is unnecessary when using either Spring or Guice as both are supported out-of-the-box.
Note: for ease of use when configuring by hand (not using a dependency injection framework like Spring or Guice) all "setters" (all 'mutators' in general) return the {@link ApplicationDefinition}itself for the purpose of chaining.