国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

CORBA編程

2019-11-18 12:41:31
字體:
供稿:網(wǎng)友

  先編一個idl文件,如:person.idl
  module person{
  interface hand{
  int add(int x,int y);
  }
  }
  然后用idl2java.exe文件編譯person.idl文件
  idl2java person.idl
  產(chǎn)生一個目錄person
  里面有一個文件hand.java,這里定義了一個接口interface hand
  應該編一個類去實現(xiàn)這個接口handImpl.java
  public class handImpl extends _handImplBase implements
  hand{
  int x,y;
  public handImpl(){
  x=0;
  y=0;
  }
  int add(int x,int y){
  this.x=x;
  this.y=y;
  return (x+y);
  }
  }
  總之在handImpl中實現(xiàn)各種功能。
  
  接下來講服務器端編程:Server.java
  package person;
  public class Server{
  public static void main(String[] argv){
  org.omg.CORBA.ORB
  orb=org.omg.CORBA.ORB.init(args,null);
  org.omg.CORBA.BOA boa=orb.BOA_init();
  person.hand p=new
  person.handImpl("Person.hand");
  boa.obj_is_ready(p);
  System.out.  boa.impl_is_ready();
  }
  }
  假如路徑設置對的話,用命令java Server就行了,不過要先運行smart
  agent
  
  public class Client{
  org.omg.CORBA.ORB orb;
  person.hand p;
  public static void main(String[] argv){
  Client app=new Client();
  orb=org.omg.CORBA.ORB.init(args,null);
  
  p=person.handHelper.bind(orb,"Person.hand");
  int result=p.add(20,30);
  System.our.pritnln(result);
  }
  }
  編譯用命令javac person/*.java

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 泸水县| 陵水| 尖扎县| 榕江县| 青川县| 芜湖县| 湘阴县| 奎屯市| SHOW| 军事| 甘德县| 长岭县| 盐源县| 沾化县| 西林县| 德昌县| 阳新县| 师宗县| 黄龙县| 肥乡县| 威海市| 石台县| 乌兰浩特市| 北碚区| 高邑县| 南昌市| 府谷县| 柘城县| 凤城市| 德阳市| 义马市| 佛教| 阜平县| 吉隆县| 乐都县| 武川县| 龙里县| 合作市| 宿松县| 永寿县| 陈巴尔虎旗|