Tuscany Web Application based Integration with Geronimo
Package the Tuscany application as a WAR with all the application jars/classes and Tuscany jars (including the dependencies) in the WEB-INF/lib folder. Configure the deployment plan to enable "inverse-classloading" so that the Tuscany jars and dependencies are loaded first by the web app classloader.
Packaging
src/main/webapp
... META-INF/
... WEB-INF/
web.xml
Sample WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>Apache Tuscany Alert Aggregator Demo</display-name> <filter> <filter-name>tuscany</filter-name> <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class> </filter> <filter-mapping> <filter-name>tuscany</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
geronimo-web.xml
Sample WEB-INF/geronimo-web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0" xmlns:d="http://geronimo.apache.org/xml/ns/deployment-1.2"> <d:environment> <d:moduleId> <d:groupId>org.apache.tuscany.sca</d:groupId> <d:artifactId>demo-alert-aggregator-webapp</d:artifactId> <d:version>1.2-incubating-SNAPSHOT</d:version> <d:type>war</d:type> </d:moduleId> <d:inverse-classloading /> </d:environment> </web-app>
sca-contribution.xml
META-INF/sca-contribution.xml
<?xml version="1.0" encoding="UTF-8"?> <contribution xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://sample" xmlns:sample="http://sample"> <deployable composite="sample:FeedAggregator"/> </contribution>
Test automation with maven
<!-- This profile handles generation of jar/war artifacts to be used in executing tests in a web-container --> <profile> <id>webapp</id> <activation> <activeByDefault>false</activeByDefault> </activation> <dependencies> <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-host-webapp</artifactId> <version>1.2-incubating-SNAPSHOT</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-host-webapp-junit</artifactId> <version>1.2-incubating-SNAPSHOT</version> <scope>runtime</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.3</version> <scope>provided</scope> </dependency> </dependencies> <build> <pluginManagement> <plugins> <!-- Skip local junit test cases --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.3.1</version> <configuration> <skip>true</skip> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <!-- Generate web-xml --> <plugin> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-maven-web-junit</artifactId> <version>1.2-incubating-SNAPSHOT</version> <executions> <execution> <id>generate-web-xml</id> <phase>process-resources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> <!-- Create war and include jUnit test classes --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.0.2</version> <configuration> <primaryArtifact>false</primaryArtifact> <!-- Exclude a few jars to avoid conflicts --> <warSourceExcludes>WEB-INF/lib/tuscany-host-tomcat-*.jar,WEB-INF/lib/tuscany-host-jetty-*.jar,servlet-api-*.jar, WEB-INF/classes/META-INF/sca-contribution*.xml</warSourceExcludes> <webResources> <resource> <directory>${project.build.directory}/test-classes</directory> <targetPath>WEB-INF/classes</targetPath> </resource> <resource> <directory>${project.build.directory}/classes/META-INF</directory> <includes> <include>sca-contribution*.xml</include> </includes> <targetPath>META-INF</targetPath> </resource> <!-- Add the junit --> <resource> <directory>${settings.localRepository}/junit/junit/4.2</directory> <includes> <include>junit-4.2.jar</include> </includes> <targetPath>WEB-INF/lib</targetPath> </resource> </webResources> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>war</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile>