summaryrefslogtreecommitdiff
path: root/java/demo/Ice
diff options
context:
space:
mode:
Diffstat (limited to 'java/demo/Ice')
-rw-r--r--java/demo/Ice/README5
-rw-r--r--java/demo/Ice/applet/HelloApplet.java18
-rw-r--r--java/demo/Ice/applet/README75
-rw-r--r--java/demo/Ice/applet/build.xml4
-rw-r--r--java/demo/Ice/applet/hello.html6
-rw-r--r--java/demo/Ice/build.xml2
-rw-r--r--java/demo/Ice/callback/CallbackSenderI.java2
-rw-r--r--java/demo/Ice/nested/NestedI.java2
-rw-r--r--java/demo/Ice/protobuf/Client.java127
-rw-r--r--java/demo/Ice/protobuf/Hello.ice27
-rw-r--r--java/demo/Ice/protobuf/HelloI.java26
-rw-r--r--java/demo/Ice/protobuf/Person.proto18
-rw-r--r--java/demo/Ice/protobuf/README41
-rw-r--r--java/demo/Ice/protobuf/Server.java37
-rw-r--r--java/demo/Ice/protobuf/ant/ProtocTask.java367
-rw-r--r--java/demo/Ice/protobuf/build.xml63
-rw-r--r--java/demo/Ice/protobuf/config.client23
-rw-r--r--java/demo/Ice/protobuf/config.server24
-rwxr-xr-xjava/demo/Ice/protobuf/expect.py30
-rw-r--r--java/demo/Ice/serialize/Client.java142
-rw-r--r--java/demo/Ice/serialize/Demo/MyGreeting.java15
-rw-r--r--java/demo/Ice/serialize/Greet.ice26
-rw-r--r--java/demo/Ice/serialize/GreetI.java33
-rw-r--r--java/demo/Ice/serialize/README37
-rw-r--r--java/demo/Ice/serialize/Server.java37
-rw-r--r--java/demo/Ice/serialize/build.xml52
-rw-r--r--java/demo/Ice/serialize/config.client28
-rw-r--r--java/demo/Ice/serialize/config.server29
-rwxr-xr-xjava/demo/Ice/serialize/expect.py30
-rw-r--r--java/demo/Ice/value/Client.java6
30 files changed, 1294 insertions, 38 deletions
diff --git a/java/demo/Ice/README b/java/demo/Ice/README
index 6a9eceee376..5714a88aa20 100644
--- a/java/demo/Ice/README
+++ b/java/demo/Ice/README
@@ -52,6 +52,11 @@ Demos in this directory:
A demo to illustrate how nested callbacks work, and how the size of
the thread pool affects the maximum nesting depth.
+- serialize
+
+ This demo illustrates how to transfer serializable Java classes
+ with Ice.
+
- session
This demo shows how to use sessions to clean up client-specific
diff --git a/java/demo/Ice/applet/HelloApplet.java b/java/demo/Ice/applet/HelloApplet.java
index 504f775a148..dd351a7918d 100644
--- a/java/demo/Ice/applet/HelloApplet.java
+++ b/java/demo/Ice/applet/HelloApplet.java
@@ -46,24 +46,10 @@ public class HelloApplet extends JApplet
initData.properties.setProperty("Ice.Trace.Network", "3");
initData.properties.setProperty("IceSSL.Trace.Security", "3");
initData.properties.setProperty("IceSSL.Password", "password");
- initData.properties.setProperty("Ice.InitPlugins", "0");
+ initData.properties.setProperty("IceSSL.Keystore", "client.jks");
+ initData.properties.setProperty("IceSSL.Truststore", "client.jks");
initData.properties.setProperty("Ice.Plugin.IceSSL", "IceSSL.PluginFactory");
_communicator = Ice.Util.initialize(initData);
-
- //
- // We delayed the initialization of the IceSSL plug-in by setting Ice.InitPlugins=0.
- // Now we obtain a reference to the plugin so that we can supply a keystore and
- // truststore using a resource file.
- //
- IceSSL.Plugin plugin = (IceSSL.Plugin)_communicator.getPluginManager().getPlugin("IceSSL");
- java.io.InputStream certs = getClass().getClassLoader().getResourceAsStream("client.jks");
- plugin.setKeystoreStream(certs);
- plugin.setTruststoreStream(certs);
-
- //
- // Finally, we're ready to complete the initialization.
- //
- _communicator.getPluginManager().initializePlugins();
}
catch(Throwable ex)
{
diff --git a/java/demo/Ice/applet/README b/java/demo/Ice/applet/README
index dbf2e18ff20..9bda261e7c3 100644
--- a/java/demo/Ice/applet/README
+++ b/java/demo/Ice/applet/README
@@ -1,8 +1,15 @@
+Introduction
+------------
+
This demo presents an unsigned applet that shows how to make
asynchronous Ice invocations in a graphical application. It also
demonstrates how to configure IceSSL using a resource file as the
keystore.
+
+Preparing the applet
+--------------------
+
The demo includes a start page (hello.html) that you will need to
publish on a web server. This page assumes that the demo applet is
stored in a fully self-contained archive named Hello.jar. In order to
@@ -11,7 +18,7 @@ with ProGuard in your CLASSPATH. After a successful build, copy
Hello.jar from this subdirectory to the same directory as hello.html
on your web server.
-NOTE: We recommend using ProGuard 4.3 or later.
+NOTE: If you use ProGuard, you must use version 4.3 or later.
If you did not build the applet with ProGuard in your CLASSPATH, the
Hello.jar archive contains only the applet classes. In this case you
@@ -26,19 +33,63 @@ applet with the following commands:
ant clean
ant
-To run the demo, you must start a "hello" server on the web server
-host. You can use the hello server from the ../hello directory or
-a hello server from any other Ice language mapping. Note that you may
-need to temporarily relax the firewall restrictions on your web server
-host to allow the applet to establish connections to the hello server.
-Next, start a web browser and open the hello.html page on your web
-server.
+
+Preparing the Ice server
+------------------------
+
+The applet requires a "hello" server. You can use the Java server
+from the ../hello directory or a hello server from any other Ice
+language mapping. You may need to temporarily relax the firewall
+restrictions on your server host to allow the applet to establish
+connections to the hello server.
+
+
+Loading the applet locally
+--------------------------
+
+The simplest way to use the applet is to open the start page
+(hello.html) as a local file directly from your browser. In this case,
+you must start the hello server on the same host and enter "localhost"
+or "127.0.0.1" as the server host name in the applet.
+
+Note however that the applet security manager in some versions of Java
+may prevent the applet from connecting to the local host. If the
+applet reports a SocketException error in its status bar, open the
+Java console and review the exception stack trace. The most likely
+occurrence is an "access denied" error, which indicates that the
+security manager rejected the applet's connection attempt. You can
+solve this issue by temporarily granting for the applet to connect to
+the local machine. For example, if you are using JRE6 on Windows, open
+the following file:
+
+ C:\Program Files\Java\jre6\lib\security\java.policy
+
+In the "grant" section, add the line shown below:
+
+ permission java.net.SocketPermission "localhost:1024-", "connect,resolve";
+
+Restart your browser and try the applet again. If the applet still
+cannot establish a connection, try loading it from a web server
+instead.
+
+
+Loading the applet from a web server
+------------------------------------
+
+Start a hello server on the web server host. Next, start a web browser
+and open the start page (hello.html) on your web server.
Once the applet has started, verify that the name of your web server
-host is correct in the "Hostname" field and press the "Hello World!"
-button. You will notice that the server prints a "Hello World!"
-message to the console for each invocation. To make other types of Ice
-invocations, select a different mode from the combobox.
+host is shown correctly in the "Hostname" field.
+
+
+Using the applet
+----------------
+
+Press the "Hello World!" button. You will notice that the server
+prints a "Hello World!" message to the console for each invocation. To
+make other types of Ice invocations, select a different mode from the
+combobox.
The two sliders allow you to experiment with various timeout settings.
The "Timeout" slider determines how long the Ice run time will wait
diff --git a/java/demo/Ice/applet/build.xml b/java/demo/Ice/applet/build.xml
index 495021109ad..adfc97057af 100644
--- a/java/demo/Ice/applet/build.xml
+++ b/java/demo/Ice/applet/build.xml
@@ -52,7 +52,7 @@
<include name="Demo/**"/>
<include name="HelloApplet*"/>
</jar>
- <jar jarfile="Hello.jar" update="true" basedir="${top.dir}/../certs">
+ <jar jarfile="Hello.jar" update="true" basedir="${certs.dir}">
<include name="client.jks"/>
</jar>
</target>
@@ -80,7 +80,7 @@
<proguard configuration="applet.pro">
<injar path="${class.dir}"/>
- <injar path="${top.dir}/../certs/client.jks"/>
+ <injar path="${certs.dir}/client.jks"/>
<injar refid="ice.classpath" filter="!META-INF/**"/>
<outjar path="Hello.jar"/>
<libraryjar path="${library.jars}"/>
diff --git a/java/demo/Ice/applet/hello.html b/java/demo/Ice/applet/hello.html
index c0a48d8f38f..4ebae2dce92 100644
--- a/java/demo/Ice/applet/hello.html
+++ b/java/demo/Ice/applet/hello.html
@@ -7,7 +7,7 @@
<object
classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase = "http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=1,5,0,0"
- WIDTH = 300 HEIGHT = 175 >
+ WIDTH = 350 HEIGHT = 215 >
<PARAM NAME = CODE VALUE = "HelloApplet" >
<param name = "type" value = "application/x-java-applet;version=1.5">
<param name = "scriptable" value = "false">
@@ -18,8 +18,8 @@
type = "application/x-java-applet;version=1.5" \
CODE = "HelloApplet" \
ARCHIVE = "Hello.jar" \
- WIDTH = 300 \
- HEIGHT = 175
+ WIDTH = 350 \
+ HEIGHT = 215
scriptable = false
pluginspage = "http://java.sun.com/products/plugin/index.html#download">
<noembed>
diff --git a/java/demo/Ice/build.xml b/java/demo/Ice/build.xml
index a8f43061344..c101f7c9627 100644
--- a/java/demo/Ice/build.xml
+++ b/java/demo/Ice/build.xml
@@ -22,6 +22,7 @@
<ant dir="minimal"/>
<ant dir="multicast"/>
<ant dir="nested"/>
+ <ant dir="serialize"/>
<ant dir="session"/>
<ant dir="throughput"/>
<ant dir="value"/>
@@ -38,6 +39,7 @@
<ant dir="minimal" target="clean"/>
<ant dir="multicast" target="clean"/>
<ant dir="nested" target="clean"/>
+ <ant dir="serialize" target="clean"/>
<ant dir="session" target="clean"/>
<ant dir="throughput" target="clean"/>
<ant dir="value" target="clean"/>
diff --git a/java/demo/Ice/callback/CallbackSenderI.java b/java/demo/Ice/callback/CallbackSenderI.java
index d30d40b5ce6..fe86e7beb9e 100644
--- a/java/demo/Ice/callback/CallbackSenderI.java
+++ b/java/demo/Ice/callback/CallbackSenderI.java
@@ -17,7 +17,7 @@ public final class CallbackSenderI extends _CallbackSenderDisp
System.out.println("initiating callback");
try
{
- proxy.callback(current.ctx);
+ proxy.callback();
}
catch(Ice.LocalException ex)
{
diff --git a/java/demo/Ice/nested/NestedI.java b/java/demo/Ice/nested/NestedI.java
index 023cffce52f..7ba7cfabbdf 100644
--- a/java/demo/Ice/nested/NestedI.java
+++ b/java/demo/Ice/nested/NestedI.java
@@ -22,7 +22,7 @@ class NestedI extends _NestedDisp
System.out.println("" + level);
if(--level > 0)
{
- proxy.nestedCall(level, _self, current.ctx);
+ proxy.nestedCall(level, _self);
}
}
diff --git a/java/demo/Ice/protobuf/Client.java b/java/demo/Ice/protobuf/Client.java
new file mode 100644
index 00000000000..cbdbb7aca2b
--- /dev/null
+++ b/java/demo/Ice/protobuf/Client.java
@@ -0,0 +1,127 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+import Demo.*;
+
+public class Client extends Ice.Application
+{
+ class ShutdownHook extends Thread
+ {
+ public void
+ run()
+ {
+ try
+ {
+ communicator().destroy();
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private static void
+ menu()
+ {
+ System.out.println(
+ "usage:\n" +
+ "t: send greeting\n" +
+ "s: shutdown server\n" +
+ "x: exit\n" +
+ "?: help\n");
+ }
+
+ public int
+ run(String[] args)
+ {
+ if(args.length > 0)
+ {
+ System.err.println(appName() + ": too many arguments");
+ return 1;
+ }
+
+ //
+ // Since this is an interactive demo we want to clear the
+ // Application installed interrupt callback and install our
+ // own shutdown hook.
+ //
+ setInterruptHook(new ShutdownHook());
+
+ HelloPrx hello = HelloPrxHelper.checkedCast(communicator().propertyToProxy("Hello.Proxy"));
+ if(hello == null)
+ {
+ System.err.println("invalid proxy");
+ return 1;
+ }
+
+ tutorial.PersonPB.Person p = tutorial.PersonPB.Person.newBuilder().
+ setId(1).setName("Fred Jones").setEmail("fred@jones.com").build();
+
+ menu();
+
+ java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
+
+ String line = null;
+ do
+ {
+ try
+ {
+ System.out.print("==> ");
+ System.out.flush();
+ line = in.readLine();
+ if(line == null)
+ {
+ break;
+ }
+ if(line.equals("t"))
+ {
+ hello.sayHello(p);
+ }
+ else if(line.equals("s"))
+ {
+ hello.shutdown();
+ }
+ else if(line.equals("x"))
+ {
+ // Nothing to do
+ }
+ else if(line.equals("?"))
+ {
+ menu();
+ }
+ else
+ {
+ System.out.println("unknown command `" + line + "'");
+ menu();
+ }
+ }
+ catch(java.io.IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ while(!line.equals("x"));
+
+ return 0;
+ }
+
+ public static void
+ main(String[] args)
+ {
+ Client app = new Client();
+ int status = app.main("Client", args, "config.client");
+ System.exit(status);
+ }
+}
+
diff --git a/java/demo/Ice/protobuf/Hello.ice b/java/demo/Ice/protobuf/Hello.ice
new file mode 100644
index 00000000000..8ddbbbd34ae
--- /dev/null
+++ b/java/demo/Ice/protobuf/Hello.ice
@@ -0,0 +1,27 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef HELLO_ICE
+#define HELLO_ICE
+
+module Demo
+{
+
+["cpp:protobuf:tutorial::Person", "java:protobuf:tutorial.PersonPB.Person", "python:protobuf:Person_pb2.Person"]
+sequence<byte> Person;
+
+interface Hello
+{
+ idempotent void sayHello(Person p);
+ void shutdown();
+};
+
+};
+
+#endif
diff --git a/java/demo/Ice/protobuf/HelloI.java b/java/demo/Ice/protobuf/HelloI.java
new file mode 100644
index 00000000000..e3fcf7008bb
--- /dev/null
+++ b/java/demo/Ice/protobuf/HelloI.java
@@ -0,0 +1,26 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+import Demo.*;
+
+public class HelloI extends _HelloDisp
+{
+ public void
+ sayHello(tutorial.PersonPB.Person p, Ice.Current current)
+ {
+ System.out.println("Hello World from " + p);
+ }
+
+ public void
+ shutdown(Ice.Current current)
+ {
+ System.out.println("Shutting down...");
+ current.adapter.getCommunicator().shutdown();
+ }
+}
diff --git a/java/demo/Ice/protobuf/Person.proto b/java/demo/Ice/protobuf/Person.proto
new file mode 100644
index 00000000000..6ee58a3f246
--- /dev/null
+++ b/java/demo/Ice/protobuf/Person.proto
@@ -0,0 +1,18 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package tutorial;
+
+option java_outer_classname = "PersonPB";
+
+message Person {
+ required int32 id = 1;
+ required string name = 2;
+ optional string email = 3;
+}
diff --git a/java/demo/Ice/protobuf/README b/java/demo/Ice/protobuf/README
new file mode 100644
index 00000000000..5ab7020aa68
--- /dev/null
+++ b/java/demo/Ice/protobuf/README
@@ -0,0 +1,41 @@
+This demo shows how to integrate Google Protocol Buffers with Ice.
+
+The Protocol Buffers distribution and documentation can be found at
+
+ http://code.google.com/apis/protocolbuffers/
+
+This demo was tested with Protocol Buffers version 2.0.3.
+
+We have added new metadata that makes it possible for you to specify
+protocol buffers message types in your Slice definitions, with Ice
+handling the serialization chores for you automatically. The metadata,
+which may only be used on a sequence<byte> type, has the following
+syntax in Java:
+
+ java:protobuf:protoc-generated-class
+
+For example:
+
+ ["java:protobuf:tutorial.PersonPB.Person"] sequence<byte> Person;
+
+The type name specified in this example, tutorial.PersonPB.Person,
+corresponds to the Java class generated by the Protocol Buffers
+compiler (protoc) for the definition shown below:
+
+ package tutorial;
+ option java_outer_classname = "PersonPB";
+ message Person { ... };
+
+This demo uses an ant build task, located in the "ant" subdirectory,
+for compiling .proto files.
+
+Prior to building the demo, you should add protoc to your PATH and
+protobuf-java-2.0.3.jar to your CLASSPATH.
+
+To run the demo, first start the server:
+
+ $ java Server
+
+In a separate window, start the client:
+
+ $ java Client
diff --git a/java/demo/Ice/protobuf/Server.java b/java/demo/Ice/protobuf/Server.java
new file mode 100644
index 00000000000..6ffab5d02fb
--- /dev/null
+++ b/java/demo/Ice/protobuf/Server.java
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+import Demo.*;
+
+public class Server extends Ice.Application
+{
+ public int
+ run(String[] args)
+ {
+ if(args.length > 0)
+ {
+ System.err.println(appName() + ": too many arguments");
+ return 1;
+ }
+
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello");
+ adapter.add(new HelloI(), communicator().stringToIdentity("hello"));
+ adapter.activate();
+ communicator().waitForShutdown();
+ return 0;
+ }
+
+ public static void
+ main(String[] args)
+ {
+ Server app = new Server();
+ int status = app.main("Server", args, "config.server");
+ System.exit(status);
+ }
+}
diff --git a/java/demo/Ice/protobuf/ant/ProtocTask.java b/java/demo/Ice/protobuf/ant/ProtocTask.java
new file mode 100644
index 00000000000..b102cb9fccd
--- /dev/null
+++ b/java/demo/Ice/protobuf/ant/ProtocTask.java
@@ -0,0 +1,367 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+//package Ice.Ant;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.taskdefs.ExecTask;
+import org.apache.tools.ant.taskdefs.Execute;
+import org.apache.tools.ant.taskdefs.PumpStreamHandler;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.Commandline.Argument;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.StringReader;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+
+/**
+ * An ant task for protoc.
+ *
+ * Attributes specific to protoc:
+ *
+ * translator - The pathname of the translator (default: "protoc").
+ * protocpath - The value for the --proto_path translator option.
+ * outputdir - The value for the --java_out translator option.
+ * dependencyfile - The file in which dependencies are stored (default: ".pbdepend").
+ *
+ * Example:
+ *
+ * <project ...>
+ * <taskdef name="protoc" classname="ProtocTask" />
+ * <property name="protoc.dir" value="../include/protoc"/>
+ * <target name="generate">
+ * <mkdir dir="tags" />
+ * <protoc tagdir="tags" outputdir="out">
+ * <fileset dir="${protoc.dir}">
+ * <include name="*.ice" />
+ * </fileset>
+ * </protoc>
+ * </target>
+ * </project>
+ *
+ * The <taskdef> element installs the protoctask task.
+ */
+public class ProtocTask extends org.apache.tools.ant.Task
+{
+ public
+ ProtocTask()
+ {
+ _translator = null;
+ _outputDir = null;
+ _protocPath = null;
+ _outputDirString = null;
+ }
+
+ public void
+ setDependencyFile(File file)
+ {
+ _dependencyFile = file;
+ }
+
+ public void
+ setOutputdir(File dir)
+ {
+ _outputDir = dir;
+ _outputDirString = _outputDir.toString();
+ if(_outputDirString.indexOf(' ') != -1)
+ {
+ _outputDirString = '"' + _outputDirString + '"';
+ }
+ }
+
+ public void
+ setProtocpath(File dir)
+ {
+ _protocPath = dir.toString();
+ }
+
+ public void
+ setTranslator(File prog)
+ {
+ _translator = prog;
+ }
+
+ public FileSet
+ createFileset()
+ {
+ FileSet fileset = new FileSet();
+ _fileSets.add(fileset);
+
+ return fileset;
+ }
+
+ public void
+ execute()
+ throws BuildException
+ {
+ if(_fileSets.isEmpty())
+ {
+ throw new BuildException("No fileset specified");
+ }
+
+ //
+ // Read the set of dependencies for this task.
+ //
+ java.util.HashMap dependencies = readDependencies();
+
+ //
+ // Compose a list of the files that need to be translated. A
+ // file needs to translated if we can't find a dependency in
+ // the dependency table or if its dependency is not up-to-date
+ // anymore (the proto file changed since the dependency was
+ // last updated)
+ //
+ java.util.Vector buildList = new java.util.Vector();
+ java.util.Vector skipList = new java.util.Vector();
+ java.util.Iterator p = _fileSets.iterator();
+ while(p.hasNext())
+ {
+ FileSet fileset = (FileSet)p.next();
+
+ DirectoryScanner scanner = fileset.getDirectoryScanner(getProject());
+ scanner.scan();
+ String[] files = scanner.getIncludedFiles();
+ for(int i = 0; i < files.length; i++)
+ {
+ File proto = new File(fileset.getDir(getProject()), files[i]);
+
+ ProtoDependency depend = (ProtoDependency)dependencies.get(getTargetKey(proto.toString()));
+ if(depend == null || !depend.isUpToDate())
+ {
+ buildList.addElement(proto);
+ }
+ else
+ {
+ skipList.addElement(proto);
+ }
+ }
+
+ java.util.Iterator i = skipList.iterator();
+ while(i.hasNext())
+ {
+ File file = (File)i.next();
+ log("skipping " + file.getName());
+ }
+ }
+
+ //
+ // Run the translator
+ //
+ if(!buildList.isEmpty())
+ {
+ String translator;
+ if(_translator == null)
+ {
+ translator = "protoc";
+ }
+ else
+ {
+ translator = _translator.toString();
+ }
+
+ StringBuilder cmd = new StringBuilder(128);
+
+ //
+ // Add --java_out.
+ //
+ if(_outputDir != null)
+ {
+ cmd.append(" --java_out=");
+ cmd.append(stripDriveLetter(_outputDirString));
+ }
+
+ //
+ // Add --proto_path
+ //
+ if(_protocPath != null)
+ {
+ cmd.append(" --proto_path=");
+ cmd.append(stripDriveLetter(_protocPath));
+ }
+
+ //
+ // Add files to be translated
+ //
+ for(int i = 0; i < buildList.size(); i++)
+ {
+ File f = (File)buildList.elementAt(i);
+ cmd.append(" ");
+ String s = stripDriveLetter(f.toString());
+ if(s.indexOf(' ') != -1)
+ {
+ cmd.append('"' + s + '"');
+ }
+ else
+ {
+ cmd.append(s);
+ }
+ }
+
+ //
+ // Execute
+ //
+ log(translator + " " + cmd);
+ ExecTask task = (ExecTask)getProject().createTask("exec");
+ task.setFailonerror(true);
+ Argument arg = task.createArg();
+ arg.setLine(cmd.toString());
+ task.setExecutable(translator);
+ task.execute();
+
+ //
+ // Update dependency file.
+ //
+ for(int i = 0; i < buildList.size(); i++)
+ {
+ ProtoDependency depend = new ProtoDependency();
+ depend._timeStamp = new java.util.Date().getTime();
+ depend._dependency = ((File)buildList.elementAt(i)).toString();
+ dependencies.put(getTargetKey(depend._dependency), depend);
+ }
+
+ writeDependencies(dependencies);
+ }
+ }
+
+ private String
+ getTargetKey(String proto)
+ {
+ //
+ // Since the dependency file can be shared by several proto
+ // tasks we need to make sure that each dependency has a
+ // unique key. We use the name of the task, the output
+ // directory and the name of the proto file to be compiled.
+ //
+ // If there's two protoc tasks using the same dependency
+ // file, with the same output dir and which compiles the same
+ // protoc file they'll use the same dependency.
+ //
+ return "protoc " + _outputDir.toString() + " " + proto;
+ }
+
+ // This is to work around a bug with protoc, where it does not
+ // accept drive letters in path names. See
+ // http://bugzilla/bugzilla/show_bug.cgi?id=3349
+ //
+ private String
+ stripDriveLetter(String s)
+ {
+ if(s.length() > 1 && s.charAt(1) == ':')
+ {
+ return s.substring(2);
+ }
+ return s;
+ }
+
+ //
+ // Read the dependency file.
+ //
+ private java.util.HashMap
+ readDependencies()
+ {
+ if(_dependencyFile == null)
+ {
+ if(_outputDir != null)
+ {
+ _dependencyFile = new File(_outputDir, ".pbdepend");
+ }
+ else
+ {
+ _dependencyFile = new File(".pbdepend");
+ }
+ }
+
+ try
+ {
+ java.io.ObjectInputStream in = new java.io.ObjectInputStream(new java.io.FileInputStream(_dependencyFile));
+ java.util.HashMap dependencies = (java.util.HashMap)in.readObject();
+ in.close();
+ return dependencies;
+ }
+ catch(java.io.IOException ex)
+ {
+ }
+ catch(java.lang.ClassNotFoundException ex)
+ {
+ }
+
+ return new java.util.HashMap();
+ }
+
+ private void
+ writeDependencies(java.util.HashMap dependencies)
+ {
+ try
+ {
+ java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(new FileOutputStream(_dependencyFile));
+ out.writeObject(dependencies);
+ out.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ throw new BuildException("Unable to write dependencies in file " + _dependencyFile.getPath() + ": " + ex);
+ }
+ }
+
+ //
+ // A proto dependency.
+ //
+ // * the _timeStamp attribute contains the last time the proto
+ // file was compiled.
+ //
+ // * the _dependency attribute contains the .proto file.
+ //
+ private class ProtoDependency implements java.io.Serializable
+ {
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws java.io.IOException
+ {
+ out.writeObject(_dependency);
+ out.writeLong(_timeStamp);
+ }
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws java.io.IOException, java.lang.ClassNotFoundException
+ {
+ _dependency = (String)in.readObject();
+ _timeStamp = in.readLong();
+ }
+
+ public boolean
+ isUpToDate()
+ {
+ File dep = new File(_dependency);
+ if(!dep.exists() || _timeStamp < dep.lastModified())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public String _dependency;
+ public long _timeStamp;
+ }
+
+ private File _translator;
+ private File _dependencyFile;
+ private File _outputDir;
+ private String _outputDirString;
+ private String _protocPath;
+ private java.util.List _fileSets = new java.util.LinkedList();
+}
diff --git a/java/demo/Ice/protobuf/build.xml b/java/demo/Ice/protobuf/build.xml
new file mode 100644
index 00000000000..aa336420300
--- /dev/null
+++ b/java/demo/Ice/protobuf/build.xml
@@ -0,0 +1,63 @@
+<!--
+ **********************************************************************
+
+ Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+
+ This copy of Ice is licensed to you under the terms described in the
+ ICE_LICENSE file included in this distribution.
+
+ **********************************************************************
+-->
+
+<project name="demo_Ice_protobuf" default="all" basedir=".">
+
+ <!-- set global properties for this build -->
+ <property name="top.dir" value="../../.."/>
+
+ <!-- import common definitions -->
+ <import file="${top.dir}/config/common.xml"/>
+
+ <target name="protoc" depends="init">
+ <!-- Build protoc task -->
+ <mkdir dir="${class.dir}"/>
+ <javac srcdir="ant" destdir="${class.dir}" debug="${debug}">
+ <compilerarg value="${javac.lint}"/>
+ </javac>
+ </target>
+
+ <target name="generate" depends="protoc">
+ <!-- Add the protoc task -->
+ <taskdef name="protoc" classpath="${class.dir}" classname="ProtocTask" />
+ <!-- Create the output directory for generated code -->
+ <mkdir dir="${generated.dir}"/>
+ <slice2java outputdir="${generated.dir}">
+ <meta value="${java2metadata}"/>
+ <fileset dir="." includes="Hello.ice"/>
+ </slice2java>
+ <protoc outputdir="${generated.dir}" protocpath=".">
+ <fileset dir="." includes="Person.proto"/>
+ </protoc>
+ </target>
+
+ <target name="compile" depends="generate">
+ <mkdir dir="${class.dir}"/>
+ <javac srcdir="${generated.dir}" destdir="${class.dir}"
+ debug="${debug}">
+ <classpath refid="ice.classpath"/>
+ <compilerarg value="${javac.lint}"/>
+ </javac>
+ <javac srcdir="." destdir="${class.dir}"
+ excludes="generated/**, ant/**" debug="${debug}">
+ <classpath refid="ice.classpath"/>
+ <compilerarg value="${javac.lint}"/>
+ </javac>
+ </target>
+
+ <target name="all" depends="compile"/>
+
+ <target name="clean">
+ <delete dir="${generated.dir}"/>
+ <delete dir="${class.dir}"/>
+ </target>
+
+</project>
diff --git a/java/demo/Ice/protobuf/config.client b/java/demo/Ice/protobuf/config.client
new file mode 100644
index 00000000000..a02cab0f4cb
--- /dev/null
+++ b/java/demo/Ice/protobuf/config.client
@@ -0,0 +1,23 @@
+#
+# The client reads this property to create the reference to the
+# "hello" object in the server.
+#
+Hello.Proxy=hello:tcp -p 10000
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
diff --git a/java/demo/Ice/protobuf/config.server b/java/demo/Ice/protobuf/config.server
new file mode 100644
index 00000000000..309db9731b2
--- /dev/null
+++ b/java/demo/Ice/protobuf/config.server
@@ -0,0 +1,24 @@
+#
+# The server creates one single object adapter with the name
+# "Hello". The following line sets the endpoints for this
+# adapter.
+#
+Hello.Endpoints=tcp -p 10000
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
diff --git a/java/demo/Ice/protobuf/expect.py b/java/demo/Ice/protobuf/expect.py
new file mode 100755
index 00000000000..60dabda57bf
--- /dev/null
+++ b/java/demo/Ice/protobuf/expect.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import sys, os
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ]
+if len(path) == 0:
+ raise "can't find toplevel directory!"
+sys.path.append(path[0])
+
+from demoscript import *
+from demoscript.Ice import protobuf
+
+server = Util.spawn('java Server --Ice.PrintAdapterReady --Ice.Warn.Connections=0')
+server.expect('.* ready')
+client = Util.spawn('java Client --Ice.Warn.Connections=0')
+client.expect('.*==>')
+
+protobuf.run(client, server)
diff --git a/java/demo/Ice/serialize/Client.java b/java/demo/Ice/serialize/Client.java
new file mode 100644
index 00000000000..e5c6ce82fb0
--- /dev/null
+++ b/java/demo/Ice/serialize/Client.java
@@ -0,0 +1,142 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+import Demo.*;
+
+public class Client extends Ice.Application
+{
+ class ShutdownHook extends Thread
+ {
+ public void
+ run()
+ {
+ try
+ {
+ communicator().destroy();
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private static void
+ menu()
+ {
+ System.out.println(
+ "usage:\n" +
+ "g: send greeting\n" +
+ "t: toggle null greeting\n" +
+ "s: shutdown server\n" +
+ "x: exit\n" +
+ "?: help\n");
+ }
+
+ public int
+ run(String[] args)
+ {
+ if(args.length > 0)
+ {
+ System.err.println(appName() + ": too many arguments");
+ return 1;
+ }
+
+ //
+ // Since this is an interactive demo we want to clear the
+ // Application installed interrupt callback and install our
+ // own shutdown hook.
+ //
+ setInterruptHook(new ShutdownHook());
+
+ GreetPrx greet = GreetPrxHelper.checkedCast(communicator().propertyToProxy("Greet.Proxy"));
+ if(greet == null) {
+
+ System.err.println("invalid proxy");
+ return 1;
+ }
+
+ MyGreeting greeting = new MyGreeting();
+ greeting.text = "Hello there!";
+ MyGreeting nullGreeting = null;
+
+ boolean sendNull = false;
+
+ menu();
+
+ java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
+
+ String line = null;
+ do
+ {
+ try
+ {
+ System.out.print("==> ");
+ System.out.flush();
+ line = in.readLine();
+ if(line == null)
+ {
+ break;
+ }
+ if(line.equals("g"))
+ {
+ if(sendNull)
+ {
+ greet.sendGreeting(nullGreeting);
+ }
+ else
+ {
+ greet.sendGreeting(greeting);
+ }
+ }
+ else if(line.equals("t"))
+ {
+ sendNull = !sendNull;
+ }
+ else if(line.equals("s"))
+ {
+ greet.shutdown();
+ }
+ else if(line.equals("x"))
+ {
+ // Nothing to do
+ }
+ else if(line.equals("?"))
+ {
+ menu();
+ }
+ else
+ {
+ System.out.println("unknown command `" + line + "'");
+ menu();
+ }
+ }
+ catch(java.io.IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ while(!line.equals("x"));
+
+ return 0;
+ }
+
+ public static void
+ main(String[] args)
+ {
+ Client app = new Client();
+ int status = app.main("Client", args, "config.client");
+ System.exit(status);
+ }
+}
+
diff --git a/java/demo/Ice/serialize/Demo/MyGreeting.java b/java/demo/Ice/serialize/Demo/MyGreeting.java
new file mode 100644
index 00000000000..bbefc3e687b
--- /dev/null
+++ b/java/demo/Ice/serialize/Demo/MyGreeting.java
@@ -0,0 +1,15 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package Demo;
+
+public class MyGreeting implements java.io.Serializable
+{
+ public String text;
+}
diff --git a/java/demo/Ice/serialize/Greet.ice b/java/demo/Ice/serialize/Greet.ice
new file mode 100644
index 00000000000..e06d9d04f6d
--- /dev/null
+++ b/java/demo/Ice/serialize/Greet.ice
@@ -0,0 +1,26 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef GREET_ICE
+#define GREET_ICE
+
+module Demo
+{
+
+["java:serializable:Demo.MyGreeting"] sequence<byte> Greeting;
+
+interface Greet
+{
+ idempotent void sendGreeting(Greeting g);
+ void shutdown();
+};
+
+};
+
+#endif
diff --git a/java/demo/Ice/serialize/GreetI.java b/java/demo/Ice/serialize/GreetI.java
new file mode 100644
index 00000000000..855af5173f5
--- /dev/null
+++ b/java/demo/Ice/serialize/GreetI.java
@@ -0,0 +1,33 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+import Demo.*;
+
+public class GreetI extends _GreetDisp
+{
+ public void
+ sendGreeting(MyGreeting greeting, Ice.Current current)
+ {
+ if(greeting != null)
+ {
+ System.out.println(greeting.text);
+ }
+ else
+ {
+ System.out.println("Received null greeting");
+ }
+ }
+
+ public void
+ shutdown(Ice.Current current)
+ {
+ System.out.println("Shutting down...");
+ current.adapter.getCommunicator().shutdown();
+ }
+}
diff --git a/java/demo/Ice/serialize/README b/java/demo/Ice/serialize/README
new file mode 100644
index 00000000000..c472c81bef0
--- /dev/null
+++ b/java/demo/Ice/serialize/README
@@ -0,0 +1,37 @@
+This demo illustrates how to transfer serializable Java classes
+with Ice.
+
+The Java classes are transferred as byte sequences by Ice. It was
+always possible to do this, but required you to explicitly serialize
+your class into a byte sequence and then pass that sequence to your
+operations to be deserialized by the receiver. You can now accomplish
+the same thing more conveniently via metadata.
+
+In your Slice definitions, you must declare a byte sequence using the
+"java:serializable" metadata and specify the Java class name, as shown
+below:
+
+["java:serializable:JavaClassName"] sequence<byte> SliceType;
+
+Now, wherever you use the declared Slice type in your operations or
+data types, you can supply an instance of the designated Java class
+and Ice automatically converts it to and from the byte sequence that
+is passed over the wire. (The Java class you pass must derive from
+java.io.Serializable.)
+
+With the "java:serializable" metadata, if you have a serializable
+class as an out-parameter, the out-parameter is passed as
+Ice.Holder<JavaClassName>. For example, if you have a Java class
+MyPackage.Car as an out-parameter, the out-parameter is passed as
+Ice.Holder<MyPackage.Car>.
+
+To run the demo, first start the server:
+
+$ java Server
+
+In a separate window, start the client:
+
+$ java Client
+
+The client allows you to toggle between sending a real class instance
+and sending a null value, to show that passing null is supported.
diff --git a/java/demo/Ice/serialize/Server.java b/java/demo/Ice/serialize/Server.java
new file mode 100644
index 00000000000..6550ea79a6d
--- /dev/null
+++ b/java/demo/Ice/serialize/Server.java
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+import Demo.*;
+
+public class Server extends Ice.Application
+{
+ public int
+ run(String[] args)
+ {
+ if(args.length > 0)
+ {
+ System.err.println(appName() + ": too many arguments");
+ return 1;
+ }
+
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Greet");
+ adapter.add(new GreetI(), communicator().stringToIdentity("greet"));
+ adapter.activate();
+ communicator().waitForShutdown();
+ return 0;
+ }
+
+ public static void
+ main(String[] args)
+ {
+ Server app = new Server();
+ int status = app.main("Server", args, "config.server");
+ System.exit(status);
+ }
+}
diff --git a/java/demo/Ice/serialize/build.xml b/java/demo/Ice/serialize/build.xml
new file mode 100644
index 00000000000..96b3470fb12
--- /dev/null
+++ b/java/demo/Ice/serialize/build.xml
@@ -0,0 +1,52 @@
+<!--
+ **********************************************************************
+
+ Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+
+ This copy of Ice is licensed to you under the terms described in the
+ ICE_LICENSE file included in this distribution.
+
+ **********************************************************************
+-->
+
+<project name="demo_Ice_serialize" default="all" basedir=".">
+
+ <!-- set global properties for this build -->
+ <property name="top.dir" value="../../.."/>
+
+ <!-- import common definitions -->
+ <import file="${top.dir}/config/common.xml"/>
+
+ <target name="generate" depends="init">
+ <!-- Create the output directory for generated code -->
+ <mkdir dir="${generated.dir}"/>
+ <slice2java outputdir="${generated.dir}">
+ <meta value="${java2metadata}"/>
+ <fileset dir="." includes="Greet.ice"/>
+ </slice2java>
+ </target>
+
+ <target name="compile" depends="generate">
+ <mkdir dir="${class.dir}"/>
+ <javac srcdir="." destdir="${class.dir}" includes="Demo/**" debug="${debug}">
+ <classpath refid="ice.classpath"/>
+ <compilerarg value="${javac.lint}"/>
+ </javac>
+ <javac srcdir="${generated.dir}" destdir="${class.dir}" debug="${debug}">
+ <classpath refid="ice.classpath"/>
+ <compilerarg value="${javac.lint}"/>
+ </javac>
+ <javac srcdir="." destdir="${class.dir}" excludes="generated/**,Serialize/**" debug="${debug}">
+ <classpath refid="ice.classpath"/>
+ <compilerarg value="${javac.lint}"/>
+ </javac>
+ </target>
+
+ <target name="all" depends="compile"/>
+
+ <target name="clean">
+ <delete dir="${generated.dir}"/>
+ <delete dir="${class.dir}"/>
+ </target>
+
+</project>
diff --git a/java/demo/Ice/serialize/config.client b/java/demo/Ice/serialize/config.client
new file mode 100644
index 00000000000..cdf6f093e41
--- /dev/null
+++ b/java/demo/Ice/serialize/config.client
@@ -0,0 +1,28 @@
+#
+# The client reads this property to create the reference to the
+# "greet" object in the server.
+#
+Greet.Proxy=greet:tcp -p 10000
+
+#
+# Warn about connection exceptions.
+#
+Ice.Warn.Connections=1
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
diff --git a/java/demo/Ice/serialize/config.server b/java/demo/Ice/serialize/config.server
new file mode 100644
index 00000000000..41bfe6caa46
--- /dev/null
+++ b/java/demo/Ice/serialize/config.server
@@ -0,0 +1,29 @@
+#
+# The server creates one single object adapter with the name
+# "Greet". The following line sets the endpoints for this
+# adapter.
+#
+Greet.Endpoints=tcp -p 10000
+
+#
+# Warn about connection exceptions.
+#
+Ice.Warn.Connections=1
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
diff --git a/java/demo/Ice/serialize/expect.py b/java/demo/Ice/serialize/expect.py
new file mode 100755
index 00000000000..76bc8e43408
--- /dev/null
+++ b/java/demo/Ice/serialize/expect.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import sys, os
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ]
+if len(path) == 0:
+ raise "can't find toplevel directory!"
+sys.path.append(path[0])
+
+from demoscript import *
+from demoscript.Ice import serialize
+
+server = Util.spawn('java Server --Ice.PrintAdapterReady --Ice.Warn.Connections=0')
+server.expect('.* ready')
+client = Util.spawn('java Client --Ice.Warn.Connections=0')
+client.expect('.*==>')
+
+serialize.run(client, server)
diff --git a/java/demo/Ice/value/Client.java b/java/demo/Ice/value/Client.java
index dbac804ad37..58ee94fcdbc 100644
--- a/java/demo/Ice/value/Client.java
+++ b/java/demo/Ice/value/Client.java
@@ -104,7 +104,7 @@ public class Client extends Ice.Application
readline(in);
Ice.ObjectFactory factory = new ObjectFactory();
- communicator().addObjectFactory(factory, "::Demo::Printer");
+ communicator().addObjectFactory(factory, Demo.Printer.ice_staticId());
initial.getPrinter(printer, printerProxy);
System.out.println("==> " + printer.value.message);
@@ -136,7 +136,7 @@ public class Client extends Ice.Application
Printer derivedAsBase = initial.getDerivedPrinter();
System.out.println("==> The type ID of the received object is \"" + derivedAsBase.ice_id() + "\"");
- assert(derivedAsBase.ice_id().equals("::Demo::Printer"));
+ assert(derivedAsBase.ice_id().equals(Demo.Printer.ice_staticId()));
System.out.println();
System.out.println("Now we install a factory for the derived class, and try again.");
@@ -145,7 +145,7 @@ public class Client extends Ice.Application
System.out.println("[press enter]");
readline(in);
- communicator().addObjectFactory(factory, "::Demo::DerivedPrinter");
+ communicator().addObjectFactory(factory, Demo.DerivedPrinter.ice_staticId());
derivedAsBase = initial.getDerivedPrinter();
DerivedPrinter derived = (Demo.DerivedPrinter)derivedAsBase;