You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

We now have to configure the tutorial-file-su to copy files from one directory to the other.

Configuring pom.xml

Changing the project name

In order to make the build output a little bit more comprehensible, we first change the project name in the generated pom.xml file.

<project>
  ...
  <name>Tutorial :: File SU</name>
  ...
</project>

Adding a dependency for a JBI component

Every service unit is targeted at a specific JBI component. We also specify this in pom.xml, by simple adding a dependency to the targeted pom.xml. ServiceMix's Maven tooling will take care of the rest. In this case, we are going to add a dependency to servicemix-file (groupId is org.apache.servicemix. The ServiceMix version is specified as a property in the pom.xml file, so we are going to re-use the same version property here. Since we are not going to use JUnit here, the <dependencies> element below should be enough for your SU right now.

<dependencies>
  <dependency>
    <groupId>org.apache.servicemix</groupId>
    <artifactId>servicemix-file</artifactId>
    <version>${servicemix-version}</version>
  </dependency>
</dependencies>

Configuring xbean.xml

Next, we will have to configure our new SU to really provide some services. We do this by creating a file named xbean.xml in the src/main/resources directory of our tutorial-file-su module. The sample shown below defines two namespaces: the ftp prefix refers to namespace to address the standard FTP functionality, while the t prefix will be used for the namespace in which all our services will be defined.

<beans xmlns:ftp="http://servicemix.apache.org/ftp/1.0"
       xmlns:t="urn:servicemix:tutorial">
  <!-- add the sender endpoint here -->
  <!-- add the poller endpoint here -->    
</beans>

Defining a file sender endpoint

A file sender can be used to write files on the local filesystem. With the XML snippet shown below, we create a file sender endpoint by using appropriate XML element and specifying the service name, endpoint name and the directory to write the files in (change this into an existing folder on your machine).

<file:sender service="test:file" 
             endpoint="sender"
             directory="file:/home/gert/sender" />

Defining a file poller endpoint

We are going to read XML files from a specific directory. The XML snippet below is used to configure a poller.

<file:poller service="test:file" 
             endpoint="poller"
             directory="file:/home/gert/poller" 
             targetService="test:file"
             targetEndpoint="sender"/>

Things to remember

  • You specify the target component for a SU as a normal dependency in Maven's pom.xml file
  • In ServiceMix, most service units will be configured by a file named xbean.xml

  • No labels