Tuscany 是 Apache 的开源项目,它是 IBM、Oracle、SAP 等厂商联合成立的 SOA 标准化组织 -OSOA 支持下开发出的 SCA 框架,它既是开源界 SCA 的试金石,也是当前开源界最成熟的 SCA 框架之一。
divideInterface
tuscany是一套开源的sca框架模型,是做soa的基础架构。
但是他的版本只更新到2002年,但是因为公司在用,没办法,跑了一个demo。
开发环境
idea 2017.1.1 maven3.3.9 Java1.8 Tuscany 2.0.1(经测试Java1.6可以)
目录结构
我实现的是一个计算器的小demo(官网的小例子)
所需依赖
<dependencies> <!--https://mvnrepository.com/artifact/org.apache.tuscany.sca/tuscany-base-runtime--> <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-base-runtime</artifactId> <version>2.0.1</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.tuscany.sca.aggregation/tuscany-binding-rmi-runtime-aggregation --> <dependency> <groupId>org.apache.tuscany.sca.aggregation</groupId> <artifactId>tuscany-binding-rmi-runtime-aggregation</artifactId> <version>2.0.1</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.tuscany.sca.aggregation/tuscany-binding-ws-runtime-axis2-aggregation --> <dependency> <groupId>org.apache.tuscany.sca.aggregation</groupId> <artifactId>tuscany-binding-ws-runtime-axis2-aggregation</artifactId> <version>2.0.1</version> </dependency> </dependencies>
加减乘除的方法都是写在接口里。
addInterface.class
/** * Created by ${MIND-ZR} on 2017/12/19. */ public interface addInterface { public double add(double n1,double n2); }
/** * Created by ${MIND-ZR} on 2017/12/19. */ public interface divideInterface { double divide(double n1,double n2); }
multiplyInterface
/** * Created by ${MIND-ZR} on 2017/12/19. */ public interface multiplyInterface { double multiply(double n1,double n2); }
subtractInterface
/** * Created by ${MIND-ZR} on 2017/12/19. */ public interface subtractInterface { double subtract(double n1,double n2); }
他们的实现方法分别是。
add
package servieImpl; import service.addInterface; /** * Created by ${MIND-ZR} on 2017/12/19. */ public class add implements addInterface { public double add(double n1,double n2){ return n1+n2; <