summaryrefslogtreecommitdiff
path: root/protobuf/demo/java
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2015-03-19 11:08:42 -0230
committerDwayne Boone <dwayne@zeroc.com>2015-03-19 11:08:42 -0230
commit7c75df06e571dfa1e60e07fdbab952d75d844d83 (patch)
treeb3816e08686320eed257c6c05e21f43be2ee1d2e /protobuf/demo/java
parentRename demo top level directories. (diff)
downloadice-7c75df06e571dfa1e60e07fdbab952d75d844d83.tar.bz2
ice-7c75df06e571dfa1e60e07fdbab952d75d844d83.tar.xz
ice-7c75df06e571dfa1e60e07fdbab952d75d844d83.zip
Removed protobuf demos
Diffstat (limited to 'protobuf/demo/java')
-rw-r--r--protobuf/demo/java/Client.java127
-rw-r--r--protobuf/demo/java/Hello.ice27
-rw-r--r--protobuf/demo/java/HelloI.java27
-rw-r--r--protobuf/demo/java/Person.proto19
-rw-r--r--protobuf/demo/java/README86
-rw-r--r--protobuf/demo/java/Server.java38
-rw-r--r--protobuf/demo/java/ant/ProtocTask.java371
-rw-r--r--protobuf/demo/java/build.xml63
-rw-r--r--protobuf/demo/java/config.client23
-rw-r--r--protobuf/demo/java/config.server24
10 files changed, 0 insertions, 805 deletions
diff --git a/protobuf/demo/java/Client.java b/protobuf/demo/java/Client.java
deleted file mode 100644
index c7eea4ac588..00000000000
--- a/protobuf/demo/java/Client.java
+++ /dev/null
@@ -1,127 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice Protobuf is licensed to you under the terms
-// described in the ICE_PROTOBUF_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/protobuf/demo/java/Hello.ice b/protobuf/demo/java/Hello.ice
deleted file mode 100644
index a36ed3e7e0f..00000000000
--- a/protobuf/demo/java/Hello.ice
+++ /dev/null
@@ -1,27 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice Protobuf is licensed to you under the terms
-// described in the ICE_PROTOBUF_LICENSE file included in this
-// distribution.
-//
-// **********************************************************************
-
-#ifndef HELLO_ICE
-#define HELLO_ICE
-
-module Demo
-{
-
-["java:protobuf:tutorial.PersonPB.Person"] sequence<byte> Person;
-
-interface Hello
-{
- idempotent void sayHello(Person p);
- void shutdown();
-};
-
-};
-
-#endif
diff --git a/protobuf/demo/java/HelloI.java b/protobuf/demo/java/HelloI.java
deleted file mode 100644
index 39319da6db9..00000000000
--- a/protobuf/demo/java/HelloI.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice Protobuf is licensed to you under the terms
-// described in the ICE_PROTOBUF_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/protobuf/demo/java/Person.proto b/protobuf/demo/java/Person.proto
deleted file mode 100644
index acada853424..00000000000
--- a/protobuf/demo/java/Person.proto
+++ /dev/null
@@ -1,19 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice Protobuf is licensed to you under the terms
-// described in the ICE_PROTOBUF_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/protobuf/demo/java/README b/protobuf/demo/java/README
deleted file mode 100644
index 979dfb31523..00000000000
--- a/protobuf/demo/java/README
+++ /dev/null
@@ -1,86 +0,0 @@
-Introduction
-------------
-
-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.5.0.
-
-Ice supports 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 { ... };
-
-
-Building the demo
------------------
-
-This demo uses an ant build task, located in the "ant" subdirectory,
-for compiling .proto files.
-
-Building the demo requires Ant 1.7.0 or greater, which can be
-downloaded at:
-
- http://ant.apache.org/bindownload.cgi
-
-If you are using a non-RPM install on Unix or have not installed Ice
-in the default location (/opt/Ice-VERSION on Unix or C:\Ice-VERSION on
-Windows) then you will need to set the environment variable ICE_HOME
-to point to the root directory of your Ice installation. For example,
-on Unix:
-
- $ export ICE_HOME=<Ice installation root directory>
-
-Or on Windows:
-
- > set ICE_HOME=<Ice installation root directory>
-
-Prior to building the demo, you should also add protoc to your PATH
-and protobuf-java-2.5.0.jar to your CLASSPATH.
-
-Use this command to build the demo:
-
- $ ant
-
-
-Running the demo
-----------------
-
-First you must ensure that your environment is set up to run Ice
-applications. Please see the documentation that came with your Ice
-distribution for more information. You will also need to add the
-classes directory to your CLASSPATH.
-
-Unix:
-
- $ export CLASSPATH=$CLASSPATH:classes
-
-Windows:
-
- > set CLASSPATH=%CLASSPATH%;classes
-
-To run the demo, first start the server:
-
- $ java Server
-
-In a separate window, start the client:
-
- $ java Client
diff --git a/protobuf/demo/java/Server.java b/protobuf/demo/java/Server.java
deleted file mode 100644
index 7bf228cdc12..00000000000
--- a/protobuf/demo/java/Server.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice Protobuf is licensed to you under the terms
-// described in the ICE_PROTOBUF_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/protobuf/demo/java/ant/ProtocTask.java b/protobuf/demo/java/ant/ProtocTask.java
deleted file mode 100644
index 3bc27d35a7f..00000000000
--- a/protobuf/demo/java/ant/ProtocTask.java
+++ /dev/null
@@ -1,371 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice Protobuf is licensed to you under the terms
-// described in the ICE_PROTOBUF_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;
- }
-
- @SuppressWarnings("unchecked")
- 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<File> buildList = new java.util.Vector<File>();
- java.util.Vector<File> skipList = new java.util.Vector<File>();
- 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('"');
- cmd.append(s);
- cmd.append('"');
- }
- 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<FileSet> _fileSets = new java.util.LinkedList<FileSet>();
-}
diff --git a/protobuf/demo/java/build.xml b/protobuf/demo/java/build.xml
deleted file mode 100644
index 7b5a79c6942..00000000000
--- a/protobuf/demo/java/build.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<!--
- **********************************************************************
-
- Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-
- This copy of Ice Protobuf is licensed to you under the terms described
- in the ICE_PROTOBUF_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/protobuf/demo/java/config.client b/protobuf/demo/java/config.client
deleted file mode 100644
index a02cab0f4cb..00000000000
--- a/protobuf/demo/java/config.client
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# 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/protobuf/demo/java/config.server b/protobuf/demo/java/config.server
deleted file mode 100644
index 309db9731b2..00000000000
--- a/protobuf/demo/java/config.server
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# 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