Skip to Main Content U.S. Department of Energy

Creating a Component's Deployment Configuration


In the HelloComponent example described in Base Component Model, we demonstrated how to create a component which comprises a sub-pipeline of modules, connected by endpoints. The method AbstractMifComponent.configure() was used to configure the sub-pipeline's processing modules including all the internal endpoints used by the component. Now, we describe how to provide a default deployment configuration which sets up the external endpoints needed by the component and adds the component to the pipeline. This is done by implementing the method AbstractMifComponent.deploy() which allows the component to be configured using a property file and deployed automatically by MIF. The programmer implementing the component exposes component properties to the pipeline builder by providing standard public setter methods on the component.

Implementing deploy()

When MIF is started with: runMif -c <properties file>, it reads the specified properties file and instantiates all the components listed there using each component's zero-argument constructor, sets the properties listed in a configuration file using standard setter methods on the component and then calls deploy(). The implementation for this method should create and set the external endpoints on your component.

Specifically, the implementation for deploy() should:

  • Create the external endpoints for the component.
  • Configure properties on the external endpoints, if necessary (for example, add transformers).
  • Set the external endpoints on the component.
  • Add the component to the MIF pipeline.

Creating the properties file

A MIF properties file consists of two main sections: a global section describing properties for the whole pipeline and sections for each component's properties.

Global properties

In the global property section, an identifier for each component in the pipeline is listed. This tells MIF which components to instantiate and deploy. The list of properties looks like:


So in this pipeline we have two components (component1 and component2). MIF will also look for properties for these components in the properties file. The properties for each component will be prefixed by these strings. For example, properties for component 1 will be listed elsewhere in this file prefixed with “component1.”

Another global property is the URL for the JMS server. Defining a value for this property will create a JMS connector for the pipeline which is available to all components.

A component implementer could also choose to use another JMS server. In this case, the implementer would need to expose an appropriate property and then implement the logic to use that particular JMS server if its property is defined.

Component properties

The only requirement for a component's properties is that it have the special className property. The value for this property is the full class name of the component to add to the pipeline. This property is special in that it is not set on the component, but is used to instantiate the class. For example, component1 must have a property which looks something like:

All of the remaining properties for a component are set on the component object using public setter methods. As mentioned above, a component identified in the properties file by the identifier component1 will have properties prefixed by “component1.”. For example, a JMS topic name may be configured for your component with the key/value pair:


Given the above property, once Component1 has been instantiated MIF will look for the method Component1.setInboundTopicName(String) and call this method with the argument “topic/MyTopicName”. A component implementer may choose to expose as many properties as desired. However, to ensure maximum reusability for a component, the more configurable properties which exist, the better.

Deployment configuration example

Now let's walk through a simple example of creating a deployment configuration for a component. We will use the HelloComponent example with the modification that we add the deploy() method, create a MIF component configuration file, and tell MIF to create a pipeline based on this file.

Running the example


To run the HelloComponent example using a deployment configuration file:

  • Open 3 console windows and navigate to $MIF_HOME in each.
  • In the first window, start MIF by executing the command: runMif.bat -c
  • In the second window, start a JMS listener by executing the command: runMif.bat -g helloListener
  • In the third window, start the JMS publisher and send a message: runMif.bat -g helloPublisher

In the JMS listener window, you will see something similar to the following printed to the screen:

2007-10-05 14:06:59,334 INFO  [RunMif] -------------------------
2007-10-05 14:06:59,335 INFO  [RunMif] Running on command line: RunMif -g helloListener 
2007-10-05 14:06:59,335 INFO  [RunMif] -------------------------
2007-10-05 14:06:59,339 INFO  [RunSample] Starting sample: helloListener
Listener received: Hey, Dave, what are you doing? 

Sample code walkthrough

The sample code for this example can be found in $MIF_HOME/samples. The relevant sections are listed below.

The properties file

First, the global section lists a JMS server and the components to instantiate.


Then the HelloComponent's properties are set.

Note that the component implementer has allowed us to set each endpoint's type as well as the path for that endpoint. This allows maximum flexibility for end users who can decide what type of endpoint (JMS, TCP, VM, etc.) to use at pipeline creation time. It is also good practice to provide default values for the corresponding fields in the component class. That way, the pipeline creator can leave a given property out of the file if he wants to accept the default value.

Implementing HelloComponent.deploy()

Here is the full implementation of the deploy() method for this example.

public void deploy(MifPipeline pipeline) throws MifException 

First, we create the external inbound and outbound endpoints for our component. Note that we are using class fields for the endpoint type and path which were set by MIF with values from the properties file.

  MifEndpoint inNameEndp = pipeline.addMifEndpoint("inNameEndp", nameEndpointType, nameEndpointPath);
  MifEndpoint outHalEndp = pipeline.addMifEndpoint("outHalEndp", halEndpointType, halEndpointPath);

Next, we set the external endpoints on the component with the appropriate tags to identify each endpoint.

  this.setEndpoint("name-in", inNameEndp);
  this.setEndpoint("hal-out", outHalEndp);

Finally, we add the component to the pipeline

deployment_configuration.txt · Last modified: 2007/10/22 15:58 by iango