ICE学习笔记一----运行官方的java版demo程序

建议新手和我一样,从官网下载英文文档,开个有道词典,慢慢啃。大笑

官方文档下载:

http://download.csdn.net/detail/xiong_mao_1/6300631


程序代码就不说了,我照抄文档的,以下都是个人笔记。


slice2java后,生成了这些文档,具体每个文件的含义有得学习,先mark个。


我是在eclipse中运行的,


结果图!嘿嘿,小兴奋中~~



eclipse工程打包下载:

http://download.csdn.net/detail/xiong_mao_1/6300697


关于客户端代码一个知识点:

源码:

Ice.ObjectPrx base = ic.stringToProxy("SimplePrinter:default -p 10000");
PrinterPrx printer = PrinterPrxHelper.checkedCast(base);


官方文档解释:

The proxy returned by sringToProxy is of type Ice.ObjectPrx,which is at the root of the inheritance tree for interfaces and classes. But to actually talk to our printer, we need a proxy for aPrinterinterface, not anObject interface. To do this,we need to do adown-cast by callingPrinterPrxHelper.checkedCast.A checked cast sends a message to the server, effectively asking “is this aproxy for a Printer interface?” If so, the call returns a proxy of typeDemo::Printer; otherwise, if the proxy denotes an interface of some other type,the call returns null.



原文地址:https://www.cnblogs.com/ycpanda/p/3637262.html