SOA(wso2+tuscany)新框架开发部署规范


一、wso2

   环境部署...

   a. 复制wso2dataservices-2.6.2 到/usr/local/目录下面

   b. 进入/usr/local/目录,建立软链接 ln -s wso2dataservices-2.6.2 wso2dataservices

   c. 设置环境变量$JAVA_HOME

   d. 如果是64为操作系统,需要执行如下操作

      cd /usr/local/wso2dataservices/bin/native/

      mv wrapper-linux-x86-32 wrapper-linux-x86-32.bak

   

   1、系统名称 + DataService, 如ProductcenterDataService 对应的系统是Productcenter

   

   2、数据库名称 + DataSource,如ProductcenterBaseDataSource 对应的数据库 productcenter_base,

                            ProductcenterEbayDeDataSource 对应的数据库 productcenter_ebay_de

                            数据连接参数中需要增加autoReconnect=true&failOverReadOnly=false, 如

                            jdbc:mysql://127.0.0.1:3306/productcenter_base?autoReconnect=true&failOverReadOnly=false

                            因为是在xml中,所以"&"符号需要转义成"&"

                              

   3、有大文本字段的数据表,做query的时候,需要分开多个query来做,

      如sku表,需要分成getSkuBaseBySkuIdList和getSkuDescriptionBySkuIdList,在getSkuBaseBySkuIdList的sql语句

      里面不要使用"*",要将出大文本字段以外的字段全部列出来

      

   4、在query里面不管字段名称是什么命名方式,对应的element name都要采用java 变量的命名方式,

      如<element name="skuId" column="skuid" xsdType="xs:string" />

      

   5、对于返还列表的query, result里面的rowName要与query里面的一直,并且element name 要在rowNname的基础上加复数,如

      <query id="getSkuBaseBySkuIdList" useConfig="productcenterBaseDataSource">                                    

        ...

        <result element="SkuBases" rowName="SkuBase">                                                      

        ...               

        </result>                                    

        ...

      </query>    

                 

      <query id="getSkuDescriptionBySkuIdList" useConfig="productcenterBaseDataSource">                                    

        ...                           

        <result element="SkuDescriptoins" rowName="SkuDescription">                                                      

        ...                             

        </result>                                    

      ...         

      </query>

    

   6、operation的名称需要在query名称后面加Das,主要是为了在tuscany发布wsdl与sca operation区分开,如

      <operation name="getSkuBaseBySkuIdListDas">                                                                        

        <call-query href="http://winsdomwen.blog.163.com/blog/getSkuBaseBySkuIdList">

           <with-param name="skuIdList" query-param="skuIdList" />                                                                        

        </call-query>                                    

      </operation>

      

   7、JDBC连接需要设置autoReconnect=true&failOverReadOnly=false参数

   

      

二、tuscany SCA

   环境部署

   a. 复制 apache-tomcat-7.0.20 到 /usr/local目录下面

   b. 进入/usr/local/目录,建立软链接 ln -s apache-tomcat-7.0.20 tomcat

   

   

   在eclipse里面安装maven插件

   在eclipse安装tuscany插件

   引用tuscany user lib(主要是方便在eclipse里面调试)

   编辑pom.xml文件,统一开发、部署的插件和依赖

   

   1、由wos2 wsdl生成java 代码,要放在com.dragonmarts + dataService对应的系统名称 + das的package,还要注意生成代码的位置,生成代码的时候要自动将数据类型类序列化

      如在productcenter系统中生成wso2 productcenterDataService 的代码

      cd /export/productcenter_app/src/main/java

      wsimport -extension -b ../resources/serializable_data_type_object.xml -s . -d . -p com.dragonmarts.productcenter.das http://productcenter.das.wgzhou.ux168.cn:9763/services/ProductcenterDataService?wsdl

      

      如在productcenter系统中生成custom wso2 productcenterDataServiceX 的代码

      cd /export/productcenter_app/src/main/java

      wsimport -extension -b ../resources/serializable_data_type_object.xml -s . -d . -p com.dragonmarts.productcenter.dasx http://productcenter.das.wgzhou.ux168.cn:9763/services/ProductcenterDataServiceX?wsdl


      

      如在productcenter系统中生成wso2 inventoryDataService 的代码(不建议跨系统调用DataService,最好通过系统app提供的Service)

      cd /export/productcenter_app/src/main/java

      wsimport -extension -b ../resources/serializable_data_type_object.xml -s . -d . -p com.dragonmarts.inventory.das http://inventory.das.hello.ux168sandbox.cn:9763/services/InventoryDataService?wsdl

      

      

      使用其他系统的服务接口

      cd /export/productcenter_app/src/main/java

      wsimport -extension -b ../resources/serializable_data_type_object.xml -s . -d . -p com.dragonmarts.external.dms http://app.dms.ux168.cn:8080/dms_app/MarketplaceDynamicComponent?wsdl

      

      

   2、系统提供的服务,代码要放在com.dragonmarts + 系统名称 + service 包里面,

                   实现要放在com.dragonmarts + 系统名称 + impl 包里面,

                   注意service和impl都用单数,如

      com.dragonmarts.productcenter.service,

      com.dragonmarts.productcenter.impl

      

      mvn tomcat:redeploy

      

   3、自己写的数据类型,代码要放在com.dragonmarts + 系统名称 + model 包里面,如

      com.dragonmarts.productcenter.model

      并且类需要加实现序列化,如

      package com.dragonmarts.productcenter.model;

      import java.io.Serializable;

      public class EbayDeScuSkuBaseComposite implements Serializable{...}

      

      mvn assembly:assembly

      cp /export/productcenter_das_x/target/productcenter_das_x-0.0.1-SNAPSHOT-jar-with-dependencies.jar /usr/local/wso2dataservices/repository/deployment/server/axis2services/

      

   4、关联表数据类型设计。

      1) 明确主从关系表的,要做一个主从表的组合返回类型,如shipment(shipment_master, shipment_detail, order_master, order_detail)

      2) map关系表,不需要做组合返回类型,具体的组合显示在web(php)端处理,如category与product是由category_product表关联,scu与sku表是由scu_sku表关联

         order与transaction是由order_transaction表关联

      3) 外键型,不需要做组合返回类型,如order与shipment,是shipment里面有orderId字段


      

   

   

三、定制化DataService开发, DataServiceX

   1、JDBC连接需要设置autoReconnect=true&failOverReadOnly=false参数

   2、Connection, Statement, PreparedStatement, ResultSet资源的释放

   


   mvn assembly:assembly

   

四、域名使用规范

   产品环境 wso2: productcenter.das.ux168.cn

          tuscany: app.productcenter.ux168.cn

          

   测试环境 wso2: productcenter.das.sandbox.ux168.cn

          tuscany: app.productcenter.sandbox.ux168.cn

          

   开发环境 wso2: productcenter.das.wgzhou.ux168.cn (用自己的名字)

          tuscany: app.productcenter.wgzhou.ux168.cn


五、CETS部署


mvn package -Denv=production

cd target

scp cets_app_production.war   root@172.16.10.221:/tmp/upgrade/cets_app/20120607