ICE - 企业使用的工具

来源:互联网 发布:淘宝嘉联华 编辑:程序博客网 时间:2024/05/17 22:02

zeroc ice,简称ice,是指ZeroC公司的ICE(Internet Communications Engine)中间件平台。对于客户端和服务端程序的开发提供了很大的便利。

外文名 定义 ICE平台包括 支持语言 zeroc ice 指ZeroC公司的ICE Ice,Ice-E,Ice Touch C++,Java,C#,Python,Ruby,PHP和ActionScript

简介

ZeroC ICE 是指ZeroC公司的ICE(Internet Communications Engine)中间件平台。对于客户端和服务端程序的开发提供了很大的便利。
目前ICE平台中包括Ice,Ice-E,Ice Touch。
Ice为主流平台设计,包括Windows和Linux,支持广泛的语言,包括C++,Java,C#(和其他.Net的语言,例如Visual Basic),Python,Ruby,PHP和ActionScript。也包括所有的ICE服务,例如Ice Grid,IceStorm等。
Ice-E是Ice在资源受限的平台上的一个实现,支持C++和嵌入式操作系统,例如Windows CE,Linux。Ice-E本身不包含任何服务,但是可以利用在Ice上提供的各种服务。因此,通过Ice-E,移动设备也能无缝的集成到分布式系统中。
Ice Touch是为iphone和ipod touch开发的版本,包括Object-C映射,支持Iphone OS,并为MAC OS X开发图形界面应用程序提供完整的Cocoa框架的访问。1

使用样例

你可以在官方网站下载到ice-3.6.1。在安装目录即可找到一个官方提供的Demo包。具体使用可参考“官方网站2 ”中的内容。

正文

不说废话,其实我也不太懂这个ICE的,在我公司使用到了它来激活某个服务

》监听器

public class ComponentServerListener implements ServletContextListener {    private static Logger log = LoggerFactory.getLogger(ComponentServerListener.class);    public static Thread thread = null;    public void contextInitialized(ServletContextEvent arg0) {        log.info("ComponentServerListener启动");        if (thread == null) {            thread = new Thread(new Runnable() {                public void run() {                    ComponentServer iceServer = new ComponentServer();                    iceServer.start();                }            });            thread.start();        }        log.info("ComponentServerListener启动完成");    }    public void contextDestroyed(ServletContextEvent arg0) {        log.info("ComponentServerListener销毁");        if (thread != null) {            thread.interrupt();        }        log.info("ComponentServerListener销毁完成");    }}

》服务器

public class ComponentServer {    private static Logger log = LoggerFactory.getLogger(ComponentServer.class);    private Communicator communicator = null;    private ObjectAdapter objectAdapter = null;    private ServantLocator servantLocator = null;    public static void main(String[] args) {        ComponentServer iceServer = new ComponentServer();        log.info("开始启动组件服务器...");        iceServer.start();    }    public void start() {        long startTime = (new Date()).getTime();        log.info("组件服务器启动开始:{}", DateKit.formatDate(startTime, "yyyy-MM-dd HH:mm:ss.SS"));        Properties prop = Util.createProperties();        Map config = PropertiesKit.getBundleAllProperties("config/component_server_config");        Iterator initData = config.keySet().iterator();        String adapterId;        while (initData.hasNext()) {            adapterId = (String) initData.next();            prop.setProperty(adapterId, (String) config.get(adapterId));        }        log.info("组件服务器运行环境配置:", config);        InitializationData initData1 = new InitializationData();        initData1.properties = prop;        this.communicator = Util.initialize(initData1);        log.info("组件服务器Communicator对象成功.");        adapterId = (String) config.get("Server.AdapterId");        String endPoint = (String) config.get("Server.EndPoint");        log.info("组件服务器当前使用适配器Id[{}], 监听请求端点[{}]", adapterId, endPoint);        this.objectAdapter = this.communicator.createObjectAdapterWithEndpoints(adapterId, endPoint);        this.servantLocator = new ComponentServantLocator();        this.objectAdapter.addServantLocator(this.servantLocator, "");        this.objectAdapter.activate();        String threadName = String.valueOf(System.identityHashCode(this));        log.info("组件服务器启动线程[{}]", threadName);        log.info("组件服务器启动成功!");        long endTime = (new Date()).getTime();        log.info("组件服务器启动完成:{}", DateKit.formatDate(endTime, "yyyy-MM-dd HH:mm:ss.SS"));        log.info("本次启动耗时:{} ms", Long.valueOf(endTime - startTime));        Thread.currentThread().setName(threadName);        String initDBFactory = (String) config.get("Server.initDBFactory");        if (initDBFactory.equals("true")) {            ComponentDBFactory.init();        }    }}

有经验的人欢迎评论分享下知识啊,另外转载一个很久以前的文章:http://blog.csdn.net/god_wot/article/details/50332997


  1. An Overview of the Ice Platform ↩
  2. 官方网站 ↩
1 0
原创粉丝点击