Tuscany2.0构建RMI服务
来源:互联网 发布:淘宝试用中心首页 编辑:程序博客网 时间:2024/06/09 22:51
一、需要引入的jar包:
<dependencies>
<!-- tuscany rmi -->
<dependency>
<groupId> org.apache.tuscany.sca</groupId >
<artifactId> tuscany-base-runtime </artifactId>
<version> 2.0.1</ version>
</dependency>
<dependency>
<groupId> org.apache.tuscany.sca</groupId >
<artifactId> tuscany-binding- rmi-runtime</ artifactId>
<version> 2.0.1</ version>
<scope> runtime</ scope>
</dependency>
<dependency>
<groupId> org.apache.tuscany.sca</groupId >
<artifactId> tuscany-implementation-spring-runtime </artifactId>
<version> 2.0.1</ version>
</dependency>
</dependencies >
二、定义接口和实现:
@Remotable
public interface HelloWorld {
String sayHello(String name);
}public class HelloWorldImpl implements HelloWorld {
public String sayHello(String name) {
return "Hello " + name;
}
}三、定义composite配置文件:
helloworld.composite文件
<?xml version= "1.0" encoding ="UTF-8"?>
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://hello" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name= "helloworld-contribution" >
<component name="HelloWorldComponent">
<implementation.spring location="helloworld-context.xml" />
<service name= "HelloworldService">
<tuscany:binding.rmi uri="rmi://localhost:8085/HelloworldService" />
</service>
</component >
</composite>
helloworld-context.xml文件内容
<?xml version= "1.0" encoding ="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca-j/spring/200810"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/sca
http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd" >
<sca:service name="HelloworldService" target="helloworldService" />
<bean id="helloworldService" class="com.solidwang.tuscany.HelloWorldImpl" />
</beans>
四、定义服务启动类:
public class ServerStart {
@Test
public void testSayHello() throws NoSuchServiceException, IOException, InterruptedException {
Node node = NodeFactory.newInstance().createNode( "helloworld.composite");
node.start();
while (true ) {
TimeUnit. SECONDS.sleep(Long.MAX_VALUE);
}
}
}
五、RMI远程调用测试:
public class RmiTest {
public static void main(String[] args) throws MalformedURLException, RemoteException, NotBoundException {
HelloWorld h = (HelloWorld) Naming.lookup("//localhost:8085/HelloworldService");
System. out.println("h=" + h.sayHello("solid......" ));
}
}
0 0
- Tuscany2.0构建RMI服务
- java远程调用中的RMI构建远程服务
- rmi服务
- rmi服务
- RMI服务
- 运行Tuscany2.0的sample dosgi-calculator出错
- 托斯卡尼 tuscany2
- Spring配置RMI服务
- RMI服务 启动异常
- rmi 服务2
- rmi 服务3
- rmi 服务4
- Spring RMI暴露服务
- java RMI 注册服务
- RMI远程服务操作
- RMI远程服务操作
- 用RMI构建聊天应用程序
- Tuscany2 JMS 详解
- WPF:菜单
- Installshield简单打包步骤
- Linux下的安装Mysql
- Cracking the coding interview--Q1.6
- python环境搭建和开发工具的配置
- Tuscany2.0构建RMI服务
- WPF:选择器(selector)
- OpenGL ES 如何能看到一个物体内部和象3dmax中能只显示网格线
- 菜鸟初识UML
- win7删除远程桌面记录
- 计算二叉树的高度和结点数
- IOS7开发~错误收集
- linux使用技巧
- WPF:带头的容器