SCA产品部署

内嵌容器与Servlet容器:内嵌容器每个域都需要它自己的专用IP端口,而Servlet容器可以在单个实例中运行多个域。

部署步骤:

1. 创建符合WAR要求的目录结构:

    参考附件ProductionDeployment.rar

2. 创建一个sca-contribution.xml文件定义使用的域和组合:

    <contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
              xmlns:hw="http://opensoa.book.chapter441"> <!--定义命名空间-->

         <!--指明要部署的组合-->
         <deployable composite="hw:ProblemManagementComposite"/>
    </contribution>

3. 创建一个web.xml文件,将Tuscany配置为一个servlet filter拦截到SCA域的请求:

    <web-app>

        <display-name>OpenSOA Chapter 3</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>

        <welcome-file-list id="WelcomeFileList">
             <welcome-file>hello.html</welcome-file>
        </welcome-file-list>
    </web-app>

4. 创建一个Ant任务来装配WAR文件

    <target name="compile" description="Compiles Java code AND creates WAR file for deployment

         to Tomcat...">
        <mkdir dir="target/classes" />
        <javac destdir="target/classes" debug="on" source="1.5" target="1.5">
            <src path="src\main\java" />
            <classpath>
                <fileset dir="${tuscany.lib}">
                    <include name="*.jar"/>
                </fileset>
                <fileset dir="${general.lib}">
                    <include name="*.jar"/>
                </fileset>
            </classpath>
        </javac>

        <copy todir="target/classes">
            <fileset dir="src\main\resources" />
        </copy>

        <war destfile="target/opensoa-chapter4.war" webxml="src/main/webapp/WEB-INF/web.xml">
            <fileset dir="src/main/webapp"/>
            <lib refid="tuscany.jars"/>
            <lib refid="3rdparty.jars"/>
            <classes dir="target/classes"/>
        </war>
    </target>

5. 不同域之间的交互方式

    分以引用的方式使用组合和通过远程绑定使用Web服务。下面以使用Web服务为例:

    <composite  xmlns="http://www.osoa.org/xmlns/sca/1.0"
            targetNamespace="http://opensoa.book.chapter441"
            xmlns:hw="http://opensoa.book.chapter441"
            name="IssueManagementComposite">

            <service  name="SystemErrorService"
                  promote="SystemErrorComponent">
                 <binding.ws uri="http://localhost:8085/SystemErrorService" />
            </service>


            <component name="SystemErrorComponent">
                <implementation.java class="opensoa.book.chapter4_41.impl.

                        SystemErrorComponentImpl" />
            </component>
  
            <!-- Use this when running in a distributed capacity -->
            <reference name="ProblemTicket"
                     promote="SystemErrorComponent/problemTicket">
                     <binding.ws uri="http://localhost:8080/opensoa-chapter4/ProblemTicketService"/>
            </reference>  
    </composite>

猜你喜欢

转载自springsfeng.iteye.com/blog/1161831
SCA