Book Image

JBoss ESB Beginner's Guide

By : Len DiMaggio, Kevin Conner, Magesh Kumar B, Tom Cunningham
Book Image

JBoss ESB Beginner's Guide

By: Len DiMaggio, Kevin Conner, Magesh Kumar B, Tom Cunningham

Overview of this book

<p>You may often have wondered if there is a better way to integrate disparate applications than error-prone "glue code". JBoss ESB is just that solution as it can help solve common but difficult problems: writing new code that can be re-used and maintained, and integrating together new and old systems. JBoss ESB takes care of routing and processing service requests, leaving you to concentrate on your system's design and development.</p> <p>The JBoss ESB Beginner’s Guide gets you up and running quickly with JBoss ESB to build your own service-based applications, with enhanced communication and organization. You will learn how to create new applications or to integrate combinations of new and legacy applications. Detailed examples get you creating your own services, and deploying and administering them with other JBoss Open Source tools.</p> <p>Through hands-on examples, this book shows you how JBoss ESB enables you to design your system as services that are loosely coupled together by sending and receiving messages. Your services can execute your own custom code, or make use of JBoss ESB’s extensive set of out-of-the-box actions to perform specific tasks. The JBoss ESB Beginner’s Guide shows you the tools you can use to build re-usable and maintainable service-based applications with JBoss ESB, and teaches you by example how to use these tools.</p>
Table of Contents (18 chapters)
JBoss ESB
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Prologue—the need for an ESB
Preface
Index

Using Maven with JBoss ESB


Most of the examples that we have gone through so far have used Apache ant to compile and package JBoss ESB archives. Maven is another very popular build tool. You can use Maven as an alternative to ant to build, compile, and package your archives, and also run your JBoss ESB tests.

Compiling with Maven

The source of JBoss ESB is built with ant, which means that no list of dependencies for the jbossesb-rosetta.jar file exists, and this presents a problem for compiling your own custom actions, listeners, and notifiers. The jbossesb-rosetta.jar file, which contains all the code which you must extend from is not hosted in a public maven repository. In order to be able to compile, you'll have to locate the jbossesb-rosetta.jar file and treat it as a third-party JAR and install it into your local maven repository manually. This will install it locally, but if you try to build your project on another machine, remember that you will want to install it manually on that machine as well.

Then you'll want to create a pom for yourself—the following example sets the compiler to JDK 1.5 and includes a number of important dependencies for compiling custom actions. You can use it as an example if you wish to compile your custom actions or gateways inside your Maven build:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <packaging>jar</packaging>
  <groupId>com.packtpub</groupId>
  <artifactId>jbossesb-example</artifactId>
  <version>1.0</version>
  <name>JBoss ESB Maven Example</name>
  <description>JBoss ESB Maven Example</description>
  <url>http://www.packtpub.com/</url>
  <properties>
    <jbossesb.version>4.10</jbossesb.version>
  </properties>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <source>1.5</source>
            <target>1.5</target>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.5</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging-api</artifactId>
      <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>org.jboss.soa.esb</groupId>
      <artifactId>rosetta</artifactId>
      <version>4.10</version>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.14</version>
    </dependency>
  </dependencies>
</project>

ESB packaging with Maven

You can use the JBoss packaging plugin to package an ESB archive. The ESB packaging plugin contains a number of configuration options which allow the user to configure the archive name, whether the archive is exploded or not, the locations of the deployment descriptor and deployment file, and what artifacts to include within the archive. Documentation can be found at http://mojo.codehaus.org/jboss-packaging-maven-plugin/esb-mojo.html.

The following is an example of a pom.xml file using the packaging plugin to package an ESB archive. This example can be used as a template in order to create your own maven pom files to package your ESB archives.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
             http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <packaging>jboss-esb</packaging>
  <groupId>com.packtpub</groupId>
  <artifactId>jbossesb-example</artifactId>
  <version>1.0</version>
  <name>JBoss ESB Maven Example</name>
  <description>JBoss ESB Maven Example</description>
  <url>http://www.packtpub.com/</url>
  <properties>
    <jbossesb.version>4.10</jbossesb.version>
  </properties>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <source>1.5</source>
            <target>1.5</target>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jboss-packaging-maven-plugin</artifactId>
        <version>2.2</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>jboss-esb</id> 
            <phase>package</phase>
            <goals>
              <goal>esb</goal>
            </goals>
            <configuration>
              <deploymentDescriptorFile>
                src/main/resources/META-INF/jboss-esb.xml
              </deploymentDescriptorFile>
              <excludeAll>true</excludeAll>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.5</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging-api</artifactId>
      <version>1.1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.soa.esb</groupId>
      <artifactId>rosetta</artifactId>
      <version>4.10</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.14</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>