CORBA高高手请进:如何实现Java与Delphi的CORBA互联?

steps 2003-09-28 09:59:44
要求服务器端使用JDK1.4,客户端使用Delphi6/7,采用IIOP互联,不使用visibroker,请教高高手,如果实现互联,最好能提供实例或是相关主页文章连接。

分数不是问题,答得的创意,送上几百分!
...全文
74 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
steps 2003-09-28
  • 打赏
  • 举报
回复
接口实现程序AddImpl.java
import ArithApp.*;
import org.omg.CORBA.*;

class AddImpl extends AddPOA {
private ORB orb;

public AddImpl(ORB orb) {
this.orb = orb;
}

// implement the addArrays() method
public void addArrays(
int a[],
int b[],
ArithApp.AddPackage.arrayHolder result) {

result.value = new int[ArithApp.Add.SIZE];

for (int i = 0; i < ArithApp.Add.SIZE; i++) {
result.value[i] = a[i] + b[i];
}
}
}
steps 2003-09-28
  • 打赏
  • 举报
回复
服务程序AddServer.java
import ArithApp.*;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;

public class AddServer {

public static void main(String args[]) {
try {
// create and initialize the ORB
ORB orb = ORB.init(args, null);

// create an implementation and register it with the ORB
AddImpl impl = new AddImpl(orb);

// get reference to rootpoa & activate the POAManager
POA rootpoa =
POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();

// get object reference from the servant
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(impl);
Add href = AddHelper.narrow(ref);

// get the root naming context
// NameService invokes the name service
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
// Use NamingContextExt which is part of the Interoperable
// Naming Service (INS) specification.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

// bind the Object Reference in Naming
String name = "Add";
NameComponent path[] = ncRef.to_name(name);
ncRef.rebind(path, href);

System.out.println("AddServer ready to add up your arrays....");

// wait for invocations from clients
orb.run();
} catch (Exception e) {
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
System.out.println("AddServer Exiting ....");
}
}
steps 2003-09-28
  • 打赏
  • 举报
回复
为方便答复,提供服务器端相关文档:
IDL文件如下:
module ArithApp {
interface Add {
const unsigned short SIZE=10;
typedef long array[SIZE];
void addArrays(in array a, in array b,
out array result);
};
};
tcby2000 2003-09-28
  • 打赏
  • 举报
回复
我们做的是这样的。CORBA服务放到TUXETO上,EJB放到WEBLOGIC,TUXETO跟WEBLOGIC之间用WTC连接。前台用STRUTS开发的页面来调用EJB。我想用DELPHI当克户端原理也差不多。

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧