SlideShare a Scribd company logo
1 of 23
Download to read offline
Getting start

ICE MINI GUIDE

                 Ady@SOHU 2012/02/28
What is ICE?

   The Internet Communications Engine
     An   object-oriented distributed middleware platform.
ICE Content
 object-oriented RPC mechanism
 language-neutral specification language (Slice)
 language mappings for various languages
 support for different transports (TCP, SSL, UDP)
  with highly-efficient protocol
 external services (server activation, firewall
  traversal, etc.)
 integrated persistence (Freeze)
 threading support
Client and Server Structure

         Client Application                                   Server Application




 Proxy                                                            Skeleton         Object
                                Ice API             Ice API
 Code                                                                              Adapter


              Client Ice Core                                  Server Ice Core
                                          Network




    Ice API

   Generated Code
What is slice?

 language-independent types
 a compiler creates language-specific source
  code
 only type definitions without statements

 define operations and exchange type defined
Java Programming Model
Basic Slice Types


 Type     Range of Mapped Type       Size of Mapped Type
 bool     false or true              ≥ 1 bits
 byte     -128-127 or 0-255          ≥ 8 bits
 short    -215 to 215-1              ≥ 16 bits
 int      -231 to 231-1              ≥ 32 bits
 long     -263 to 263-1              ≥ 64 bits
 float    IEEE single-precision      ≥ 32 bits
 double   IEEE double-precision      ≥ 64 bits
 string   Unicode (UTF-8 for java)   Variable-length
Enumerations
enum CounterType {
   BLOG,
   ALBUM,
   FEED,
   GUEST
};


Rules
   • Like Java Enum
   • Cannot specify the value
   • Empty enumerations are illegal
Structures

struct TimeOfDay {
     short hour;   // 0-23
     short minute; // 0-59
     short second; // 0-59
};
Sequences

   sequences<AccountIndex> AccountIndexList;

 Default Type(Arrays): AccountIndex[]
 Define other types (ArrayList/LinkedList)
    ["java:type:java.util.ArrayList"]
    sequences<AccountIndex> AccountIndexList;
Dictionaries
   dictionary<string,string> AccountCacheMap;
   dictionary<string,AccountCacheMap> AccountCacheMapMap;

   Default type: java.util.HashMap

   The key rule:
       An integral type (bool, byte, short, int, long, enum) or string
       A structure containing only members of integral type or type string
Interfaces
dictionary<string,string> AccountCacheMap;
dictionary<string,AccountCacheMap> AccountCacheMapMap;
["java:type:java.util.ArrayList"] sequence<string> StringList;

interface AccountCacheService {

     AccountCacheMap get(string passport);
     AccountCacheMapMap gets(StringList passports);

};
Interfaces Operations And Parameters

   rules
     an operation name
     a return type (or void if none)

     zero or more parameters

     an optional exception specification

     operation cannot be overloaded
A SIMPLE DEMO
Step 1: write a slice file
module sce{
   module demo{
      interface CounterService{
         int incr();
         int decr();
         int get();
         void set(int num);
      };
   };
};
Step 2: slice2java
slice2java demo.ice
C:Usersxylzworkspacesce-demo>ll sce-demo
-rw-rw-rw- 1 user group      1089 Feb 28 16:34 Callback_CounterService_decr.java
-rw-rw-rw- 1 user group      1086 Feb 28 16:34 Callback_CounterService_get.java
-rw-rw-rw- 1 user group      1089 Feb 28 16:34 Callback_CounterService_incr.java
-rw-rw-rw- 1 user group      639 Feb 28 16:34 Callback_CounterService_set.java
-rw-rw-rw- 1 user group      697 Feb 28 16:34 CounterService.java
-rw-rw-rw- 1 user group      1149 Feb 28 16:34 CounterServiceHolder.java
-rw-rw-rw- 1 user group      3112 Feb 28 16:34 CounterServicePrx.java
-rw-rw-rw- 1 user group     17744 Feb 28 16:34 CounterServicePrxHelper.java
-rw-rw-rw- 1 user group      808 Feb 28 16:34 CounterServicePrxHolder.java
-rw-rw-rw- 1 user group      1034 Feb 28 16:34 _CounterServiceDel.java
-rw-rw-rw- 1 user group      7998 Feb 28 16:34 _CounterServiceDelD.java
-rw-rw-rw- 1 user group      5642 Feb 28 16:34 _CounterServiceDelM.java
-rw-rw-rw- 1 user group      6210 Feb 28 16:34 _CounterServiceDisp.java
-rw-rw-rw- 1 user group      769 Feb 28 16:34 _CounterServiceOperations.java
-rw-rw-rw- 1 user group      687 Feb 28 16:34 _CounterServiceOperationsNC.java
Step 3: write a server
package sce.demo.server;

import java.util.concurrent.atomic.AtomicInteger;
import Ice.Current;
import sce.demo._CounterServiceDisp;

public class CounterServiceI extends _CounterServiceDisp {

    final AtomicInteger counter = new AtomicInteger(0);

    public int incr(Current __current) { return counter.incrementAndGet(); }
    public int decr(Current __current) {return counter.decrementAndGet();}
    public int get(Current __current) {return counter.get();}
    public void set(int num, Current __current) {counter.set(num); }
}
Step 4: start the server
package sce.demo.server;

public class Server {

    public static void main(String[] args) throws Exception {
     Ice.Communicator ic = null;
     try {
       ic = Ice.Util.initialize(args);
         Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints("Demo", "default -p 2012");
          adapter.add(new CounterServiceI(), ic.stringToIdentity("Counter"));
          adapter.activate();
          ic.waitForShutdown();
        } finally {
          if (ic != null) ic.destroy();
        }
    }
}
Step 5: write a client
package sce.demo.client;

import sce.demo.CounterServicePrx;
import sce.demo.CounterServicePrxHelper;

public class Client {

    public static void main(String[] args) {
      Ice.Communicator ic = null;
      try {
          ic = Ice.Util.initialize(args);
          Ice.ObjectPrx base = ic.stringToProxy("Counter:default -p 2012");
          CounterServicePrx counter = CounterServicePrxHelper.checkedCast(base);
          //
          final int initValue = 100;
          counter.set(initValue);
          System.out.println((initValue+1)+" => "+counter.incr());     101 => 101
          System.out.println((initValue+1)+" => "+counter.get());      101 => 101
          System.out.println((initValue)+" => "+counter.decr());
      } finally {
                                                                       100 => 100
          if (ic != null) ic.destroy();
      }
    }
}
Common Steps

1.   write the slice files
2.   convert slice to java source files (slice2java)
3.   write the server (active the object)
4.   write the client
Source Code

   git
     git   clone git@github.com:adyliu/sce-demo.git
   web
     https://github.com/adyliu/sce-demo
Multi-language supported
Next



 SCE full samples with Protocol Buffers
 ICE more advanced topic

More Related Content

What's hot

Python twisted
Python twistedPython twisted
Python twistedMahendra M
 
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016Susan Potter
 
C#을 이용한 task 병렬화와 비동기 패턴
C#을 이용한 task 병렬화와 비동기 패턴C#을 이용한 task 병렬화와 비동기 패턴
C#을 이용한 task 병렬화와 비동기 패턴명신 김
 
Apache zookeeper 101
Apache zookeeper 101Apache zookeeper 101
Apache zookeeper 101Quach Tung
 
Cassandra summit 2013 - DataStax Java Driver Unleashed!
Cassandra summit 2013 - DataStax Java Driver Unleashed!Cassandra summit 2013 - DataStax Java Driver Unleashed!
Cassandra summit 2013 - DataStax Java Driver Unleashed!Michaël Figuière
 
What is the ServiceStack?
What is the ServiceStack?What is the ServiceStack?
What is the ServiceStack?Demis Bellot
 
Non blocking io with netty
Non blocking io with nettyNon blocking io with netty
Non blocking io with nettyZauber
 
Kubernetes networking - basics
Kubernetes networking - basicsKubernetes networking - basics
Kubernetes networking - basicsJuraj Hantak
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019GOG.com dev team
 
Paris Cassandra Meetup - Cassandra for Developers
Paris Cassandra Meetup - Cassandra for DevelopersParis Cassandra Meetup - Cassandra for Developers
Paris Cassandra Meetup - Cassandra for DevelopersMichaël Figuière
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Joe Arnold
 
OpenStack Neutron Reverse Engineered
OpenStack Neutron Reverse EngineeredOpenStack Neutron Reverse Engineered
OpenStack Neutron Reverse Engineeredopenstackindia
 
Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akkanartamonov
 
Http4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web StackHttp4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web StackGaryCoady
 
Securing your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris KelloggSecuring your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris KelloggStreamNative
 

What's hot (20)

Python twisted
Python twistedPython twisted
Python twisted
 
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
 
Reactive server with netty
Reactive server with nettyReactive server with netty
Reactive server with netty
 
C#을 이용한 task 병렬화와 비동기 패턴
C#을 이용한 task 병렬화와 비동기 패턴C#을 이용한 task 병렬화와 비동기 패턴
C#을 이용한 task 병렬화와 비동기 패턴
 
Forgive me for i have allocated
Forgive me for i have allocatedForgive me for i have allocated
Forgive me for i have allocated
 
Apache zookeeper 101
Apache zookeeper 101Apache zookeeper 101
Apache zookeeper 101
 
Cassandra summit 2013 - DataStax Java Driver Unleashed!
Cassandra summit 2013 - DataStax Java Driver Unleashed!Cassandra summit 2013 - DataStax Java Driver Unleashed!
Cassandra summit 2013 - DataStax Java Driver Unleashed!
 
What is the ServiceStack?
What is the ServiceStack?What is the ServiceStack?
What is the ServiceStack?
 
Non blocking io with netty
Non blocking io with nettyNon blocking io with netty
Non blocking io with netty
 
Kubernetes networking - basics
Kubernetes networking - basicsKubernetes networking - basics
Kubernetes networking - basics
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
 
Paris Cassandra Meetup - Cassandra for Developers
Paris Cassandra Meetup - Cassandra for DevelopersParis Cassandra Meetup - Cassandra for Developers
Paris Cassandra Meetup - Cassandra for Developers
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012
 
OpenStack Neutron Reverse Engineered
OpenStack Neutron Reverse EngineeredOpenStack Neutron Reverse Engineered
OpenStack Neutron Reverse Engineered
 
Docker and Fargate
Docker and FargateDocker and Fargate
Docker and Fargate
 
Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akka
 
GCD and OperationQueue.
GCD and OperationQueue.GCD and OperationQueue.
GCD and OperationQueue.
 
Http4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web StackHttp4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web Stack
 
Securing your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris KelloggSecuring your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris Kellogg
 

Similar to Ice mini guide

Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsScala Italy
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSAlberto Paro
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayLuka Zakrajšek
 
Logisland "Event Mining at scale"
Logisland "Event Mining at scale"Logisland "Event Mining at scale"
Logisland "Event Mining at scale"Thomas Bailet
 
Getting Started with Datatsax .Net Driver
Getting Started with Datatsax .Net DriverGetting Started with Datatsax .Net Driver
Getting Started with Datatsax .Net DriverDataStax Academy
 
Apache Spark Streaming: Architecture and Fault Tolerance
Apache Spark Streaming: Architecture and Fault ToleranceApache Spark Streaming: Architecture and Fault Tolerance
Apache Spark Streaming: Architecture and Fault ToleranceSachin Aggarwal
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileAmazon Web Services Japan
 
Scorex, the Modular Blockchain Framework
Scorex, the Modular Blockchain FrameworkScorex, the Modular Blockchain Framework
Scorex, the Modular Blockchain FrameworkAlex Chepurnoy
 
SQL Server Security - Attack
SQL Server Security - Attack SQL Server Security - Attack
SQL Server Security - Attack webhostingguy
 
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at NetflixOSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at NetflixManish Pandit
 
540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdfhamzadamani7
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swiftTim Burks
 
Rider - Taking ReSharper out of Process
Rider - Taking ReSharper out of ProcessRider - Taking ReSharper out of Process
Rider - Taking ReSharper out of Processcitizenmatt
 
El camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - IntroductionEl camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - IntroductionPlain Concepts
 
Cassandra Day NY 2014: Getting Started with the DataStax C# Driver
Cassandra Day NY 2014: Getting Started with the DataStax C# DriverCassandra Day NY 2014: Getting Started with the DataStax C# Driver
Cassandra Day NY 2014: Getting Started with the DataStax C# DriverDataStax Academy
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffJAX London
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsSebastian Springer
 

Similar to Ice mini guide (20)

Scala at Netflix
Scala at NetflixScala at Netflix
Scala at Netflix
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and Play
 
Logisland "Event Mining at scale"
Logisland "Event Mining at scale"Logisland "Event Mining at scale"
Logisland "Event Mining at scale"
 
Getting Started with Datatsax .Net Driver
Getting Started with Datatsax .Net DriverGetting Started with Datatsax .Net Driver
Getting Started with Datatsax .Net Driver
 
Apache Spark Streaming: Architecture and Fault Tolerance
Apache Spark Streaming: Architecture and Fault ToleranceApache Spark Streaming: Architecture and Fault Tolerance
Apache Spark Streaming: Architecture and Fault Tolerance
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
Scorex, the Modular Blockchain Framework
Scorex, the Modular Blockchain FrameworkScorex, the Modular Blockchain Framework
Scorex, the Modular Blockchain Framework
 
SQL Server Security - Attack
SQL Server Security - Attack SQL Server Security - Attack
SQL Server Security - Attack
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at NetflixOSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
 
540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swift
 
Rider - Taking ReSharper out of Process
Rider - Taking ReSharper out of ProcessRider - Taking ReSharper out of Process
Rider - Taking ReSharper out of Process
 
El camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - IntroductionEl camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - Introduction
 
Cassandra Day NY 2014: Getting Started with the DataStax C# Driver
Cassandra Day NY 2014: Getting Started with the DataStax C# DriverCassandra Day NY 2014: Getting Started with the DataStax C# Driver
Cassandra Day NY 2014: Getting Started with the DataStax C# Driver
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 

Recently uploaded

Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringWSO2
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceIES VE
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....rightmanforbloodline
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 

Recently uploaded (20)

Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 

Ice mini guide

  • 1. Getting start ICE MINI GUIDE Ady@SOHU 2012/02/28
  • 2. What is ICE?  The Internet Communications Engine  An object-oriented distributed middleware platform.
  • 3. ICE Content  object-oriented RPC mechanism  language-neutral specification language (Slice)  language mappings for various languages  support for different transports (TCP, SSL, UDP) with highly-efficient protocol  external services (server activation, firewall traversal, etc.)  integrated persistence (Freeze)  threading support
  • 4. Client and Server Structure Client Application Server Application Proxy Skeleton Object Ice API Ice API Code Adapter Client Ice Core Server Ice Core Network Ice API Generated Code
  • 5. What is slice?  language-independent types  a compiler creates language-specific source code  only type definitions without statements  define operations and exchange type defined
  • 7. Basic Slice Types Type Range of Mapped Type Size of Mapped Type bool false or true ≥ 1 bits byte -128-127 or 0-255 ≥ 8 bits short -215 to 215-1 ≥ 16 bits int -231 to 231-1 ≥ 32 bits long -263 to 263-1 ≥ 64 bits float IEEE single-precision ≥ 32 bits double IEEE double-precision ≥ 64 bits string Unicode (UTF-8 for java) Variable-length
  • 8. Enumerations enum CounterType { BLOG, ALBUM, FEED, GUEST }; Rules • Like Java Enum • Cannot specify the value • Empty enumerations are illegal
  • 9. Structures struct TimeOfDay { short hour; // 0-23 short minute; // 0-59 short second; // 0-59 };
  • 10. Sequences  sequences<AccountIndex> AccountIndexList;  Default Type(Arrays): AccountIndex[]  Define other types (ArrayList/LinkedList) ["java:type:java.util.ArrayList"] sequences<AccountIndex> AccountIndexList;
  • 11. Dictionaries  dictionary<string,string> AccountCacheMap;  dictionary<string,AccountCacheMap> AccountCacheMapMap;  Default type: java.util.HashMap  The key rule:  An integral type (bool, byte, short, int, long, enum) or string  A structure containing only members of integral type or type string
  • 12. Interfaces dictionary<string,string> AccountCacheMap; dictionary<string,AccountCacheMap> AccountCacheMapMap; ["java:type:java.util.ArrayList"] sequence<string> StringList; interface AccountCacheService { AccountCacheMap get(string passport); AccountCacheMapMap gets(StringList passports); };
  • 13. Interfaces Operations And Parameters  rules  an operation name  a return type (or void if none)  zero or more parameters  an optional exception specification  operation cannot be overloaded
  • 15. Step 1: write a slice file module sce{ module demo{ interface CounterService{ int incr(); int decr(); int get(); void set(int num); }; }; };
  • 16. Step 2: slice2java slice2java demo.ice C:Usersxylzworkspacesce-demo>ll sce-demo -rw-rw-rw- 1 user group 1089 Feb 28 16:34 Callback_CounterService_decr.java -rw-rw-rw- 1 user group 1086 Feb 28 16:34 Callback_CounterService_get.java -rw-rw-rw- 1 user group 1089 Feb 28 16:34 Callback_CounterService_incr.java -rw-rw-rw- 1 user group 639 Feb 28 16:34 Callback_CounterService_set.java -rw-rw-rw- 1 user group 697 Feb 28 16:34 CounterService.java -rw-rw-rw- 1 user group 1149 Feb 28 16:34 CounterServiceHolder.java -rw-rw-rw- 1 user group 3112 Feb 28 16:34 CounterServicePrx.java -rw-rw-rw- 1 user group 17744 Feb 28 16:34 CounterServicePrxHelper.java -rw-rw-rw- 1 user group 808 Feb 28 16:34 CounterServicePrxHolder.java -rw-rw-rw- 1 user group 1034 Feb 28 16:34 _CounterServiceDel.java -rw-rw-rw- 1 user group 7998 Feb 28 16:34 _CounterServiceDelD.java -rw-rw-rw- 1 user group 5642 Feb 28 16:34 _CounterServiceDelM.java -rw-rw-rw- 1 user group 6210 Feb 28 16:34 _CounterServiceDisp.java -rw-rw-rw- 1 user group 769 Feb 28 16:34 _CounterServiceOperations.java -rw-rw-rw- 1 user group 687 Feb 28 16:34 _CounterServiceOperationsNC.java
  • 17. Step 3: write a server package sce.demo.server; import java.util.concurrent.atomic.AtomicInteger; import Ice.Current; import sce.demo._CounterServiceDisp; public class CounterServiceI extends _CounterServiceDisp { final AtomicInteger counter = new AtomicInteger(0); public int incr(Current __current) { return counter.incrementAndGet(); } public int decr(Current __current) {return counter.decrementAndGet();} public int get(Current __current) {return counter.get();} public void set(int num, Current __current) {counter.set(num); } }
  • 18. Step 4: start the server package sce.demo.server; public class Server { public static void main(String[] args) throws Exception { Ice.Communicator ic = null; try { ic = Ice.Util.initialize(args); Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints("Demo", "default -p 2012"); adapter.add(new CounterServiceI(), ic.stringToIdentity("Counter")); adapter.activate(); ic.waitForShutdown(); } finally { if (ic != null) ic.destroy(); } } }
  • 19. Step 5: write a client package sce.demo.client; import sce.demo.CounterServicePrx; import sce.demo.CounterServicePrxHelper; public class Client { public static void main(String[] args) { Ice.Communicator ic = null; try { ic = Ice.Util.initialize(args); Ice.ObjectPrx base = ic.stringToProxy("Counter:default -p 2012"); CounterServicePrx counter = CounterServicePrxHelper.checkedCast(base); // final int initValue = 100; counter.set(initValue); System.out.println((initValue+1)+" => "+counter.incr()); 101 => 101 System.out.println((initValue+1)+" => "+counter.get()); 101 => 101 System.out.println((initValue)+" => "+counter.decr()); } finally { 100 => 100 if (ic != null) ic.destroy(); } } }
  • 20. Common Steps 1. write the slice files 2. convert slice to java source files (slice2java) 3. write the server (active the object) 4. write the client
  • 21. Source Code  git  git clone git@github.com:adyliu/sce-demo.git  web  https://github.com/adyliu/sce-demo
  • 23. Next  SCE full samples with Protocol Buffers  ICE more advanced topic