最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
CORBA例子(转)――――――――我也不知道是什麽东东:-)
时间:2022-07-02 17:35:39 编辑:袖梨 来源:一聚教程网
Below is a simple example of a CORBA program
download the source file
1. produce a idl file like this
hello.idl
module HelloApp {
interface Hello {
string sayHello();
};
};
2. produce stub and skeleton files through idltojava.exe
idltojava hello.idl
idltojava is not include in the jdk. But you can download it from idldojava.
3. write a server program like this
// HelloServer.java
import HelloApp.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import java.io.*;
class HelloServant extends _HelloImplBase
{
public String sayHello()
{
return " Hello world !! ";
}
}
public class HelloServer {
public static void main(String args[])
{
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// create servant and register it with the ORB
HelloServant helloRef = new HelloServant();
orb.connect(helloRef);
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
download the source file
1. produce a idl file like this
hello.idl
module HelloApp {
interface Hello {
string sayHello();
};
};
2. produce stub and skeleton files through idltojava.exe
idltojava hello.idl
idltojava is not include in the jdk. But you can download it from idldojava.
3. write a server program like this
// HelloServer.java
import HelloApp.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import java.io.*;
class HelloServant extends _HelloImplBase
{
public String sayHello()
{
return " Hello world !! ";
}
}
public class HelloServer {
public static void main(String args[])
{
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// create servant and register it with the ORB
HelloServant helloRef = new HelloServant();
orb.connect(helloRef);
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
相关文章
- 云星穹铁道权益升级怎么玩 云崩铁权益升级活动介绍 12-03
- 以闪亮之名山中绘梦怎么玩 以闪亮之名滢然花梦套装活动介绍 12-03
- 以闪亮之名绿野梦歌礼包怎么样 以闪亮之名绿野梦歌拍照礼包介绍 12-03
- 光遇12.6有什么更新 光遇12月6日更新内容介绍 12-03
- 伍六七暗影交锋测试资格怎么获得 伍六七暗影交锋内测资格获取方法 12-03
- 无限暖暖晶莹诗集怎么样 12-03