Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 8. Packaging and Deployment for Switchyard

SwitchYard supports the following packaging types for deployment:

JAR
JAR is the default packaging type for SwitchYard apps.
WAR
WAR files are useful when you need to include additional libraries with your application or you have web application resources (e.g. JSPs, JSF, etc.).
For an example of packaging as a WAR, see the quickstart at EAP_HOME/quickstarts/switchyard/demos/orders.
EAR
EAR files support multiple application modules in a single deployment along with additional libraries.
EAR deployments allow multiple SwitchYard applications to be included in a single deployable archive. Keep in mind that the SwitchYard applications included in an EAR are still considered separate applications from a lifecycle and visibility (both class loading and service) standpoint. For an example of deploying a SwitchYard application as an EAR, see the quickstart at EAP_HOME/quickstarts/switchyard/ear-deployment.

8.1. Deployment for SwitchYard

You can deploy SwitchYard applications to the server using file-based deployment, CLI, maven plugin, and the management console. See the JBoss EAP deployment documentation for more information.

8.2. Deploy a WAR file for SwitchYard

To prepare a WAR file for deployment to SwitchYard, the SwitchYard component dependencies (switchyard-*.jar) must be excluded as they are provided by the Fuse Service Works container. There are two methods of excluding the SwitchYard dependencies:
  1. Mark the SwitchYard dependencies as provided.
    To do this, edit the pom.xml file for the WAR file. Mark the switchyard-*.jar dependiencies as provided.
    <dependency>
      <groupId>org.switchyard</groupId>
      <artifactId>switchyard-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.switchyard.components</groupId>
      <artifactId>switchyard-component-bean</artifactId>
      <scope>provided</scope>
    </dependency>
    ...	
    Next, configure switchyard-plugin in the pom.xml file:
    <plugin>
      <groupId>org.switchyard</groupId>
      <artifactId>switchyard-plugin</artifactId>
      <configuration>
        ...
        <!-- Output to war directory -->
        <outputFile>${project.build.directory}/${project.build.finalName}/WEB-INF/switchyard.xml</outputFile>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>configure</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  2. Configure the Maven WAR plugin to exclude SwitchYard dependencies
    An alternative to marking the SwitchYard dependencies as provided, is to use the Maven WAR plugin to exclude SwitchYard dependencies. Edit the pom.xml file to include the following entry:
    <plugin>
      <artifactId>maven-war-plugin</artifactId>
      <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <packagingExcludes>
          WEB-INF/lib/*.jar,
          WEB-INF/classes/META-INF/switchyard.xml
        </packagingExcludes>
        <webResources>
          <resource>
            <directory>target/classes/META-INF</directory>
            <targetPath>WEB-INF</targetPath>
            <includes>
              <include>switchyard.xml</include>
            </includes>
          </resource>
        </webResources>
      </configuration>
    </plugin>	

Note

The preferred method is option 1, Mark the SwitchYard dependencies as provided.