[Portal] with Ruby call ICE interface

sponsored links
Ice is not introduced, http://www.zeroc.com/
Ruby is not introduced.

I try ah, the steps I will be clearly recorded,
One to definitely not let the people Society,
Second, I am afraid I have forgotten the past two days, brain hypoxia, only three days to remember things. . . . . .

Download Ice-3.3.0-VC60.msi

http://www.zeroc.com/download/Ice/3.3/Ice-3.3.0-VC60.msi

ICE From the outset 3.1.1 Supporting the Ruby dynamic language also supports Python, php.

After the download to install, skip.

After installation, please open the installation directory, read the "README.txt", if you feel too tired to read in English do not want to detours, then please carefully read this blog.

First of all, Ice3.3.0 support Ruby is 1.8.6, please confirm.
Secondly, README.txt in and said:

Quote

"You also need to add the Ice bin directory to your PATH, for example:

set PATH = <Ice installation root directory> \ bin;% PATH%

Finally, set RUBYLIB so that the Ruby interpreter is able to load
the Ice extension:

set RUBYLIB = <Ice installation root directory> \ ruby;% RUBYLIB% "

So please in your environment variables to set / increase the above two, do not wrong! ! !

Environment variables you get? Get your IRB try out,

win+r->cmd->irb:
require 'rubygems'
require 'Ice'


Require the implementation of these two after if successful, then congratulations to you, Ice the ruby work environment has been done.

Ice how the job I do not want to go on, Service After the development of client interfaces, using. Ice documents describe interfaces and data formats, and then this. Ice document to the client, the client can go into slice2 **** the appropriate language interface file, loading into account and can use server-side interface and good agreement data.

This article mainly refers to the client how to use ruby invoke server-side interfaces, server-side so we will realize no matter how I put the main server-side code give everyone a look everyone will understand, better than everybody smart Oh my!

The following services are the main client code,
/* This code is to start the Ice, the routine of things  */
	Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("WGSrv","default -p 7788");
// The server port is 7788  
	Ice::ObjectPtr object = new CTestIceImpl();
	adapter->add(object, ic->stringToIdentity("WGInterfaceAgentId"));
	// This is important, the Convention with a card as the client, is used to determine the client calls the server of which ice interface.  
	adapter->activate();

	std::cout << "now server start successfully." << std::endl;

	ic->waitForShutdown();


/* This code is server-side interface implementation,  
* I choose a ping interface for everyone to see,  
* We can see this ping in addition to the Terminal  ( Server-side  ) Output  "ping successfully." This string,  
* A 0 is returned, not doing anything other than that, very simple.  
*/
	int ping(const Ice::Current& = Ice::Current())
	{
		std::cout << "ping successfully." << std::endl;
		return 0;
	}


Above are server things, the following are to visit the Ruby interface methods:

<<COMMENT
 There's something almost all of the routine, you need to implement the code please put somewhere else, you need to load in.  
COMMENT
require 'Ice'
Ice::loadSlice('testice.ice')# The service side to your  .ice Here!  

status = 0
ic = nil
begin
    ic = Ice::initialize(ARGV)
    base = ic.stringToProxy("WGInterfaceAgentId:default -p 7788 -h 10.2.226.8")
# The preceding sentence, please note that server-side one of the words "adapter  ->add(object, ic->stringToIdentity("WGInterfaceAgentId")); ”  
# We mentioned above  "WGInterfaceAgentId" This string is used to identify the destination interface, now with oh.  
    pinger = WG::WGTestIcePrx::checkedCast(base)
    if not pinger
        raise "Invalid proxy"
    end

    pinger.ping()# Only the most useful, others are routine.  
rescue
    puts $!
    puts $!.backtrace.join("\n")
    status = 1
end

if ic
    # Clean up
    begin
        ic.destroy()
    rescue
        puts $!
        puts $!.backtrace.join("\n")
        status = 1
    end
end

exit(status)


Executive about the success.

I did not carefully studied the ICE, there has never been used before this thing, This is the first time, read the documentation under the ZeroC, ask a friend, to complete the call, but there do not understand my problem, Ice provides a tools are slice2 ****, this tool for the static language is used to convert. ice documents to each other's language, but I use dynamic languages such as Ruby interface to call Ice, I found that even if I put the generated files slice2rb document also does not matter deleted, the same call through, I think this may be the use of dynamic languages without a statement of the characteristics of the definition of it, it seems to use Ruby to call Ice interface is too convenient! !

Pro, and would like to thank my buddies: Student crown, Ice Service client interfaces that are easy to write of him.

Had finished.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of [Portal] with Ruby call ICE interface

  • Hibernate configuration parameters hibernate.hbm2ddl.auto

    Hibernate in the configuration file: <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...

  • Build flex + spring + blazeds + hibernate application

    Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...

  • What is the appfuse

    First, Appfuse brief introduction Matt Raible are Appfuse developed a guiding entry-level J2EE framework, how to integrate its popular Spring, Hibernate, ibatis, struts, Xdcolet, junit, etc. give the basic framework of the model, the latest version 1.7 is

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15

  • In the servlet use Bean

    According to Sun's definition, JavaBean is a reusable software components. In fact JavaBean is a Java class, through the package into a property and methods of treatment of a function or a business object, referred to as bean. Because JavaBean is ...

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries