ice安装以及简单使用

ICE(Internet Communications Engine)是一个中间件平台。作为一个高性能的互联网通信平台,ICE包含了很多分层的服务和插件(Plug-ins),并且简单、高效和强大。

ICE当前支持C++、Java、C#、Visual Basic、Python和PHP编程语言,并支持在多种操作系统上运行。更多的操作系统和编程语言将会在以后的发布中支持。

1:下载安装包:http://www.zeroc.com/download.html

2:安装ice并在环境变量中配置ice的安装路径 例如:path=D:\ice\Ice-3.5.1\bin

3:如果进行生成java程序,使用slice2java,出现如下:代表安装成功。

slice2java: error: no input file

Usage: slice2java [options] slice-files...

Options:

-h, --help              Show this message.

-v, --version           Display the Ice version.

-DNAME                  Define NAME as 1.

-DNAME=DEF              Define NAME as DEF.

-UNAME                  Remove any definition for NAME.

-IDIR                   Put DIR in the include file search path.

-E                      Print preprocessor output on stdout.

--output-dir DIR        Create files in the directory DIR.

--tie                   Generate TIE classes.

--impl                  Generate sample implementations.

--impl-tie              Generate sample TIE implementations.

--depend                Generate Makefile dependencies.

--depend-xml            Generate dependencies in XML format.

--list-generated        Emit list of generated files in XML format.

-d, --debug             Print debug messages.

--ice                   Permit `Ice‘ prefix (for building Ice sourc

--underscore            Permit underscores in Slice identifiers.

--checksum CLASS        Generate checksums for Slice definitions in

--stream                Generate marshaling support for public stre

--meta META             Define global metadata directive META.

4:使用ice写一个脚本

module demo {

interface Printer {

void printString(string s);

};

};

文件名为printer.ice

5:转到printer.ice所在目录,使用命令slice2java printer.ice

生成的文件copy到你的编辑器中。

6:引入Ice.jar到你的项目下面,使用你的ice安装时lib下面的Ice.jar。

7:编写服务端和客户端程序

服务端:

package servant;

import Ice.Current;
import demo._PrinterDisp;

public class PrinterI extends _PrinterDisp{

	@Override
	public void printString(String s, Current __current) {
		System.out.println(s);
	}

}
package server;

import servant.PrinterI;

public class Server {
	public static void main(String[] args) {
		int status=0;
		Ice.Communicator ic=null;
		try{
			ic = Ice.Util.initialize(args);
			Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
			Ice.Object object = new PrinterI();
			adapter.add(object, Ice.Util.stringToIdentity("SimplePrinter"));
			adapter.activate();
			ic.waitForShutdown();
		}catch(Ice.LocalException e){
			e.printStackTrace();
			status=1;
		}catch(Exception e){
			System.err.println(e.getMessage());
			status=1;
		}finally{
			if(ic!=null){
				ic.destroy();
			}
			System.exit(status);
		}
	}
}

客户端:

package client;

import demo.PrinterPrx;
import demo.PrinterPrxHelper;

public class Client {

	public static void main(String[] args) {
		int status=0;
		Ice.Communicator ic = null;
		try{
			ic = Ice.Util.initialize();
			Ice.ObjectPrx base = ic.stringToProxy("SimplePrinter:default  -p 10000");
			PrinterPrx printer = PrinterPrxHelper.checkedCast(base);
			if(printer==null){
				throw new Error("null proxy");
			}
			printer.printString("hello world!");
		}catch(Ice.LocalException e){
			e.printStackTrace();
			status=1;
		}catch(Exception e){
			System.err.println(e.getMessage());
			status=1;
		}finally{
			if(ic!=null){
				ic.destroy();
			}
			System.exit(status);
		}
	}

}

8:先执行服务端,后执行客户端。互相通信。

时间: 2024-08-29 06:37:08

ice安装以及简单使用的相关文章

python requests的安装与简单运用

requests是Python的一个HTTP客户端库,跟urllib,urllib2类似,那为什么要用requests而不用urllib2呢?官方文档中是这样说明的: python的标准库urllib2提供了大部分需要的HTTP功能,但是API太逆天了,一个简单的功能就需要一大堆代码. 我也看了下requests的文档,确实很简单,适合我这种懒人.下面就是一些简单指南. 插播个好消息!刚看到requests有了中文翻译版,建议英文不好的看看,内容也比我的博客好多了,具体链接是:http://cn

saltstack安装和简单配置(一)

saltstack 安装和简单配置 在安装前,写了好多废话,都被我删除了,下面就开始搞吧. 环境: master:10.70.36.110 minion:10.70.36.103 一.安装: 现在centos下的yum源内有最新的salt-master源码包,安装的话,直接     yum -y install salt-master   #服务端         yum -y install salt-minion   #客户端 要使用yum安装,必须配置好epel源,可参考:        

Redis安装及简单测试

题目链接:11645 - Bits 题意:给定一个数字n,要求0-n的二进制形式下,连续11的个数. 思路:和 UVA 11038 这题类似,枚举中间,然后处理两边的情况. 不过本题最大的答案会超过longlong,要用高精度,不过借鉴http://www.cnblogs.com/TO-Asia/p/3214706.html这个人的方法,直接用两个数字来保存一个数字,这样能保存到2个longlong的长度,就足够存放这题的答案了. 代码: #include <stdio.h> #include

memcache的windows下的安装和简单使用

原文:memcache的windows下的安装和简单使用 memcache是为了解决网站访问量大,数据库压力倍增的解决方案之一,由于其简单实用,很多站点现在都在使用memcache,但是memcache缺点之一却是缺少安全性验证,所以一般而言我们都会把一些访问量大,但是不需要验证的数据放在这里,需要用的时候来这里取,就给数据库减少了很多的负担.一般而言设定个更新时间就好了,1个小时左右更新一次. windows下安装和测试memcache最为方便,Linux只是需要相应的编译包就行了,需要包括m

TFS 2010 让安装更简单,也让VSS成为历史

一转眼VS 2010 RC(Release Candidate)版本号已经公布一月多了,RTM(Release To Manufacturer)版本号也快妥了,已经进入了最后的倒计时,仅仅等4月12号公布了.TFS 2010也将一起正式公布,相对于2005和2008,2010将是具有里程碑意义的一个版本号,就像它总设计师Brian Harry在以下的Channel 9採訪中所描写叙述的:“TFS 2005是TFS 1.0版,2008则是1.5,而2010则是2.0版”. Brian Harry:

puppet yum安装配置,简单证书维护

Puppet学习之puppet的安装和配置 一.Puppet简介 Puppet基于ruby语言开发的自动化系统配置工具,可以C/S模式或独立运行,支持对所有UNIX及类UNIX系统的配置管理,最新版本也开始支持对Windows操作系统有限的一些管理.Puppet适用于服务器管的整个过程 ,比如初始安装.配置更新以及系统下线. 二.Puppet的安装 Puppet的安装方式支持源码安装.yum安装以及ruby的gem安装.官网推荐使用yum来安装puppet,方面以后的升级.管理.维护.Cento

&lt;转载&gt; FreeNAS的安装和简单配置 http://freenas.cn/?p=342

前些日子在公司搭了一个模拟生产环境的平台.由于是测试环境,资源有限只能使用虚拟机实现,所以存储这块就想到了使用FreeNAS.很早以前玩儿过几次,当时是生产环境需要上存储设备,经过对比还是选择的更可靠的NetApp的存储设备.目前FreeNAS最新版本到了0.7.3514,下载地址是 http://www.freenas.cn/?page_id=9 .借用FreeNAS官方网站对它的描述:FreeNAS是一套免费的NAS服务器,它能将一部普通PC变成网络存储服务器.该软件基于FreeBSD,Sa

Linux libusb 安装及简单使用

Linux libusb 安装及简单使用 一.参考文档: 1. libusb1 fails do_configure task with “udev support requested but libudev not installed” http://stackoverflow.com/questions/23712859/libusb1-fails-do-configure-task-with-udev-support-requested-but-libudev-not-ins 2. lib

SecureCRT的安装与简单使用

一.SecureCRT简介 SecureCRT是一款支持SSH/Telent/rlogin协议的终端仿真程序.该软件最初开发在Windows平台下,后来有增加了对 Mac OS X.Linux的支持. SecureCRT可以轻松的通过Windows往Linux系统上传输文件,通过内置的VCP命令程序能够对传输的文件进行加密. SecureCRT也可以通过该软件对Linux的终端进行各种操作,有时你需要远程对某台机器进行开发测试,你也通过这个软件连接到该机器的IP地址,而不需要你亲自去使用该机器.