CORBA 客户/服务器编程
1 实验目的:
学习 CORBA 客户/服务器编程。
2 实验内容及步骤:
2.1 安装 Visual Café 和 JDK1.1
2.2 服务器接口的语言无关的 IDL 定义:
程序清单 1:Count.IDL
module Counter
{ interface Count
{attribute long sum;
long increment();
};
};
运行 idl2java 编译器:
prompt> idl2java count.idl -no_comments –no_tie
2.3 服务器端:
首先实现 Count 接口函数:
程序清单 2:Countlmpl
//CountIml.java:The Count Implementation
class CountImpl extends Counter._CountImplBase
{private int sum;
//Constructor
CountImpl(String name)
{ super(name);
System.out.println(“Count Object Created”);
Sum=0;
}
//get sum
public int sum()
{
return sum;
}
//set sum
public void sum(int val)
{
sum = val;
}
//increment method
public int increment()
{
sum++;