...
As shown below, we configure the web.xml with a Tuscany servlet filter which is responsible to dispatch HTTP requests to corresponding SCA service binding listeners.
Code Block |
---|
2 | xml |
---|
borderStyle | solid |
---|
title | Sample WEB-INF/web.xml |
---|
borderStyle | solid |
---|
|
<?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 Calculator Web Service Sample</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>
|
...
The most important setting in the geronimo-web.xml is inverse-classloading which ensures the tuscany and its dependency classes will be loaded from the WEB-INF/lib. It creates an isolated environment for the tuscany runtime without being interfered by other jars shipped by Geronimo (such as axis2).
Code Block |
---|
2 | xml | borderStyle | solid |
---|
title | Sample WEB-INF/geronimo-web.xml |
---|
borderStyle | solid |
---|
|
<?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>sample-calculator-ws-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>
|
...
Anchor |
---|
| Calculator.composite |
---|
| Calculator.composite |
---|
|
Code Block |
---|
2 | xml | borderStyle | solid |
---|
title | Calculator.composite |
---|
borderStyle | solid |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://sample"
xmlns:sample="http://sample"
name="Calculator">
<component name="CalculatorServiceComponent">
<implementation.java class="calculator.CalculatorServiceImpl"/>
<reference name="addService" >
<interface.java interface="calculator.AddService" />
<binding.ws uri="http://localhost:8080/sample-calculator-ws-webapp/AddServiceComponent"/>
</reference>
<reference name="subtractService" target="SubtractServiceComponent"></reference>
<reference name="multiplyService" target="MultiplyServiceComponent"></reference>
<reference name="divideService" target="DivideServiceComponent"></reference>
</component>
<component name="AddServiceComponent">
<implementation.java class="calculator.AddServiceImpl"/>
<service name="AddService">
<interface.java interface="calculator.AddService" />
<binding.ws/>
</service>
</component>
<component name="SubtractServiceComponent">
<implementation.java class="calculator.SubtractServiceImpl"/>
</component>
<component name="MultiplyServiceComponent">
<implementation.java class="calculator.MultiplyServiceImpl"/>
</component>
<component name="DivideServiceComponent">
<implementation.java class="calculator.DivideServiceImpl"/>
</component>
</composite>
|
...
Anchor |
---|
| META-INF/sca-contribution.xml |
---|
| META-INF/sca-contribution.xml |
---|
|
Code Block |
---|
2 | xml | borderStyle | solid |
---|
title | META-INF/calculator.composite |
---|
borderStyle | solid |
---|
|
<?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:Calculator"/>
</contribution>
|
...
You can acccess existing stateless session bean using binding.ejb. Here is an example of the composite file.
Code Block |
---|
2 | xml | borderStyle | solid |
---|
title | binding.ejb |
---|
borderStyle | solid |
---|
|
<binding.ejb uri="corbaname:iiop:1.2@localhost:1050#VegetablesCatalogEJB" />
|
...