summaryrefslogtreecommitdiff
path: root/java/demo/Manual/simple_filesystem
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2015-03-18 12:58:16 -0230
committerMatthew Newhook <matthew@zeroc.com>2015-03-18 12:58:16 -0230
commit9b7668c7c92cf9cb311fe444cdddb489cd2a219d (patch)
tree5016567c58c81f5654e9d01935e199c6bf4761d2 /java/demo/Manual/simple_filesystem
parentVS add-in & build updates: (diff)
downloadice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.tar.bz2
ice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.tar.xz
ice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.zip
Removed demos.
Moved demoscript to distribution.
Diffstat (limited to 'java/demo/Manual/simple_filesystem')
-rw-r--r--java/demo/Manual/simple_filesystem/.externalToolBuilders/demo.book.simple_filesystem.launch17
-rw-r--r--java/demo/Manual/simple_filesystem/Client.java103
-rwxr-xr-xjava/demo/Manual/simple_filesystem/Filesystem.ice38
-rw-r--r--java/demo/Manual/simple_filesystem/Filesystem/DirectoryI.java72
-rw-r--r--java/demo/Manual/simple_filesystem/Filesystem/FileI.java67
-rw-r--r--java/demo/Manual/simple_filesystem/README10
-rw-r--r--java/demo/Manual/simple_filesystem/Server.java99
-rwxr-xr-xjava/demo/Manual/simple_filesystem/expect.py34
8 files changed, 0 insertions, 440 deletions
diff --git a/java/demo/Manual/simple_filesystem/.externalToolBuilders/demo.book.simple_filesystem.launch b/java/demo/Manual/simple_filesystem/.externalToolBuilders/demo.book.simple_filesystem.launch
deleted file mode 100644
index 2256b877bae..00000000000
--- a/java/demo/Manual/simple_filesystem/.externalToolBuilders/demo.book.simple_filesystem.launch
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
-<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="generate,"/>
-<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/>
-<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="generate,"/>
-<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
-<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
-<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${container}"/>
-<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
-<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
-<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="demo.book.simple_filesystem"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/demo.book.simple_filesystem/Filesystem.ice&quot; type=&quot;1&quot;/&gt;&#10;&lt;/resources&gt;}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.book.simple_filesystem/build.xml}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,auto,clean"/>
-<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
-</launchConfiguration>
diff --git a/java/demo/Manual/simple_filesystem/Client.java b/java/demo/Manual/simple_filesystem/Client.java
deleted file mode 100644
index b311cff4667..00000000000
--- a/java/demo/Manual/simple_filesystem/Client.java
+++ /dev/null
@@ -1,103 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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 Filesystem.*;
-
-public class Client
-{
- // Recursively print the contents of directory "dir" in tree fashion.
- // For files, show the contents of each file. The "depth"
- // parameter is the current nesting level (for indentation).
-
- static void
- listRecursive(DirectoryPrx dir, int depth)
- {
- char[] indentCh = new char[++depth];
- java.util.Arrays.fill(indentCh, '\t');
- String indent = new String(indentCh);
-
- NodePrx[] contents = dir.list();
-
- for(int i = 0; i < contents.length; ++i)
- {
- DirectoryPrx subdir = DirectoryPrxHelper.checkedCast(contents[i]);
- FilePrx file = FilePrxHelper.uncheckedCast(contents[i]);
- System.out.println(indent + contents[i].name() + (subdir != null ? " (directory):" : " (file):"));
- if(subdir != null)
- {
- listRecursive(subdir, depth);
- }
- else
- {
- String[] text = file.read();
- for(int j = 0; j < text.length; ++j)
- {
- System.out.println(indent + "\t" + text[j]);
- }
- }
- }
- }
-
- public static void
- main(String[] args)
- {
- int status = 0;
- Ice.Communicator ic = null;
- try
- {
- //
- // Create a communicator
- //
- ic = Ice.Util.initialize(args);
-
- //
- // Create a proxy for the root directory
- //
- Ice.ObjectPrx base = ic.stringToProxy("RootDir:default -h localhost -p 10000");
-
- //
- // Down-cast the proxy to a Directory proxy
- //
- DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(base);
- if(rootDir == null)
- {
- throw new RuntimeException("Invalid proxy");
- }
-
- //
- // Recursively list the contents of the root directory
- //
- System.out.println("Contents of root directory:");
- listRecursive(rootDir, 0);
- }
- catch(Ice.LocalException e)
- {
- e.printStackTrace();
- status = 1;
- }
- catch(Exception e)
- {
- System.err.println(e.getMessage());
- status = 1;
- }
- if(ic != null)
- {
- try
- {
- ic.destroy();
- }
- catch(Exception e)
- {
- System.err.println(e.getMessage());
- status = 1;
- }
- }
- System.exit(status);
- }
-}
diff --git a/java/demo/Manual/simple_filesystem/Filesystem.ice b/java/demo/Manual/simple_filesystem/Filesystem.ice
deleted file mode 100755
index 6331f9b1fdd..00000000000
--- a/java/demo/Manual/simple_filesystem/Filesystem.ice
+++ /dev/null
@@ -1,38 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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.
-//
-// **********************************************************************
-
-#pragma once
-
-module Filesystem
-{
- exception GenericError
- {
- string reason;
- };
-
- interface Node
- {
- idempotent string name();
- };
-
- sequence<string> Lines;
-
- interface File extends Node
- {
- idempotent Lines read();
- idempotent void write(Lines text) throws GenericError;
- };
-
- sequence<Node*> NodeSeq;
-
- interface Directory extends Node
- {
- idempotent NodeSeq list();
- };
-};
diff --git a/java/demo/Manual/simple_filesystem/Filesystem/DirectoryI.java b/java/demo/Manual/simple_filesystem/Filesystem/DirectoryI.java
deleted file mode 100644
index 55297f9c878..00000000000
--- a/java/demo/Manual/simple_filesystem/Filesystem/DirectoryI.java
+++ /dev/null
@@ -1,72 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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 Filesystem;
-
-public final class DirectoryI extends _DirectoryDisp
-{
- // DirectoryI constructor
-
- public
- DirectoryI(Ice.Communicator communicator, String name, DirectoryI parent)
- {
- _name = name;
- _parent = parent;
-
- // Create an identity. The root directory has the fixed identity "RootDir"
- //
- _id = new Ice.Identity();
- _id.name = _parent != null ? java.util.UUID.randomUUID().toString() : "RootDir";
- }
-
- // Slice Node::name() operation
-
- public String
- name(Ice.Current current)
- {
- return _name;
- }
-
- // Slice Directory::list() operation
-
- public NodePrx[]
- list(Ice.Current current)
- {
- NodePrx[] result = new NodePrx[_contents.size()];
- _contents.toArray(result);
- return result;
- }
-
- // addChild is called by the child in order to add
- // itself to the _contents member of the parent
-
- void
- addChild(NodePrx child)
- {
- _contents.add(child);
- }
-
- // activate adds the servant to the object adapter and
- // adds child nodes ot the parent's _contents list.
-
- public void
- activate(Ice.ObjectAdapter a)
- {
- NodePrx thisNode = NodePrxHelper.uncheckedCast(a.add(this, _id));
- if(_parent != null)
- {
- _parent.addChild(thisNode);
- }
- }
-
- private String _name;
- private DirectoryI _parent;
- private Ice.Identity _id;
- private java.util.List<NodePrx> _contents = new java.util.ArrayList<NodePrx>();
-}
diff --git a/java/demo/Manual/simple_filesystem/Filesystem/FileI.java b/java/demo/Manual/simple_filesystem/Filesystem/FileI.java
deleted file mode 100644
index 540b230ed7c..00000000000
--- a/java/demo/Manual/simple_filesystem/Filesystem/FileI.java
+++ /dev/null
@@ -1,67 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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 Filesystem;
-
-public class FileI extends _FileDisp
-{
- // FileI constructor
-
- public
- FileI(Ice.Communicator communicator, String name, DirectoryI parent)
- {
- _name = name;
- _parent = parent;
-
- assert(_parent != null);
-
- //
- // Create an identity
- //
- _id = new Ice.Identity();
- _id.name = java.util.UUID.randomUUID().toString();
- }
-
- // Slice Node::name() operation
-
- public String
- name(Ice.Current current)
- {
- return _name;
- }
-
- // Slice File::read() operation
-
- public String[]
- read(Ice.Current current)
- {
- return _lines;
- }
-
- // Slice File::write() operation
-
- public void
- write(String[] text, Ice.Current current)
- throws GenericError
- {
- _lines = text;
- }
-
- public void
- activate(Ice.ObjectAdapter a)
- {
- NodePrx thisNode = NodePrxHelper.uncheckedCast(a.add(this, _id));
- _parent.addChild(thisNode);
- }
-
- private String _name;
- private DirectoryI _parent;
- private Ice.Identity _id;
- private String[] _lines;
-}
diff --git a/java/demo/Manual/simple_filesystem/README b/java/demo/Manual/simple_filesystem/README
deleted file mode 100644
index f6ed81b1855..00000000000
--- a/java/demo/Manual/simple_filesystem/README
+++ /dev/null
@@ -1,10 +0,0 @@
-This demo implements the simple filesystem application shown at
-the end of the client and server Java mapping chapters.
-
-To run it, start the server in a window:
-
-$ java -jar build/libs/server.jar
-
-Then run the client in a separate window:
-
-$ java -jar build/libs/client.jar
diff --git a/java/demo/Manual/simple_filesystem/Server.java b/java/demo/Manual/simple_filesystem/Server.java
deleted file mode 100644
index f2abe81c235..00000000000
--- a/java/demo/Manual/simple_filesystem/Server.java
+++ /dev/null
@@ -1,99 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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 Filesystem.*;
-
-public class Server extends Ice.Application
-{
- public int
- run(String[] args)
- {
- //
- // Terminate cleanly on receipt of a signal
- //
- shutdownOnInterrupt();
-
- //
- // Create an object adapter.
- //
- Ice.ObjectAdapter adapter =
- communicator().createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h localhost -p 10000");
-
- //
- // Create the root directory (with name "/" and no parent)
- //
- DirectoryI root = new DirectoryI(communicator(), "/", null);
- root.activate(adapter);
-
- //
- // Create a file called "README" in the root directory
- //
- FileI file = new FileI(communicator(), "README", root);
- String[] text;
- text = new String[]{ "This file system contains a collection of poetry." };
- try
- {
- file.write(text, null);
- }
- catch(GenericError e)
- {
- System.err.println(e.reason);
- }
- file.activate(adapter);
-
- //
- // Create a directory called "Coleridge" in the root directory
- //
- DirectoryI coleridge = new DirectoryI(communicator(), "Coleridge", root);
- coleridge.activate(adapter);
-
- //
- // Create a file called "Kubla_Khan" in the Coleridge directory
- //
- file = new FileI(communicator(), "Kubla_Khan", coleridge);
- text = new String[]{ "In Xanadu did Kubla Khan",
- "A stately pleasure-dome decree:",
- "Where Alph, the sacred river, ran",
- "Through caverns measureless to man",
- "Down to a sunless sea." };
- try
- {
- file.write(text, null);
- }
- catch(GenericError e)
- {
- System.err.println(e.reason);
- }
- file.activate(adapter);
-
- //
- // All objects are created, allow client requests now
- //
- adapter.activate();
-
- //
- // Wait until we are done
- //
- communicator().waitForShutdown();
-
- if(interrupted())
- {
- System.err.println(appName() + ": terminating");
- }
-
- return 0;
- }
-
- public static void
- main(String[] args)
- {
- Server app = new Server();
- System.exit(app.main("Server", args));
- }
-}
diff --git a/java/demo/Manual/simple_filesystem/expect.py b/java/demo/Manual/simple_filesystem/expect.py
deleted file mode 100755
index 65ec940bd8f..00000000000
--- a/java/demo/Manual/simple_filesystem/expect.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2015 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, signal
-
-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 RuntimeError("can't find toplevel directory!")
-sys.path.append(path[0])
-
-from demoscript import Util
-
-server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady')
-server.expect('.* ready')
-
-sys.stdout.write("testing... ")
-sys.stdout.flush()
-client = Util.spawn('java -jar build/libs/client.jar')
-client.expect('Contents of root directory:\n.*Down to a sunless sea.')
-client.waitTestSuccess()
-server.kill(signal.SIGINT)
-server.waitTestSuccess()
-print("ok")