TuscanySCA4-Single Process中运行Composite Application
1. 准备Contributions
??? Contributions是SCA的打包策略,其中可包含:可执行的代码,Composite,或其他的组件(如:Scheme??
??? File,WSDLFile, ZIP,WAR).
??? Contributions可以Export或Imoport XML 命名空间或Java Package,这样可以是相同的命名空间在多个??
??? Contributions之间共享避免了在不同Contributions中有重复命名空间的问题。
??? Export Namespaces:
??? <contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
????????????? xmlns:tst="http://tuscanyscatours.com/">
????????????? <export.java package="com.tuscanyscatours" />
????????????? <deployable composite="tst:Tours" />
??? </contribution>
??? Import Namespaces:
??? <contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
????????????? xmlns:client="http://client.scatours/">
????????????? <import.java package="com.tuscanyscatours" />
????????????? <deployable composite="client:Client" />
??? </contribution>
2. Launcher Contributions的代码
??? public class IntroducingLauncher {
????????? public static void main(String[] args) throws Exception {
???????????????? //找到并创建Contributions,此处的第一个参数代表Compostie被部署后的名字,为null意味着:
???????????????? //本节点的执行环境将被部署在该Contributios中的所有Composite联合创建。
?????? ? ? ? ? ? SCANode node = SCANodeFactory.newInstance().createSCANode(null,
?????????????????????????????????????????????????????? locate("introducing-tours"),
?????????????????????????????????????????????????????? locate("introducing-trips"),
?????????????????????????????????????????????????????? locate("introducing-client"));
???????????????? node.start();
???????????????? //得到introducing-client组件中的Runnabel服务
???????????????? Runnable proxy = ((SCAClient)node).getService(Runnable.class,
??????????????????????? "TestClient/Runnable");
?
???????????????? //调用introducing-client组件中的Runnabel服务中格的run方法
???????????????? proxy.run();
???????????????? node.stop();
????????? }
? ? }
??? 注意:Tuscany1.x执行环境中,需要Imports的Contributuions需要放置在Exports的Contributions后面。
3. 运行Launcher
??? 运行上面代码的Main方法。