JBoss Community Archive (Read Only)

SwitchYard 0.8

Deployment

Available Runtimes

SwitchYard supports the following deployment options:

  1. SwitchYard AS7 (JBoss AS7 with SwitchYard pre-installed)

  2. Servlet Container (.war) deployment.

SwitchYard AS7

Things are a bit different in SwitchYard AS7 (based on JBoss AS7). Auto-deploy still exists, but there are some subtle changes to the process. Deploy is still just a matter of copying the archive to the server, but the target directory should be standalone/deployments.

cp myapp.jar $JBOSS_HOME/standalone/deployments/.

To undeploy the application, you need to remove the .deployed marker file that is generated upon successful deployment of your application:

rm $JBOSS_HOME/standalone/deployments/myapp.jar.deployed
You can find more information on the ins and outs of deployment on JBoss AS7 in the README.txt file contained in the standalone/deployments directory of the distribution.

Web Archive Deployments on SwitchYard AS7

The following guidelines/tips apply when deploying Web Archive (.war) based SwitchYard deployments on a SwitchYard AS7 distribution.

See the "orders" quickstart (in the demos folder) as an example of .war deployment on SwitchYard AS7.

Application Dependencies

When running on SwitchYard AS7, remember that all the SwitchYard dependencies are provided by the container, so there's no need to bundle them inside your applications .war file. If using maven to build your application, simply set <scope>provided</scope> on all the SwitchYard dependencies.

SwitchYard Maven Plugin Configuration

Some maven POM tweaks are required when using both the switchyard-plugin and maven-war-plugin plugins to build a SwitchYard deployable .war file. By default, the switchyard-plugin expects the base switchyard.xml file to be located at src/main/resources/META-INF/ within your maven project structure. This results in the maven-war-plugin putting the generated switchyard.xml (base switchyard.xml + scanned additions) into WEB-INF/classes/META-INF/ in the generated .war artifact. This is fine when deploying a .war file on Tomcat (or other pure Servlet Container), but not when deploying on SwitchYard AS7, because the SwitchYard AS7 deployer is what's doing the SwitchYard deployment work. When deploying a .war on SwitchYard AS7, we need the generated switchyard.xml to be in META-INF/ , where it can be located by the SwitchYard AS7 deployer.

In order to do this we need to move away from the defaults a little bit. We need to locate the base switchyard.xml somewhere other than in src/main/resources/META-INF/, and configure the switchyard-plugin and maven-war-plugin accordingly. Lets assume we put the base switchyard.xml in src/main/webResources/META-INF/:

images/author/download/attachments/63636286/Screen shot 2011-08-31 at 14.04.30.png
SwitchYard AS7 Web Application Maven Project Structure

The POM configuration changes (away from the default) to the switchyard-plugin and maven-war-plugin plugins would be as follows:

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    ...

    <build>
        <plugins>

            ...

            <plugin>
                <groupId>org.switchyard</groupId>
                <artifactId>switchyard-plugin</artifactId>
                <version>0.3.0-SNAPSHOT</version>
                <configuration>
                    <scannerClassNames>
                        <param>org.switchyard.component.bean.config.model.BeanSwitchYardScanner</param>
                        <param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
                        ...
                    </scannerClassNames>
                    <!--
                        Specify specific scan directories to reflect the new location of the
                        base switchyard.xml ...
                    -->
                    <scanDirectories>
                        <param>target/classes</param>
                        <param>src/main/webResources</param>
                    </scanDirectories>
                    <!--
                        Specify different output directory for the generated switchyard.xml because we don't
                        want it ending up in WEB-INF/classes/META-INF.  The maven-war-plugin is configured to
                        pick up the generated switchyard.xml from this new location...
                    -->
                    <outputDirectory>target/switchyard_xml</outputDirectory>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>configure</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <webResources>
                        <resource>
                            <!--
                                Pick up the generated switchyard.xml from location specified by
                                the switchyard-plugin...
                            -->
                            <directory>target/switchyard_xml</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

            ...

        </plugins>
    </build>
</project>

See the "orders" quickstart (in the demos folder) as an example of .war deployment on SwitchYard AS7.

Servlet Container Deployment

SwitchYard provides a Servlet <listener-class> in support for deploying SwitchYard applications in a Java EE Web Application Container such as Tomcat or Jetty. To use this component, you simply need to include the switchyard-deploy-webapp artifact as a dependency on your web application project.

<dependency>
    <groupId>org.switchyard</groupId>
    <artifactId>switchyard-deploy-webapp</artifactId>
    <version>XXX</version> <!-- SwitchYard release version e.g. 0.3.0 -->
</dependency>

You then need to add the WebApplicationDeployer class as a Servlet <listener-class> in your application's web.xml file.

<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <listener>
        <listener-class>org.switchyard.deployment.WebApplicationDeployer</listener-class>
    </listener>

    <!-- etc... -->

</web-app>

The WebApplicationDeployer class looks for a switchyard.xml file at WEB-INF/classes/META-INF/switchyard.xml, so if you are using maven to build your Web Application, you need to put your switchyard.xml in the resources/META-INF folder (i.e. not in webapp/META-INF). Your basic project structure should look as follows.

images/author/download/attachments/63636286/Screen shot 2011-08-30 at 15.21.21.png
Generic Servlet Container Web Application Maven Project Structure

Once you've made these configurations, the process of creating the Web Application is no different to developing any other Web Application. Note however that, since this is only a new feature in version 0.3.0, we have tested only a very limited set of use cases:

  1. A Basic SwitchYard .war deployment:

    • With all dependencies bundled in the application.

    • Deployable on Tomcat (and, in theory, on Jetty).

    • CDI Bean Services.

    • SOAP binding on the CDI Bean Service.

    • No JSF web ui components.

    • See the "webapp-deploy" quickstart (in the demos).

  2. A more detailed SwitchYard .war deployment:

    • Without any dependencies bundled in the application and structured to work on the SwitchYard AS7 distribution.

    • Deployable on the SwitchYard AS7 distribution (Not deployable on Tomcat or Jetty).

    • More detailed CDI Bean Service.

    • SOAP binding on the CDI Bean Service.

    • JSF web ui interface on the CDI Bean Service. For more information on building a JSF interface on top of your SwitchYard CDI Bean Services, see the Bean Services documentation.

    • See the "orders" quickstart (in the demos).

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 09:49:41 UTC, last content change 2013-03-15 00:54:28 UTC.