diff options
Diffstat (limited to 'java')
469 files changed, 0 insertions, 31208 deletions
diff --git a/java/allDemos.py b/java/allDemos.py deleted file mode 100755 index c5c08d21a8e..00000000000 --- a/java/allDemos.py +++ /dev/null @@ -1,64 +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 os, sys - -for toplevel in [".", "..", "../..", "../../..", "../../../.."]: - toplevel = os.path.abspath(toplevel) - if os.path.exists(os.path.join(toplevel, "demoscript")): - break -else: - raise RuntimeError("can't find toplevel directory!") - -sys.path.append(os.path.join(toplevel)) -from demoscript import Util - -# -# List of all basic demos. -# -demos = [ - "Ice/async", - "Ice/bidir", - "Ice/callback", - "Ice/hello", - "Ice/invoke", - "Ice/latency", - "Ice/minimal", - "Ice/multicast", - "Ice/nested", - "Ice/plugin", - "Ice/properties", - "Ice/serialize", - "Ice/session", - "Ice/throughput", - "Ice/value", - "Ice/optional", - "Ice/context", - "IceDiscovery/hello", - "IceDiscovery/replication", - "IceBox/hello", - "IceStorm/clock", - "IceGrid/simple", - "IceGrid/icebox", - "Glacier2/callback", - "Freeze/bench", - "Freeze/phonebook", - "Freeze/library", - "Freeze/transform", - "Freeze/casino", - "Manual/evictor_filesystem", - "Manual/map_filesystem", - "Manual/simple_filesystem", - "Manual/printer", - "Manual/lifecycle", -] - -if __name__ == "__main__": - Util.run(demos) diff --git a/java/build.gradle b/java/build.gradle index aec1b63de08..50ef819b127 100644 --- a/java/build.gradle +++ b/java/build.gradle @@ -43,12 +43,6 @@ subprojects { } } -apply from: "$rootProject.projectDir/demo/Ice/build.gradle" -apply from: "$rootProject.projectDir/demo/IceDiscovery/build.gradle" -apply from: "$rootProject.projectDir/demo/Glacier2/build.gradle" -apply from: "$rootProject.projectDir/demo/IceGrid/build.gradle" -apply from: "$rootProject.projectDir/demo/Manual/build.gradle" - // // Used to build the gradle wrapper to automatically download and install // the version of gradle needed to build Ice. diff --git a/java/demo/Database/README b/java/demo/Database/README deleted file mode 100644 index 676202f8cf8..00000000000 --- a/java/demo/Database/README +++ /dev/null @@ -1,6 +0,0 @@ -Demos in this directory: - -- library - - This demo shows how to implement an Ice server that uses mysql through - a JDBC API. diff --git a/java/demo/Database/library/.externalToolBuilders/demo.Database.library.slice.launch b/java/demo/Database/library/.externalToolBuilders/demo.Database.library.slice.launch deleted file mode 100644 index f698a374014..00000000000 --- a/java/demo/Database/library/.externalToolBuilders/demo.Database.library.slice.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.Database.library"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Database.library/Glacier2Session.ice" type="1"/> <item path="/demo.Database.library/Library.ice" type="1"/> <item path="/demo.Database.library/Session.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Database.library/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/Database/library/BookI.java b/java/demo/Database/library/BookI.java deleted file mode 100644 index ecf49cf2b84..00000000000 --- a/java/demo/Database/library/BookI.java +++ /dev/null @@ -1,403 +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 Demo.*; - -// -// This servant is a default servant. The book identity is retrieved -// from the Ice.Current object. -// -class BookI extends _BookDisp -{ - @Override - public void - ice_ping(Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = new Integer(current.id.name); - - try - { - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT * FROM books WHERE id = ?"); - stmt.setInt(1, id); - java.sql.ResultSet rs = stmt.executeQuery(); - if(!rs.next()) - { - throw new Ice.ObjectNotExistException(); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public BookDescription - describe(Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = new Integer(current.id.name); - - try - { - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT * FROM books WHERE id = ?"); - stmt.setInt(1, id); - java.sql.ResultSet rs = stmt.executeQuery(); - if(!rs.next()) - { - throw new Ice.ObjectNotExistException(); - } - return extractDescription(context, rs, current.adapter); - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public void - setTitle(String title, Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = new Integer(current.id.name); - - try - { - java.sql.PreparedStatement stmt = context.prepareStatement("UPDATE books SET title = ? WHERE id = ?"); - stmt.setString(1, title); - stmt.setInt(2, id); - int count = stmt.executeUpdate(); - if(count == 0) - { - throw new Ice.ObjectNotExistException(); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public void - setAuthors(java.util.List<String> authors, Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = new Integer(current.id.name); - - try - { - // First make sure the book still exists - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT * FROM books WHERE id = ?"); - stmt.setInt(1, id); - java.sql.ResultSet rs = stmt.executeQuery(); - if(!rs.next()) - { - throw new Ice.ObjectNotExistException(); - } - - // Next destroy each of the authors_books records. - stmt = context.prepareStatement("DELETE FROM authors_books WHERE book_id = ?"); - stmt.setInt(1, id); - stmt.executeUpdate(); - - // - // Convert the authors string to an id set. - // - java.util.List<Integer> authIds = new java.util.LinkedList<Integer>(); - for(String author : authors) - { - Integer authid; - stmt = context.prepareStatement("SELECT * FROM authors WHERE name = ?"); - stmt.setString(1, author); - rs = stmt.executeQuery(); - if(rs.next()) - { - // If there is a result, then the database - // already contains this author. - authid = rs.getInt(1); - assert !rs.next(); - } - else - { - // Otherwise, create a new author record. - stmt = context.prepareStatement("INSERT INTO authors (name) VALUES(?)", - java.sql.Statement.RETURN_GENERATED_KEYS); - stmt.setString(1, author); - int count = stmt.executeUpdate(); - assert count == 1; - rs = stmt.getGeneratedKeys(); - boolean next = rs.next(); - assert next; - authid = rs.getInt(1); - } - - // Add the new id to the list of ids. - authIds.add(authid); - } - - // Create new authors_books records. - for(Integer i : authIds) - { - stmt = context.prepareStatement("INSERT INTO authors_books (book_id, author_id) VALUES(?, ?)"); - stmt.setInt(1, id); - stmt.setInt(2, i); - int count = stmt.executeUpdate(); - assert count == 1; - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public void - destroy(Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = new Integer(current.id.name); - - try - { - java.sql.PreparedStatement stmt = context.prepareStatement("DELETE FROM books WHERE id = ?"); - stmt.setInt(1, id); - int count = stmt.executeUpdate(); - if(count == 0) - { - throw new Ice.ObjectNotExistException(); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public String - getRenter(Ice.Current current) - throws BookNotRentedException - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = new Integer(current.id.name); - - try - { - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT * FROM books WHERE id = ?"); - stmt.setInt(1, id); - java.sql.ResultSet rs = stmt.executeQuery(); - if(!rs.next()) - { - throw new Ice.ObjectNotExistException(); - } - - int renterId = rs.getInt("renter_id"); - if(rs.wasNull()) - { - throw new BookNotRentedException(); - } - - stmt = context.prepareStatement("SELECT * FROM customers WHERE id = ?"); - stmt.setInt(1, renterId); - rs = stmt.executeQuery(); - boolean next = rs.next(); - assert next; - return rs.getString("name"); - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - // - // The context automatically closes the associated statements at the end of - // the request. - // - @SuppressWarnings("resource") - @Override - public void - rentBook(String name, Ice.Current current) - throws InvalidCustomerException, BookRentedException - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = new Integer(current.id.name); - name = name.trim(); - if(name.length() == 0) - { - throw new InvalidCustomerException(); - } - - try - { - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT * FROM books WHERE id = ?"); - stmt.setInt(1, id); - java.sql.ResultSet rs = stmt.executeQuery(); - if(!rs.next()) - { - throw new Ice.ObjectNotExistException(); - } - - Integer renterId = rs.getInt("renter_id"); - if(!rs.wasNull()) - { - stmt = context.prepareStatement("SELECT * FROM customers WHERE id = ?"); - stmt.setInt(1, renterId); - rs = stmt.executeQuery(); - boolean next = rs.next(); - assert next; - throw new BookRentedException(rs.getString("name")); - } - - stmt = context.prepareStatement("SELECT * FROM customers WHERE name = ?"); - stmt.setString(1, name); - rs = stmt.executeQuery(); - - if(rs.next()) - { - renterId = rs.getInt("id"); - assert !rs.next(); - } - else - { - stmt = context.prepareStatement("INSERT into customers (name) VALUES(?)", - java.sql.Statement.RETURN_GENERATED_KEYS); - stmt.setString(1, name); - int count = stmt.executeUpdate(); - assert count == 1; - rs = stmt.getGeneratedKeys(); - boolean next = rs.next(); - assert next; - renterId = rs.getInt(1); - } - - stmt = context.prepareStatement("UPDATE books SET renter_id = ? WHERE id = ?"); - stmt.setInt(1, renterId); - stmt.setInt(2, id); - int count = stmt.executeUpdate(); - assert count == 1; - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public void - returnBook(Ice.Current current) - throws BookNotRentedException - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = new Integer(current.id.name); - try - { - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT * FROM books WHERE id = ?"); - stmt.setInt(1, id); - java.sql.ResultSet rs = stmt.executeQuery(); - if(!rs.next()) - { - throw new Ice.ObjectNotExistException(); - } - rs.getInt("renter_id"); - if(rs.wasNull()) - { - throw new BookNotRentedException(); - } - - stmt = context.prepareStatement("UPDATE books SET renter_id = NULL WHERE id = ?"); - stmt.setInt(1, id); - int count = stmt.executeUpdate(); - assert count == 1; - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - BookI() - { - } - - static Ice.Identity - createIdentity(Integer bookId) - { - Ice.Identity id = new Ice.Identity(); - id.category = "book"; - id.name = bookId.toString(); - return id; - } - - static BookDescription - extractDescription(SQLRequestContext context, java.sql.ResultSet rs, Ice.ObjectAdapter adapter) - throws java.sql.SQLException - { - Integer id = rs.getInt("id"); - - BookDescription desc = new BookDescription(); - desc.isbn = rs.getString("isbn"); - desc.title = rs.getString("title"); - desc.authors = new java.util.LinkedList<String>(); - desc.proxy = BookPrxHelper.uncheckedCast(adapter.createProxy(createIdentity(id))); - - java.sql.PreparedStatement stmt = null; - // Query for the rentedBy. - Integer renterId = rs.getInt("renter_id"); - if(!rs.wasNull()) - { - stmt = context.prepareStatement("SELECT * FROM customers WHERE id = ?"); - stmt.setInt(1, renterId); - java.sql.ResultSet customerRS = stmt.executeQuery(); - boolean next = customerRS.next(); - assert next; - desc.rentedBy = customerRS.getString(2); - } - - // Query for the authors. - stmt = context.prepareStatement("SELECT * FROM authors INNER JOIN authors_books ON " + - "authors.id=authors_books.author_id AND authors_books.book_id = ?"); - stmt.setInt(1, id); - java.sql.ResultSet authorRS = stmt.executeQuery(); - while(authorRS.next()) - { - desc.authors.add(authorRS.getString("name")); - } - - return desc; - } -} diff --git a/java/demo/Database/library/BookQueryResultI.java b/java/demo/Database/library/BookQueryResultI.java deleted file mode 100644 index 048332e87e1..00000000000 --- a/java/demo/Database/library/BookQueryResultI.java +++ /dev/null @@ -1,90 +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 Demo.*; - -class BookQueryResultI extends _BookQueryResultDisp -{ - BookQueryResultI(SQLRequestContext context, java.sql.ResultSet rs, Ice.ObjectAdapter adapter) throws java.sql.SQLException - { - _books = new java.util.Stack<BookDescription>(); - for(int i = 0; i < MAX_BOOK_QUERY_RESULT; ++i) - { - _books.add(BookI.extractDescription(context, rs, adapter)); - if(!rs.next()) - { - break; - } - } - } - - @Override - synchronized public java.util.List<BookDescription> - next(int n, Ice.BooleanHolder destroyed, Ice.Current current) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - destroyed.value = false; - java.util.List<BookDescription> l = new java.util.LinkedList<BookDescription>(); - if(n <= 0) - { - return l; - } - - for(int i = 0; i < n && _books.size() > 0; ++i) - { - l.add(_books.pop()); - } - - if(_books.size() <= 0) - { - try - { - destroyed.value = true; - destroy(current); - } - catch(Exception e) - { - // Ignore. - } - } - - return l; - } - - @Override - synchronized public void - destroy(Ice.Current current) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - _destroyed = true; - - current.adapter.remove(current.id); - } - - // Called on application shutdown by the Library. - synchronized public void - shutdown() - { - if(!_destroyed) - { - _destroyed = true; - } - } - - private java.util.Stack<BookDescription> _books; - private boolean _destroyed = false; - private static final int MAX_BOOK_QUERY_RESULT = 1000; -} - diff --git a/java/demo/Database/library/Client.java b/java/demo/Database/library/Client.java deleted file mode 100644 index 0e9cd61992a..00000000000 --- a/java/demo/Database/library/Client.java +++ /dev/null @@ -1,56 +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. -// -// ********************************************************************** - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - @Override - public int - run(String[] args) - { - if(args.length > 1) - { - System.err.println("Usage: " + appName() + " [file]"); - 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()); - - return RunParser.runParser(appName(), args, communicator()); - } - - static public void - main(String[] args) - { - Client app = new Client(); - int status = app.main("demo.Database.library.Client", args, "config.client"); - System.exit(status); - } -} diff --git a/java/demo/Database/library/ConnectionPool.java b/java/demo/Database/library/ConnectionPool.java deleted file mode 100644 index 7e896a1dd99..00000000000 --- a/java/demo/Database/library/ConnectionPool.java +++ /dev/null @@ -1,157 +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. -// -// ********************************************************************** - -class ConnectionPool -{ - public synchronized void - destroy() - { - _destroyed = true; - while(_connections.size() != _nconnections) - { - try - { - wait(); - } - catch(InterruptedException e) - { - } - } - - while(!_connections.isEmpty()) - { - java.sql.Connection conn = _connections.removeFirst(); - try - { - conn.close(); - } - catch(java.sql.SQLException e) - { - } - } - } - - public synchronized java.sql.Connection - acquire() - { - while(_connections.isEmpty() && !_destroyed) - { - try - { - wait(); - } - catch(InterruptedException e) - { - } - } - if(_destroyed) - { - return null; - } - java.sql.Connection conn = _connections.removeFirst(); - - try - { - boolean closed = conn.isClosed(); - if(closed) - { - _logger.warning("ConnectionPool: lost connection to database"); - conn = null; - } - else - { - // Probe the connection with the database. - java.sql.PreparedStatement stmt = conn.prepareStatement("SELECT 1"); - java.sql.ResultSet rs = stmt.executeQuery(); - rs.close(); - stmt.close(); - } - } - catch(java.sql.SQLException e) - { - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - e.printStackTrace(pw); - pw.flush(); - _logger.warning("ConnectionPool: lost connection to database:\n" + sw.toString()); - - conn = null; - } - - // If the connection has been closed, or is otherwise invalid, - // we need to re-establish the connection. - while(conn == null) - { - if(_trace) - { - _logger.trace("ConnectionPool", "establishing new database connection"); - } - try - { - conn = java.sql.DriverManager.getConnection(_url, _username, _password); - conn.setAutoCommit(false); - } - catch(java.sql.SQLException e) - { - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - e.printStackTrace(pw); - pw.flush(); - _logger.warning("ConnectionPool: database connection failed:\n" + sw.toString()); - } - } - if(_trace) - { - _logger.trace("ConnectionPool", "returning connection: " + conn + " " + - _connections.size() + "/" + _nconnections + " remaining"); - } - return conn; - } - - public synchronized void - release(java.sql.Connection connection) - { - if(connection != null) - { - _connections.add(connection); - notifyAll(); - } - } - - ConnectionPool(Ice.Logger logger, String url, String username, String password, int numConnections) - throws java.sql.SQLException - { - _logger = logger; - _url = url; - _username = username; - _password = password; - - _nconnections = numConnections; - if(_trace) - { - _logger.trace("ConnectionPool", "establishing " + numConnections + " connections to " + url); - } - while(numConnections-- > 0) - { - java.sql.Connection connection = java.sql.DriverManager.getConnection(url, username, password); - connection.setAutoCommit(false); - _connections.add(connection); - } - } - - - private Ice.Logger _logger; - private boolean _trace = true; - private String _url; - private String _username; - private String _password; - private java.util.LinkedList<java.sql.Connection> _connections = new java.util.LinkedList<java.sql.Connection>(); - private boolean _destroyed = false; - private int _nconnections; -} diff --git a/java/demo/Database/library/DispatchInterceptorI.java b/java/demo/Database/library/DispatchInterceptorI.java deleted file mode 100644 index 3ab374d524d..00000000000 --- a/java/demo/Database/library/DispatchInterceptorI.java +++ /dev/null @@ -1,59 +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 Demo.*; - -class DispatchInterceptorI extends Ice.DispatchInterceptor -{ - @Override - public Ice.DispatchStatus - dispatch(Ice.Request request) - { - // Allocate a new SQLRequestContext associated with this - // request thread. - SQLRequestContext context = new SQLRequestContext(); - try - { - Ice.DispatchStatus status = _servant.ice_dispatch(request); - - // An exception causes the current transaction to rollback. - context.destroyFromDispatch(status == Ice.DispatchStatus.DispatchOK); - - return status; - } - catch(JDBCException ex) - { - // Log the error. - Ice.Current c = request.getCurrent(); - context.error("call of `" + c.operation + "' on id `" + c.id.category + "/" + c.id.name + "' failed", ex); - - // A JDBCException causes the current transaction to - // rollback. - context.destroyFromDispatch(false); - - // Translate the exception to UnknownException. - Ice.UnknownException e = new Ice.UnknownException(); - e.initCause(ex); - throw e; - } - catch(RuntimeException ex) - { - // Any other exception causes the transaction to rollback. - context.destroyFromDispatch(false); - throw ex; - } - } - - DispatchInterceptorI(Ice.Object servant) - { - _servant = servant; - } - - private Ice.Object _servant; -} diff --git a/java/demo/Database/library/Glacier2Session.ice b/java/demo/Database/library/Glacier2Session.ice deleted file mode 100644 index 6222aa24d97..00000000000 --- a/java/demo/Database/library/Glacier2Session.ice +++ /dev/null @@ -1,47 +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 - -#include <Glacier2/Session.ice> - -module Demo -{ - -/* Forward declaration. */ -interface Library; - -/** - * - * The session object. This is used to retrieve a per-session library - * on behalf of the client. If the session is not refreshed on a - * periodic basis, it will be automatically destroyed. - * - */ -interface Glacier2Session extends Glacier2::Session -{ - /** - * - * Get the library object. - * - * @return A proxy for the new library. - * - **/ - Library* getLibrary(); - - /** - * - * Refresh a session. If a session is not refreshed on a regular - * basis by the client, it will be automatically destroyed. - * - **/ - idempotent void refresh(); -}; - -}; diff --git a/java/demo/Database/library/Glacier2SessionManagerI.java b/java/demo/Database/library/Glacier2SessionManagerI.java deleted file mode 100644 index 170b850e5bc..00000000000 --- a/java/demo/Database/library/Glacier2SessionManagerI.java +++ /dev/null @@ -1,39 +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 Demo.*; - -class Glacier2SessionManagerI extends Glacier2._SessionManagerDisp -{ - @Override - public Glacier2.SessionPrx - create(String userId, Glacier2.SessionControlPrx control, Ice.Current c) - { - SessionI session = new SessionI(_logger, c.adapter); - _Glacier2SessionTie servant = new _Glacier2SessionTie(session); - - Glacier2.SessionPrx proxy = Glacier2.SessionPrxHelper.uncheckedCast(c.adapter.addWithUUID(servant)); - - _logger.trace("SessionFactory", "create new session: " + - c.adapter.getCommunicator().identityToString(proxy.ice_getIdentity())); - - _reaper.add(proxy, session); - - return proxy; - } - - Glacier2SessionManagerI(Ice.Logger logger, ReapTask reaper) - { - _logger = logger; - _reaper = reaper; - } - - private Ice.Logger _logger; - private ReapTask _reaper; -} diff --git a/java/demo/Database/library/Grammar.java b/java/demo/Database/library/Grammar.java deleted file mode 100644 index 447a8775589..00000000000 --- a/java/demo/Database/library/Grammar.java +++ /dev/null @@ -1,176 +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. -// -// ********************************************************************** - -class Grammar -{ - Grammar(Parser p) - { - _parser = p; - _scanner = new Scanner(_parser); - } - - void - parse() - { - while(true) - { - try - { - _token = _scanner.nextToken(); - if(_token == null) - { - return; - } - else if(_token.type == Token.TOK_SEMI) - { - // Continue - } - else if(_token.type == Token.TOK_HELP) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.usage(); - } - else if(_token.type == Token.TOK_EXIT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - return; - } - else if(_token.type == Token.TOK_ADD_BOOK) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.addBook(s); - } - else if(_token.type == Token.TOK_FIND_ISBN) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.findIsbn(s); - } - else if(_token.type == Token.TOK_FIND_AUTHORS) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.findAuthors(s); - } - else if(_token.type == Token.TOK_FIND_TITLE) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.findTitle(s); - } - else if(_token.type == Token.TOK_NEXT_FOUND_BOOK) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.nextFoundBook(); - } - else if(_token.type == Token.TOK_PRINT_CURRENT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.printCurrent(); - } - else if(_token.type == Token.TOK_RENT_BOOK) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.rentCurrent(s); - } - else if(_token.type == Token.TOK_RETURN_BOOK) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.returnCurrent(); - } - else if(_token.type == Token.TOK_REMOVE_CURRENT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.removeCurrent(); - } - else - { - _parser.error("parse error"); - } - } - catch(ParseError e) - { - _parser.error("Parse error: " + e.getMessage()); - } - } - } - - private java.util.List<String> - strings() - { - java.util.List<String> l = new java.util.ArrayList<String>(); - while(true) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_STRING) - { - return l; - } - l.add(_token.value); - } - } - - static private class ParseError extends RuntimeException - { - ParseError(String msg) - { - super(msg); - } - } - - private Parser _parser; - private Scanner _scanner; - private Token _token; -} diff --git a/java/demo/Database/library/Library.ice b/java/demo/Database/library/Library.ice deleted file mode 100644 index e0f02ecfffc..00000000000 --- a/java/demo/Database/library/Library.ice +++ /dev/null @@ -1,294 +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 - -#include <Ice/BuiltinSequences.ice> - -module Demo -{ - -/** - * - * This local exception is used internally if a java.sql.SQLException - * is raised. - * - **/ -local exception JDBCException -{ -}; - -/** - * - * This exception is raised if the book already exists. - * - **/ -exception BookExistsException -{ -}; - -/** - * - * This exception is raised if a book has already been rented. - * - **/ -exception BookRentedException -{ - string renter; -}; - -/** - * - * This exception is raised if a customer name is invalid. - * - **/ -exception InvalidCustomerException -{ -}; - -/** - * - * This exception is raised if the ISBN is invalid. - * - **/ -exception InvalidISBNException -{ -}; - -/** - * - * This exception is raised if the book has not been rented. - * - **/ -exception BookNotRentedException -{ -}; - -/** Forward declaration for the interface Book. */ -interface Book; - -/** - * - * A description of a book. - * - **/ -struct BookDescription -{ - /** The ISBN number of the book. */ - string isbn; - - /** The title of the book. */ - string title; - - /** The authors of the book. */ - ["java:type:java.util.LinkedList<String>:java.util.List<String>"] Ice::StringSeq authors; - - /** The customer name of the renter. */ - string rentedBy; - - /** A proxy to the associated book. */ - Book* proxy; -}; - -/** A sequence of book descriptions. */ -["java:type:java.util.LinkedList<BookDescription>:java.util.List<BookDescription>"] -sequence<BookDescription> BookDescriptionSeq; - -/** - * - * This interface represents a book. - * - **/ -interface Book -{ - /** - * - * Get a description of the book. - * - * @return The book description. - * - **/ - idempotent BookDescription describe(); - - /** - * - * Set the title of a book. - * - * @param title The book title. - * - **/ - void setTitle(string title); - - /** - * - * Set the book authors. - * - * @param authors The book authors. - * - **/ - void setAuthors(["java:type:java.util.LinkedList<String>:java.util.List<String>"] Ice::StringSeq authors); - - /** - * - * Rent the book to the specified customer. - * - * @param customer The customer. - * - * @throws BookRentedException Raised if the book has already been - * rented. - * - * @throws InvalidCustomerException Raised if the customer is invalid. - * - **/ - void rentBook(string name) - throws InvalidCustomerException, BookRentedException; - - /** - * - * Get the renter. - * - * @return The current rental customer. - * - * @throws BookNotRentedException Raised if the book is not - * currently rented. - * - **/ - idempotent string getRenter() - throws BookNotRentedException; - - /** - * - * Return the book. - * - * @throws BookNotRentedException Raised if the book is not - * currently rented. - * - **/ - void returnBook() - throws BookNotRentedException; - - /** - * - * Destroy the book. - * - **/ - void destroy(); -}; - -/** - * - * Interface to get query results. - * - **/ -interface BookQueryResult -{ - /** - * - * Get more query results. - * - * @param n The maximum number of results to return. - * - * @param destroyed There are no more results, and the query has - * been destroyed. - * - * @returns A sequence of up to n results. - * - **/ - BookDescriptionSeq next(int n, out bool destroyed); - - /** - * - * Destroy the query result. - * - **/ - void destroy(); -}; - -/** - * - * An interface to the library. - * - **/ -interface Library -{ - /** - * - * Query based on isbn number. The query is a partial match at the - * start of the isbn number. - * - * @param isbn The ISBN number. - * - * @param n The number of rows to retrieve in the initial request. - - * @param first The first set of results, up to n results. - * - * @param nrows The total number of rows. - * - * @param result The remainder of the results. If there are no - * further results, a null proxy is returned. - * - **/ - void queryByIsbn(string isbn, int n, out BookDescriptionSeq first, out int nrows, out BookQueryResult* result); - - /** - * - * Query based on the author name. The query is a partial match of - * the author's name. - * - * @param author The authors name. - * - * @param n The number of rows to retrieve in the initial request. - - * @param first The first set of results, up to n results. - * - * @param nrows The total number of rows. - * - * @param result The remainder of the results. If there are no - * further results, a null proxy is returned. - * - **/ - void queryByAuthor(string author, int n, out BookDescriptionSeq first, out int nrows, out BookQueryResult* result); - - /** - * - * Query based on the book title. The query is a partial match of - * the book title. - * - * @param author The authors name. - * - * @param n The number of rows to retrieve in the initial request. - - * @param first The first set of results, up to n results. - * - * @param nrows The total number of rows. - * - * @param result The remainder of the results. If there are no - * further results, a null proxy is returned. - * - **/ - void queryByTitle(string title, int n, out BookDescriptionSeq first, out int nrows, out BookQueryResult* result); - - /** - * - * Create a book with the given description. - * - * @param description The book description. - * - * @return A proxy for the new book. - * - * @throws BookExistsException Raised if a book with the same ISBN - * number already exists. - * - **/ - Book* createBook(string isbn, string title, - ["java:type:java.util.LinkedList<String>:java.util.List<String>"] Ice::StringSeq authors) - throws BookExistsException, InvalidISBNException; -}; - -}; diff --git a/java/demo/Database/library/LibraryI.java b/java/demo/Database/library/LibraryI.java deleted file mode 100644 index 39594b4b110..00000000000 --- a/java/demo/Database/library/LibraryI.java +++ /dev/null @@ -1,383 +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 Demo.*; - -// -// This is a per-session library object. -// -class LibraryI extends _LibraryDisp -{ - @Override - public void - queryByIsbn(String isbn, int n, BookDescriptionSeqHolder first, Ice.IntHolder nrows, - BookQueryResultPrxHolder result, Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - - reapQueries(); - - try - { - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT COUNT(*) FROM books WHERE isbn LIKE ?"); - stmt.setString(1, isbn + "%"); - java.sql.ResultSet rs = stmt.executeQuery(); - boolean next = rs.next(); - assert next; - nrows.value = rs.getInt(1); - if(nrows.value == 0) - { - return; - } - - stmt = context.prepareStatement("SELECT * FROM books WHERE isbn LIKE ?"); - stmt.setString(1, isbn + "%"); - rs = stmt.executeQuery(); - next = rs.next(); - assert next; - - first.value = new java.util.LinkedList<BookDescription>(); - next = true; - for(int i = 0; i < n && next; ++i) - { - first.value.add(BookI.extractDescription(context, rs, current.adapter)); - next = rs.next(); - } - if(next) - { - BookQueryResultI impl = new BookQueryResultI(context, rs, current.adapter); - result.value = BookQueryResultPrxHelper.uncheckedCast(current.adapter.addWithUUID(impl)); - add(result.value, impl); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public void - queryByAuthor(String author, int n, BookDescriptionSeqHolder first, Ice.IntHolder nrows, - BookQueryResultPrxHolder result, Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - - reapQueries(); - - try - { - // Find each of the authors. - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT * FROM authors WHERE name LIKE ?"); - stmt.setString(1, "%" + author + "%"); - java.sql.ResultSet rs = stmt.executeQuery(); - if(!rs.next()) - { - // No results are available. - nrows.value = 0; - return; - } - - // Build a query that finds all books by these authors. - StringBuilder sb = new StringBuilder(128); - sb.append("("); - boolean front = true; - do - { - if(!front) - { - sb.append(" OR "); - } - front = false; - sb.append("authors_books.author_id="); - sb.append(rs.getInt("id")); - } - while(rs.next()); - sb.append(")"); - - stmt = context.prepareStatement( - "SELECT COUNT(DISTINCT ID) FROM books INNER JOIN authors_books ON books.id=authors_books.book_id AND " - + sb.toString()); - rs = stmt.executeQuery(); - boolean next = rs.next(); - assert next; - nrows.value = rs.getInt(1); - if(nrows.value == 0) - { - return; - } - - // Execute the query. - stmt = context.prepareStatement( - "SELECT DISTINCT ID, ISBN, TITLE, RENTER_ID FROM books INNER JOIN authors_books ON " + - "books.id=authors_books.book_id AND " + sb.toString()); - rs = stmt.executeQuery(); - next = rs.next(); - assert next; - - next = true; - first.value = new java.util.LinkedList<BookDescription>(); - for(int i = 0; i < n && next; ++i) - { - first.value.add(BookI.extractDescription(context, rs, current.adapter)); - next = rs.next(); - } - - if(next) - { - BookQueryResultI impl = new BookQueryResultI(context, rs, current.adapter); - result.value = BookQueryResultPrxHelper.uncheckedCast(current.adapter.addWithUUID(impl)); - add(result.value, impl); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public void - queryByTitle(String title, int n, BookDescriptionSeqHolder first, Ice.IntHolder nrows, - BookQueryResultPrxHolder result, Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - - reapQueries(); - - try - { - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT COUNT(*) FROM books WHERE title LIKE ?"); - stmt.setString(1, "%" + title + "%"); - java.sql.ResultSet rs = stmt.executeQuery(); - boolean next = rs.next(); - assert next; - nrows.value = rs.getInt(1); - if(nrows.value == 0) - { - return; - } - - stmt = context.prepareStatement("SELECT * FROM books WHERE title LIKE ?"); - stmt.setString(1, "%" + title + "%"); - rs = stmt.executeQuery(); - next = rs.next(); - assert next; - - first.value = new java.util.LinkedList<BookDescription>(); - next = true; - for(int i = 0; i < n && next; ++i) - { - first.value.add(BookI.extractDescription(context, rs, current.adapter)); - next = rs.next(); - } - if(next) - { - BookQueryResultI impl = new BookQueryResultI(context, rs, current.adapter); - result.value = BookQueryResultPrxHelper.uncheckedCast(current.adapter.addWithUUID(impl)); - add(result.value, impl); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public BookPrx - createBook(String isbn, String title, java.util.List<String> authors, Ice.Current current) - throws BookExistsException, InvalidISBNException - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - try - { - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT * FROM books WHERE isbn = ?"); - stmt.setString(1, isbn); - java.sql.ResultSet rs = stmt.executeQuery(); - if(rs.next()) - { - throw new BookExistsException(); - } - - if(isbn.length() > 13) - { - throw new InvalidISBNException(); - } - - // - // First convert the authors string to an id set. - // - java.util.List<Integer> authIds = new java.util.LinkedList<Integer>(); - for(String author : authors) - { - Integer id; - stmt = context.prepareStatement("SELECT * FROM authors WHERE name = ?"); - stmt.setString(1, author); - rs = stmt.executeQuery(); - if(rs.next()) - { - // If there is a result, then the database - // already contains this author. - id = rs.getInt(1); - assert !rs.next(); - } - else - { - // Otherwise, create a new author record. - stmt = context.prepareStatement("INSERT INTO authors (name) VALUES(?)", - java.sql.Statement.RETURN_GENERATED_KEYS); - stmt.setString(1, author); - int count = stmt.executeUpdate(); - assert count == 1; - rs = stmt.getGeneratedKeys(); - boolean next = rs.next(); - assert next; - id = rs.getInt(1); - } - - // Add the new id to the list of ids. - authIds.add(id); - } - - // Create the new book. - stmt = context.prepareStatement("INSERT INTO books (isbn, title) VALUES(?, ?)", - java.sql.Statement.RETURN_GENERATED_KEYS); - stmt.setString(1, isbn); - stmt.setString(2, title); - int count = stmt.executeUpdate(); - assert count == 1; - - rs = stmt.getGeneratedKeys(); - boolean next = rs.next(); - assert next; - Integer bookId = rs.getInt(1); - - // Create new authors_books records. - for(Integer i : authIds) - { - stmt = context.prepareStatement("INSERT INTO authors_books (book_id, author_id) VALUES(?, ?)"); - stmt.setInt(1, bookId); - stmt.setInt(2, i); - count = stmt.executeUpdate(); - assert count == 1; - } - - return BookPrxHelper.uncheckedCast(current.adapter.createProxy(BookI.createIdentity(bookId))); - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - LibraryI() - { - } - - synchronized public void - destroy() - { - if(_destroyed) - { - return; - } - _destroyed = true; - for(QueryProxyPair p : _queries) - { - try - { - p.proxy.destroy(); - } - catch(Ice.ObjectNotExistException e) - { - // Ignore, it could have already been destroyed. - } - } - } - - synchronized public void - shutdown() - { - if(_destroyed) - { - return; - } - _destroyed = true; - - // Shutdown each of the associated query objects. - for(QueryProxyPair p : _queries) - { - p.impl.shutdown(); - } - } - - synchronized private void - add(BookQueryResultPrx proxy, BookQueryResultI impl) - { - // If the session has been destroyed, then destroy the book - // result, and raise an ObjectNotExistException. - if(_destroyed) - { - proxy.destroy(); - throw new Ice.ObjectNotExistException(); - } - _queries.add(new QueryProxyPair(proxy, impl)); - } - - synchronized private void - reapQueries() - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - - java.util.Iterator<QueryProxyPair> p = _queries.iterator(); - while(p.hasNext()) - { - QueryProxyPair pair = p.next(); - try - { - pair.proxy.ice_ping(); - } - catch(Ice.ObjectNotExistException e) - { - p.remove(); - } - } - } - - static class QueryProxyPair - { - QueryProxyPair(BookQueryResultPrx p, BookQueryResultI i) - { - proxy = p; - impl = i; - } - - BookQueryResultPrx proxy; - BookQueryResultI impl; - } - - private java.util.List<QueryProxyPair> _queries = new java.util.LinkedList<QueryProxyPair>(); - private boolean _destroyed = false; -} diff --git a/java/demo/Database/library/Parser.java b/java/demo/Database/library/Parser.java deleted file mode 100644 index 28596c766be..00000000000 --- a/java/demo/Database/library/Parser.java +++ /dev/null @@ -1,446 +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 Demo.*; - -class Parser -{ - Parser(Ice.Communicator communicator, LibraryPrx library) - { - _library = library; - } - - void - usage() - { - System.err.print( - "help Print this message.\n" + - "exit, quit Exit this program.\n" + - "add isbn title authors Create new book.\n" + - "isbn NUMBER Find all books that start with the given ISBN number.\n" + - "authors NAME Find all books by the given authors.\n" + - "title NAME Find all books which have the given title.\n" + - "next Set the current book to the next one that was found.\n" + - "current Display the current book.\n" + - "rent NAME Rent the current book for customer NAME.\n" + - "return Return the currently rented book.\n" + - "remove Permanently remove the current book from the library.\n"); - } - - void - addBook(java.util.List<String> args) - { - if(args.size() != 3) - { - error("`add' requires exactly three arguments (type `help' for more info)"); - return; - } - - try - { - String isbn = args.get(0); - String title = args.get(1); - - java.util.List<String> authors = new java.util.LinkedList<String>(); - java.util.StringTokenizer st = new java.util.StringTokenizer(args.get(2), ","); - while(st.hasMoreTokens()) - { - authors.add(st.nextToken().trim()); - } - - _library.createBook(isbn, title, authors); - System.out.println("added new book with isbn " + isbn); - } - catch(BookExistsException ex) - { - error("the book already exists"); - } - catch(InvalidISBNException ex) - { - error("invalid ISBN"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - findIsbn(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`isbn' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - if(_query != null) - { - try - { - _query.destroy(); - } - catch(Exception e) - { - // Ignore - } - _query = null; - _current = null; - } - - BookDescriptionSeqHolder first = new BookDescriptionSeqHolder(); - Ice.IntHolder nrows = new Ice.IntHolder(); - BookQueryResultPrxHolder result = new BookQueryResultPrxHolder(); - _library.queryByIsbn(args.get(0), 1, first, nrows, result); - - System.out.println(nrows.value + " results"); - if(nrows.value == 0) - { - return; - } - - _current = first.value.get(0); - _query = result.value; - printCurrent(); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - findAuthors(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`authors' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - if(_query != null) - { - try - { - _query.destroy(); - } - catch(Exception e) - { - // Ignore - } - _query = null; - _current = null; - } - - BookDescriptionSeqHolder first = new BookDescriptionSeqHolder(); - Ice.IntHolder nrows = new Ice.IntHolder(); - BookQueryResultPrxHolder result = new BookQueryResultPrxHolder(); - _library.queryByAuthor(args.get(0), 1, first, nrows, result); - - System.out.println(nrows.value + " results"); - if(nrows.value == 0) - { - return; - } - - _current = first.value.get(0); - _query = result.value; - printCurrent(); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - findTitle(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`title' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - if(_query != null) - { - try - { - _query.destroy(); - } - catch(Exception e) - { - // Ignore - } - _query = null; - _current = null; - } - - BookDescriptionSeqHolder first = new BookDescriptionSeqHolder(); - Ice.IntHolder nrows = new Ice.IntHolder(); - BookQueryResultPrxHolder result = new BookQueryResultPrxHolder(); - _library.queryByTitle(args.get(0), 1, first, nrows, result); - - System.out.println(nrows.value + " results"); - if(nrows.value == 0) - { - return; - } - - _current = first.value.get(0); - _query = result.value; - printCurrent(); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - nextFoundBook() - { - if(_query == null) - { - System.out.println("no next book"); - return; - } - - try - { - Ice.BooleanHolder destroyed = new Ice.BooleanHolder(); - java.util.List<BookDescription> next = _query.next(1, destroyed); - if(next.size() > 0) - { - _current = next.get(0); - } - else - { - assert destroyed.value; - _current = null; - } - if(destroyed.value) - { - _query = null; - } - printCurrent(); - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("the query object no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - printCurrent() - { - if(_current != null) - { - System.out.println("current book is:"); - System.out.println("isbn: " + _current.isbn); - System.out.println("title: " + _current.title); - System.out.println("authors: " + _current.authors); - if(_current.rentedBy.length() > 0) - { - System.out.println("rented: " + _current.rentedBy); - } - } - else - { - System.out.println("no current book"); - } - } - - void - rentCurrent(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`rent' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - if(_current != null) - { - _current.proxy.rentBook(args.get(0)); - System.out.println("the book is now rented by `" + args.get(0) + "'"); - _current = _current.proxy.describe(); - } - else - { - System.out.println("no current book"); - } - } - catch(BookRentedException ex) - { - System.out.println("the book has already been rented"); - } - catch(InvalidCustomerException ex) - { - System.out.println("the customer name is invalid"); - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current book no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - returnCurrent() - { - try - { - if(_current != null) - { - _current.proxy.returnBook(); - System.out.println( "the book has been returned"); - _current = _current.proxy.describe(); - } - else - { - System.out.println("no current book"); - } - } - catch(BookNotRentedException ex) - { - System.out.println("the book is not currently rented"); - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current book no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - removeCurrent() - { - try - { - if(_current != null) - { - _current.proxy.destroy(); - _current = null; - System.out.println("removed current book" ); - } - else - { - System.out.println("no current book" ); - } - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current book no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - error(String s) - { - System.err.println("error: " + s); - } - - void - warning(String s) - { - System.err.println("warning: " + s); - } - - String - getInput() - { - System.out.print(">>> "); - System.out.flush(); - - try - { - return _in.readLine(); - } - catch(java.io.IOException e) - { - return null; - } - } - - int - parse() - { - _query = null; - _current = null; - - _in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - int - parse(String file) - { - _query = null; - _current = null; - - try - { - _in = new java.io.BufferedReader(new java.io.FileReader(file)); - } - catch(java.io.FileNotFoundException ex) - { - error(ex.getMessage()); - return 1; - } - - Grammar g = new Grammar(this); - g.parse(); - - System.out.println(); - - try - { - _in.close(); - } - catch(java.io.IOException ex) - { - } - - return 0; - } - - private BookQueryResultPrx _query; - private BookDescription _current; - - private LibraryPrx _library; - - private java.io.BufferedReader _in; -} diff --git a/java/demo/Database/library/README b/java/demo/Database/library/README deleted file mode 100644 index 15d78ff9e02..00000000000 --- a/java/demo/Database/library/README +++ /dev/null @@ -1,121 +0,0 @@ -MySQL JDBC Demo -=============== - -This demo shows how to implement an Ice server that uses MariaDB or mysql -through a JDBC API and demonstrates the following techniques: - - - Mapping relational data to Ice objects, and in particular the - conversion between Ice and JDBC types. - - Using a JDBC connection pool to provide JDBC connections for Ice - requests. - - Using an Ice servant locator. - - Using a dispatch interceptor. - - -Setting up the demo -------------------- - -1. Install mysql or MariaDB as necessary. - -2. Download version 5.1.31 of the mysql JDBC connector here: - - http://dev.mysql.com/downloads/connector/j/5.1.html - - After extracting the archive, add mysql-connector-java-5.1.31-bin.jar - to your CLASSPATH. - - Alternatively, for MariaDB Download version 1.1.7 of the MariaDB Client - Library for Java Applications here: - - https://downloads.mariadb.org/client-java/+releases/ - - After downloading the jar, add mariadb-java-client-1.1.7.jar to your - CLASSPATH. You must also edit config.server and change the JDBC.Url and - JDBC.DriverClassName to the MariaDB configurations. - -3. Create a database named "library" and grant privileges to a user. In - the commands below, replace USER with the name you have chosen and - PASSWORD with a suitable password: - - $ mysql -u root -p - Enter password: - Welcome to the MySQL monitor. - - mysql> CREATE DATABASE library; - Query OK, 1 row affected (0.00 sec) - - mysql> GRANT ALL PRIVILEGES ON library.* TO "USER"@"localhost" - -> IDENTIFIED BY "PASSWORD"; - Query OK, 0 rows affected (0.00 sec) - - mysql> FLUSH PRIVILEGES; - Query OK, 0 rows affected (0.01 sec) - - mysql> EXIT - -4. Create the SQL tables using the script createTypes.sql: - - $ mysql --user=USER --password=PASSWORD library < createTypes.sql - -5. Edit the JDBC properties in config.server to reflect your selected - user name and password: - - JDBC.Username=USER - JDBC.Password=PASSWORD - -NOTES: - These instructions assume that the demo server runs on the same - host as the database server. If you intend to run the demo server on - a different host than the database server, you will need to revise - the mysql privileges as well as the JDBC URL in config.server. - - In order to get correct results when using multiple concurrent - clients, you need to use the SERIALIZABLE isolation level. Refer - to the mysql documentation for instructions on how to set the - isolation level: - - http://dev.mysql.com/doc/refman/5.0/en/set-transaction.html - -6. Add the Ice jar (ice-3.6.0.jar) and the location of the demo classes - (build/classes/main) to your CLASSPATH. - - -Running the demo ----------------- - -To run the demo, first start the server: - -$ java Server - -The demo includes a text file named "books" containing a series of -commands that populate the server's database with a collection of -books. Pass this file as an argument the first time you run the -client. In another window: - -$ java Client books - -Type "help" to get a list of valid commands. - - -Running the demo with Glacier2 ------------------------------- - -The demo also supports a Glacier2 deployment. You will need to edit -config.client and uncomment this configuration property: - -#Ice.Default.Router=DemoGlacier2/router:ssl -p 4064 -h 127.0.0.1 - -To run the demo using Glacier2, first start the server: - -$ java Server - -In a separate window, start the Glacier2 router: - -$ glacier2router --Ice.Config=config.glacier2 - -In a separate window, start the client: - -$ java Client books - -Omit the "books" argument if you have already populated the server's -database. diff --git a/java/demo/Database/library/ReapTask.java b/java/demo/Database/library/ReapTask.java deleted file mode 100644 index ed15614eb9d..00000000000 --- a/java/demo/Database/library/ReapTask.java +++ /dev/null @@ -1,109 +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 Demo.*; - -class ReapTask implements Runnable -{ - static class SessionProxyPair - { - SessionProxyPair(Demo.SessionPrx p, SessionI s) - { - glacier2proxy = null; - proxy = p; - session = s; - } - - SessionProxyPair(Glacier2.SessionPrx p, SessionI s) - { - glacier2proxy = p; - proxy = null; - session = s; - } - - Glacier2.SessionPrx glacier2proxy; - Demo.SessionPrx proxy; - SessionI session; - } - - ReapTask(Ice.Logger logger, long timeout) - { - _logger = logger; - _timeout = timeout; - } - - @Override - synchronized public void - run() - { - java.util.Iterator<SessionProxyPair> p = _sessions.iterator(); - while(p.hasNext()) - { - SessionProxyPair s = p.next(); - try - { - // - // Session destruction may take time in a - // real-world example. Therefore the current time - // is computed for each iteration. - // - if((System.currentTimeMillis() - s.session.timestamp()) > _timeout * 1000) - { - _logger.trace("ReapTask", "The session " + - s.proxy.ice_getCommunicator().identityToString(s.proxy.ice_getIdentity()) + - " has timed out."); - if(s.proxy != null) - { - s.proxy.destroy(); - } - else - { - s.glacier2proxy.destroy(); - } - p.remove(); - } - } - catch(Ice.ObjectNotExistException e) - { - p.remove(); - } - } - } - - synchronized public void - terminate() - { - // Destroy each of the sessions, releasing any resources they - // may hold. This calls directly on the session, not via the - // proxy since terminate() is called after the communicator is - // shutdown, which means calls on collocated objects are not - // permitted. - for(SessionProxyPair p : _sessions) - { - p.session.shutdown(); - } - _sessions.clear(); - } - - synchronized public void - add(SessionPrx proxy, SessionI session) - { - _sessions.add(new SessionProxyPair(proxy, session)); - } - - synchronized public void - add(Glacier2.SessionPrx proxy, SessionI session) - { - _sessions.add(new SessionProxyPair(proxy, session)); - } - - private final long _timeout; - private Ice.Logger _logger; - private java.util.List<SessionProxyPair> _sessions = new java.util.LinkedList<SessionProxyPair>(); -} diff --git a/java/demo/Database/library/RunParser.java b/java/demo/Database/library/RunParser.java deleted file mode 100644 index 978446389d1..00000000000 --- a/java/demo/Database/library/RunParser.java +++ /dev/null @@ -1,203 +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 Demo.*; - -class RunParser -{ - // - // Adapter for the two types of session objects. - // - interface SessionAdapter - { - public LibraryPrx getLibrary(); - public void destroy(); - public void refresh(); - public long getTimeout(); - } - - static SessionAdapter - createSession(String appName, Ice.Communicator communicator) { - SessionAdapter session; - final Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.uncheckedCast(communicator.getDefaultRouter()); - if(router != null) - { - Glacier2.SessionPrx glacier2session = null; - long timeout; - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - while(true) - { - System.out.println("This demo accepts any user-id / password combination."); - try - { - String id; - System.out.print("user id: "); - System.out.flush(); - id = in.readLine(); - - String pw; - System.out.print("password: "); - System.out.flush(); - pw = in.readLine(); - - try - { - glacier2session = router.createSession(id, pw); - timeout = router.getSessionTimeout() / 2; - break; - } - catch(Glacier2.PermissionDeniedException ex) - { - System.out.println("permission denied:\n" + ex.reason); - } - catch(Glacier2.CannotCreateSessionException ex) - { - System.out.println("cannot create session:\n" + ex.reason); - } - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - } - } - final long to = timeout; - final Glacier2SessionPrx sess = Glacier2SessionPrxHelper.uncheckedCast(glacier2session); - session = new SessionAdapter() - { - @Override - public LibraryPrx getLibrary() - { - return sess.getLibrary(); - } - - @Override - public void destroy() - { - try - { - router.destroySession(); - } - catch(Glacier2.SessionNotExistException ex) - { - } - catch(Ice.ConnectionLostException ex) - { - // - // Expected: the router closed the connection. - // - } - } - - @Override - public void refresh() - { - sess.refresh(); - } - - @Override - public long getTimeout() - { - return to; - } - }; - } - else - { - SessionFactoryPrx factory = SessionFactoryPrxHelper.checkedCast( - communicator.propertyToProxy("SessionFactory.Proxy")); - if(factory == null) - { - System.err.println(appName + ": invalid object reference"); - return null; - } - - final SessionPrx sess = factory.create(); - final long timeout = factory.getSessionTimeout()/2; - session = new SessionAdapter() - { - @Override - public LibraryPrx getLibrary() - { - return sess.getLibrary(); - } - - @Override - public void destroy() - { - sess.destroy(); - } - - @Override - public void refresh() - { - sess.refresh(); - } - - @Override - public long getTimeout() - { - return timeout; - } - }; - } - return session; - } - - static int - runParser(String appName, String[] args, final Ice.Communicator communicator) - { - final SessionAdapter session = createSession(appName, communicator); - if(session == null) - { - return 1; - } - - java.util.concurrent.ScheduledExecutorService executor = java.util.concurrent.Executors.newScheduledThreadPool(1); - executor.scheduleAtFixedRate(new Runnable() - { - @Override - public void - run() - { - try - { - session.refresh(); - } - catch(Ice.LocalException ex) - { - communicator.getLogger().warning("SessionRefreshThread: " + ex); - // Exceptions thrown from the executor task supress subsequent execution - // of the task. - throw ex; - } - } - }, session.getTimeout(), session.getTimeout(), java.util.concurrent.TimeUnit.SECONDS); - - LibraryPrx library = session.getLibrary(); - - Parser parser = new Parser(communicator, library); - - int rc = 0; - - if(args.length == 1) - { - rc = parser.parse(args[0]); - } - - if(rc == 0) - { - rc = parser.parse(); - } - - executor.shutdown(); - session.destroy(); - - return rc; - } -} diff --git a/java/demo/Database/library/SQLRequestContext.java b/java/demo/Database/library/SQLRequestContext.java deleted file mode 100644 index bc506e2ad98..00000000000 --- a/java/demo/Database/library/SQLRequestContext.java +++ /dev/null @@ -1,147 +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. -// -// ********************************************************************** - -// -// A SQL request context encapsulates SQL resources allocated in the -// process of executing a request, such as the database connection, -// and associated SQL statements. -// -// The request context is automatically destroyed at the end of a -// request. -// -// When the request context is destroyed, the transaction is either -// automatically committed or rolled back, depending whether the -// request executed successfully. -// -class SQLRequestContext -{ - public static SQLRequestContext - getCurrentContext() - { - return _contextMap.get(Thread.currentThread()); - } - - public static void - initialize(Ice.Logger logger, ConnectionPool pool) - { - assert _logger == null; - assert _pool == null; - - _logger = logger; - _pool = pool; - } - - public java.sql.PreparedStatement - prepareStatement(String sql) - throws java.sql.SQLException - { - java.sql.PreparedStatement stmt = _conn.prepareStatement(sql); - _statements.add(stmt); - return stmt; - } - - public java.sql.PreparedStatement - prepareStatement(String sql, int autoGeneratedKeys) - throws java.sql.SQLException - { - java.sql.PreparedStatement stmt = _conn.prepareStatement(sql, autoGeneratedKeys); - _statements.add(stmt); - return stmt; - } - - public void - destroy(boolean commit) - { - destroyInternal(commit); - } - - public void - error(String prefix, Exception ex) - { - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - _logger.error(prefix + ": error:\n" + sw.toString()); - } - - SQLRequestContext() - { - _conn = _pool.acquire(); - - if(_trace) - { - _logger.trace("SQLRequestContext", "create new context: " + this + - " thread: " + Thread.currentThread() + - ": connection: " + _conn); - } - _contextMap.put(Thread.currentThread(), this); - } - - // Called only during the dispatch process. - void - destroyFromDispatch(boolean commit) - { - // Remove the current context from the thread->context - // map. - SQLRequestContext context = _contextMap.remove(Thread.currentThread()); - assert context != null; - destroyInternal(commit); - } - - private void - destroyInternal(boolean commit) - { - // Release all resources. - try - { - if(commit) - { - _conn.commit(); - if(_trace) - { - _logger.trace("SQLRequestContext", "commit context: " + this); - } - } - else - { - _conn.rollback(); - if(_trace) - { - _logger.trace("SQLRequestContext", "rollback context: " + this); - } - } - - for(java.sql.Statement p : _statements) - { - p.close(); - } - } - catch(java.sql.SQLException e) - { - error("SQLRequestContext", e); - } - - _pool.release(_conn); - - _statements.clear(); - _conn = null; - } - - // A map of threads to request contexts. - private static java.util.Map<Thread, SQLRequestContext> _contextMap = - java.util.Collections.synchronizedMap(new java.util.HashMap<Thread, SQLRequestContext>()); - - private static Ice.Logger _logger = null; - private static ConnectionPool _pool = null; - - private boolean _trace = true; - private java.util.List<java.sql.Statement> _statements = new java.util.LinkedList<java.sql.Statement>(); - private java.sql.Connection _conn; -} diff --git a/java/demo/Database/library/Scanner.java b/java/demo/Database/library/Scanner.java deleted file mode 100644 index c13231a6ab5..00000000000 --- a/java/demo/Database/library/Scanner.java +++ /dev/null @@ -1,283 +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. -// -// ********************************************************************** - -class Scanner -{ - Scanner(Parser p) - { - _parser = p; - } - - Token - nextToken() - { - String s = next(); - if(s == null) - { - return null; - } - - if(s.equals(";")) - { - return new Token(Token.TOK_SEMI); - } - else if(s.equals("help")) - { - return new Token(Token.TOK_HELP); - } - else if(s.equals("exit") || s.equals("quit")) - { - return new Token(Token.TOK_EXIT); - } - else if(s.equals("add")) - { - return new Token(Token.TOK_ADD_BOOK); - } - else if(s.equals("isbn")) - { - return new Token(Token.TOK_FIND_ISBN); - } - else if(s.equals("authors")) - { - return new Token(Token.TOK_FIND_AUTHORS); - } - else if(s.equals("title")) - { - return new Token(Token.TOK_FIND_TITLE); - } - else if(s.equals("next")) - { - return new Token(Token.TOK_NEXT_FOUND_BOOK); - } - else if(s.equals("current")) - { - return new Token(Token.TOK_PRINT_CURRENT); - } - else if(s.equals("rent")) - { - return new Token(Token.TOK_RENT_BOOK); - } - else if(s.equals("return")) - { - return new Token(Token.TOK_RETURN_BOOK); - } - else if(s.equals("remove")) - { - return new Token(Token.TOK_REMOVE_CURRENT); - } - else - { - return new Token(Token.TOK_STRING, s); - } - } - - static private class EndOfInput extends Exception - { - } - - private char - get() - throws EndOfInput - { - // - // If there is an character in the unget buffer, return it. - // - if(_unget) - { - _unget = false; - return _ungetChar; - } - - // - // No current buffer? - // - if(_buf == null) - { - _buf = _parser.getInput(); - _pos = 0; - if(_buf == null) - { - throw new EndOfInput(); - } - } - - // - // At the end-of-buffer? - // - while(_pos >= _buf.length()) - { - _buf = null; - _pos = 0; - return '\n'; - } - - return _buf.charAt(_pos++); - } - - // - // unget only works with one character. - // - private void - unget(char c) - { - assert(!_unget); - _unget = true; - _ungetChar = c; - } - - private String - next() - { - // - // Eat any whitespace. - // - char c; - try - { - do - { - c = get(); - } - while(Character.isWhitespace(c) && c != '\n'); - } - catch(EndOfInput ignore) - { - return null; - } - - StringBuilder buf = new StringBuilder(128); - - if(c == ';' || c == '\n') - { - buf.append(';'); - } - else if(c == '\'') - { - try - { - while(true) - { - c = get(); - if(c == '\'') - { - break; - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else if(c == '\"') - { - try - { - while(true) - { - c = get(); - if(c == '\"') - { - break; - } - else if(c == '\\') - { - try - { - char next = get(); - switch(next) - { - case '\\': - case '"': - { - buf.append(next); - break; - } - - case 'n': - { - buf.append('\n'); - break; - } - - case 'r': - { - buf.append('\r'); - break; - } - - case 't': - { - buf.append('\t'); - break; - } - - case 'f': - { - buf.append('\f'); - break; - } - - default: - { - buf.append(c); - unget(next); - } - } - } - catch(EndOfInput e) - { - buf.append(c); - } - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else - { - // - // Otherwise it's a string. - // - try - { - do - { - buf.append(c); - c = get(); - } - while(!Character.isWhitespace(c) && c != ';' && c != '\n'); - - unget(c); - } - catch(EndOfInput ignore) - { - } - } - - return buf.toString(); - } - - private Parser _parser; - private boolean _unget = false; - private char _ungetChar; - private String _buf = null; - private int _pos; -} diff --git a/java/demo/Database/library/Server.java b/java/demo/Database/library/Server.java deleted file mode 100644 index 63e67b3ad76..00000000000 --- a/java/demo/Database/library/Server.java +++ /dev/null @@ -1,139 +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. -// -// ********************************************************************** - - - -class Server extends Ice.Application -{ - static class LocatorI implements Ice.ServantLocator - { - @Override - public Ice.Object - locate(Ice.Current c, Ice.LocalObjectHolder cookie) - { - assert c.id.category.equals("book"); - return _servant; - } - - @Override - public void - finished(Ice.Current c, Ice.Object servant, Object cookie) - { - } - - @Override - public void - deactivate(String category) - { - } - - LocatorI(Ice.Object servant) - { - _servant = new DispatchInterceptorI(servant); - } - - private Ice.Object _servant; - } - - @Override - public int - run(String[] args) - { - args = communicator().getProperties().parseCommandLineOptions("JDBC", args); - - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.Properties properties = communicator().getProperties(); - - String username = properties.getProperty("JDBC.Username"); - String password = properties.getProperty("JDBC.Password"); - String url = properties.getProperty("JDBC.Url"); - int nConnections = properties.getPropertyAsIntWithDefault("JDBC.NumConnections", 5); - if(nConnections < 1) - { - nConnections = 1; - } - ConnectionPool pool = null; - Ice.Logger logger = communicator().getLogger(); - - try - { - Class.forName(properties.getProperty("JDBC.DriverClassName")).newInstance(); - } - catch(Exception e) - { - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - e.printStackTrace(pw); - pw.flush(); - System.err.println("failed to initialize mysql driver:\n" + sw.toString()); - return 1; - } - - try - { - pool = new ConnectionPool(logger, url, username, password, nConnections); - } - catch(java.sql.SQLException e) - { - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - e.printStackTrace(pw); - pw.flush(); - System.err.println("failed to create connection pool: SQLException:\n" + sw.toString()); - return 1; - } - - long timeout = properties.getPropertyAsIntWithDefault("SessionTimeout", 30); - - java.util.concurrent.ScheduledExecutorService executor = java.util.concurrent.Executors.newScheduledThreadPool(1); - ReapTask reaper = new ReapTask(logger, timeout); - executor.scheduleAtFixedRate(reaper, timeout/2, timeout/2, java.util.concurrent.TimeUnit.SECONDS); - - // - // Create an object adapter - // - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("SessionFactory"); - - SQLRequestContext.initialize(logger, pool); - adapter.addServantLocator(new LocatorI(new BookI()), "book"); - - adapter.add(new SessionFactoryI(logger, reaper, timeout), communicator().stringToIdentity("SessionFactory")); - adapter.add(new Glacier2SessionManagerI(logger, reaper), - communicator().stringToIdentity("LibrarySessionManager")); - - // - // Everything ok, let's go. - // - adapter.activate(); - - shutdownOnInterrupt(); - communicator().waitForShutdown(); - defaultInterrupt(); - - executor.shutdown(); - reaper.terminate(); - - pool.destroy(); - - return 0; - } - - static public void - main(String[] args) - { - Server app = new Server(); - int status = app.main("demo.Database.library.Server", args, "config.server"); - System.exit(status); - } -} diff --git a/java/demo/Database/library/Session.ice b/java/demo/Database/library/Session.ice deleted file mode 100644 index 783519db138..00000000000 --- a/java/demo/Database/library/Session.ice +++ /dev/null @@ -1,79 +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 Demo -{ - -/* Forward declaration. */ -interface Library; - -/** - * - * The session object. This is used to retrieve a per-session library - * on behalf of the client. If the session is not refreshed on a - * periodic basis, it will be automatically destroyed. - * - */ -interface Session -{ - /** - * - * Get the library object. - * - * @return A proxy for the new library. - * - **/ - Library* getLibrary(); - - /** - * - * Refresh a session. If a session is not refreshed on a regular - * basis by the client, it will be automatically destroyed. - * - **/ - idempotent void refresh(); - - /** - * - * Destroy the session. - * - **/ - void destroy(); -}; - -/** - * - * Interface to create new sessions. - * - **/ -interface SessionFactory -{ - /** - * - * Create a session. - * - * @return A proxy to the session. - * - **/ - Session* create(); - - /** - * - * Get the value of the session timeout. Sessions are destroyed - * if they see no activity for this period of time. - * - * @return The timeout (in seconds). - * - **/ - ["nonmutating"] idempotent long getSessionTimeout(); -}; - -}; diff --git a/java/demo/Database/library/SessionFactoryI.java b/java/demo/Database/library/SessionFactoryI.java deleted file mode 100644 index 73c47b9a537..00000000000 --- a/java/demo/Database/library/SessionFactoryI.java +++ /dev/null @@ -1,48 +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 Demo.*; - -class SessionFactoryI extends _SessionFactoryDisp -{ - @Override - public synchronized SessionPrx - create(Ice.Current c) - { - SessionI session = new SessionI(_logger, c.adapter); - _SessionTie servant = new _SessionTie(session); - - SessionPrx proxy = SessionPrxHelper.uncheckedCast(c.adapter.addWithUUID(servant)); - - _logger.trace("SessionFactory", "create new session: " + - c.adapter.getCommunicator().identityToString(proxy.ice_getIdentity())); - - _reaper.add(proxy, session); - - return proxy; - } - - @Override - public long - getSessionTimeout(Ice.Current c) - { - return _timeout; - } - - SessionFactoryI(Ice.Logger logger, ReapTask reaper, long timeout) - { - _logger = logger; - _reaper = reaper; - _timeout = timeout; - } - - private Ice.Logger _logger; - private ReapTask _reaper; - private long _timeout; -} diff --git a/java/demo/Database/library/SessionI.java b/java/demo/Database/library/SessionI.java deleted file mode 100644 index 57874837d8a..00000000000 --- a/java/demo/Database/library/SessionI.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 Demo.*; - -class SessionI implements _SessionOperations, _Glacier2SessionOperations -{ - @Override - synchronized public LibraryPrx - getLibrary(Ice.Current c) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - return _library; - } - - @Override - synchronized public void - refresh(Ice.Current c) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - _timestamp = System.currentTimeMillis(); - } - - synchronized public long - getSessionTimeout(Ice.Current c) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - return 5000; - } - - @Override - synchronized public void - destroy(Ice.Current c) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - - _destroyed = true; - _logger.trace("Session", "session " + c.adapter.getCommunicator().identityToString(c.id) + - " is now destroyed."); - - // This method is never called on shutdown of the server. - _libraryI.destroy(); - c.adapter.remove(_library.ice_getIdentity()); - c.adapter.remove(c.id); - } - - // Called on application shutdown. - synchronized public void - shutdown() - { - if(!_destroyed) - { - _destroyed = true; - _libraryI.shutdown(); - } - } - - synchronized public long - timestamp() - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - return _timestamp; - } - - SessionI(Ice.Logger logger, Ice.ObjectAdapter adapter) - { - _logger = logger; - _timestamp = System.currentTimeMillis(); - _libraryI = new LibraryI(); - _library = LibraryPrxHelper.uncheckedCast(adapter.addWithUUID(new DispatchInterceptorI(_libraryI))); - } - - private Ice.Logger _logger; - private boolean _destroyed = false; // true if destroy() was called, false otherwise. - private long _timestamp; // The last time the session was refreshed. - private LibraryPrx _library; - private LibraryI _libraryI; -} diff --git a/java/demo/Database/library/Token.java b/java/demo/Database/library/Token.java deleted file mode 100644 index 3c78830ddad..00000000000 --- a/java/demo/Database/library/Token.java +++ /dev/null @@ -1,40 +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. -// -// ********************************************************************** - -class Token -{ - public static final int TOK_HELP = 0; - public static final int TOK_EXIT = 1; - public static final int TOK_ADD_BOOK = 2; - public static final int TOK_FIND_ISBN = 3; - public static final int TOK_FIND_AUTHORS = 4; - public static final int TOK_FIND_TITLE = 5; - public static final int TOK_NEXT_FOUND_BOOK = 6; - public static final int TOK_PRINT_CURRENT = 7; - public static final int TOK_RENT_BOOK = 8; - public static final int TOK_RETURN_BOOK = 9; - public static final int TOK_REMOVE_CURRENT = 10; - public static final int TOK_STRING = 11; - public static final int TOK_SEMI = 12; - - int type; - String value; - - Token(int t) - { - type = t; - value = null; - } - - Token(int t, String v) - { - type = t; - value = v; - } -} diff --git a/java/demo/Database/library/books b/java/demo/Database/library/books deleted file mode 100644 index 18836dbdba6..00000000000 --- a/java/demo/Database/library/books +++ /dev/null @@ -1,30 +0,0 @@ -add '096447963X' 'The Dragon Style (Learn to Play Go, Volume III)' 'Janice Kim, Jeong Soo-Hyun' ; -add '0964479613' "Learn to Play Go: A Master's Guide to the Ultimate Game (Volume I)" 'Janice Kim, Jeong Soo-Hyun' ; -add '0964479621' 'The Way of the Moving Horse (Learn to Play Go, Volume II)' 'Janice Kim, Jeong Soo-Hyun' ; -add '0964479648' 'Battle Strategies (Learn to Play Go Series)' 'Janice Kim, Jeong Soo-Hyun' ; -add '0201889544' 'The C++ Programming Language' 'Bjarne Stroustrup' ; -add '0201543303' 'The Design and Evolution of C++' 'Bjarne Stroustrup' ; -add '0201700735' 'The C++ Programming Language Special Edition' 'Bjarne Stroustrup' ; -add '0201379260' 'The C++ Standard Library : A Tutorial and Reference' 'Nicolai M. Josuttis' ; -add '0201749629' 'Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library' 'Scott Meyers' ; -add '0201924889' 'Effective C++: 50 Specific Ways to Improve Your Programs and Design' 'Scott Meyers' ; -add '020163371X' 'More Effective C++: 35 New Ways to Improve Your Programs and Designs' 'Scott Meyers' ; -add '0201615622' 'Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions' 'Herb Sutter' ; -add '020170434X' 'More Exceptional C++' 'Herb Sutter' ; -add '0201704315' 'Modern C++ Design: Generic Programming and Design Patterns Applied' 'Andrei Alexandrescu' ; -add '0735616353' 'Microsoft Visual C++ .NET Deluxe Learning Edition' 'Microsoft Corporation' ; -add '0735615497' 'Programming with Microsoft Visual C++ .NET, Sixth Edition (Core Reference)' 'George Shepherd, David Kruglinski' ; -add '0735614229' 'Applied Microsoft .NET Framework Programming' 'Jeffrey Richter' ; -add '0201824701' 'C++ Primer' 'Stanley B. Lippman, Josee Lajoie' ; -add '0201485184' 'Essential C++' 'Stanley B. Lippman' ; -add '020170353X' 'Accelerated C++: Practical Programming by Example' 'Andrew Koenig, Barbara E. Moo' ; -add '0201423391' 'Ruminations on C++ : A Decade of Programming Insight and Experience' 'Andrew Koenig, Barbara E. Moo' ; -add '0201179288' 'C Traps and Pitfalls' 'Andrew Koenig' ; -add '0131103628' 'The C Programming Language' 'Brian W. Kernighan, Dennis M. Ritchie' ; -add '020161586X' 'The Practice of Programming' 'Brian W. Kernighan, Rob Pike' ; -add '013937681X' 'UNIX Programming Environment, The' 'Brian W. Kernighan, Rob Pike' ; -add '0201563177' 'Advanced Programming in the UNIX(R) Environment' 'W. Richard Stevens' ; -add '0201633469' 'The Protocols (TCP/IP Illustrated, Volume 1)' 'W. Richard Stevens' ; -add '0201634953' 'TCP for Transactions, HTTP, NNTP, and the UNIX(R) Domain Protocols (TCP/IP Illustrated, Volume 3)' 'W. Richard Stevens' ; -add '013490012X' 'UNIX Network Programming, Volume 1: Networking APIs - Sockets and XTI' 'W. Richard Stevens' ; -add '0130810819' 'UNIX Network Programming: Interprocess Communications' 'W. Richard Stevens' ; diff --git a/java/demo/Database/library/build.gradle b/java/demo/Database/library/build.gradle deleted file mode 100644 index 43e73e9396e..00000000000 --- a/java/demo/Database/library/build.gradle +++ /dev/null @@ -1,35 +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. -// -// ********************************************************************** - -slice { - java { - include = ["${projectDir}"] - args = "--tie" - srcDir = '.' - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - compile localDependency("ice") - compile localDependency("glacier2") - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } -} - -// Don't create the default jar. -jar.enabled = false diff --git a/java/demo/Database/library/config.client b/java/demo/Database/library/config.client deleted file mode 100644 index ec7ea31f884..00000000000 --- a/java/demo/Database/library/config.client +++ /dev/null @@ -1,62 +0,0 @@ -# -# The client reads this property to create the reference to the -# "SessionFactory" object in the server. -# -SessionFactory.Proxy=SessionFactory:default -h localhost -p 10000 - -# -# The proxy to the Glacier2 router for all outgoing connections. This -# must match the value of Glacier2.Client.Endpoints in config.glacier2. -# -#Ice.Default.Router=DemoGlacier2/router:ssl -p 4064 -h localhost - -# -# No active connection management is permitted because of the session -# interfaces. Connections must remain established. -# -Ice.ACM.Client.Timeout=0 - -# -# Connection retry is not possible because of the session -# interfaces. Connections must remain established. -# -Ice.RetryIntervals=-1 - -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Truststore=certs.jks -IceSSL.TrustOnly.Client=CN=127.0.0.1 diff --git a/java/demo/Database/library/config.glacier2 b/java/demo/Database/library/config.glacier2 deleted file mode 100644 index 4e39bc8ae95..00000000000 --- a/java/demo/Database/library/config.glacier2 +++ /dev/null @@ -1,55 +0,0 @@ -# -# Set the Glacier2 instance name. -# -Glacier2.InstanceName=DemoGlacier2 - -# -# The client-visible endpoint of Glacier2. This should be an endpoint -# visible from the public Internet, and it should be secure. -# -Glacier2.Client.Endpoints=tcp -p 4063 -h localhost:ssl -p 4064 -h localhost - -# -# The server-visible endpoint of Glacier2. This endpoint is only -# required if callbacks are needed (leave empty otherwise). This -# should be an endpoint on an internal network (like 192.168.x.x), or -# on the loopback, so that the server is not directly accessible from -# the Internet. -# -Glacier2.Server.Endpoints=tcp -h localhost - -# -# The proxy of the session manager. -# -Glacier2.SessionManager=LibrarySessionManager:tcp -h localhost -p 10000 - -# -# For this demo, we use the null permissions verifier. This permissions -# verifier allows any user-id / password combination. -# -Glacier2.PermissionsVerifier=DemoGlacier2/NullPermissionsVerifier - -# -# The timeout for inactive sessions. If any client session is inactive -# for longer than this value, the session expires and is removed. The -# unit is seconds. -# -Glacier2.SessionTimeout=30 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL:createIceSSL -IceSSL.DefaultDir=../../../../certs -IceSSL.CertAuthFile=cacert.pem -IceSSL.CertFile=s_rsa1024.pfx -IceSSL.Password=password -IceSSL.VerifyPeer=0 diff --git a/java/demo/Database/library/config.server b/java/demo/Database/library/config.server deleted file mode 100644 index b8a0555d661..00000000000 --- a/java/demo/Database/library/config.server +++ /dev/null @@ -1,74 +0,0 @@ -# -# Configure the server endpoints. -# -SessionFactory.Endpoints=tcp -h localhost -p 10000:ssl -h localhost -p 10001 - -# JDBC configuration. -JDBC.Username=USER -JDBC.Password=PASSWORD - -# -# For mysql use the following configuration. -# -JDBC.Url=jdbc:mysql://localhost/library -JDBC.DriverClassName=com.mysql.jdbc.Driver - -# -# For MariaDB use the following configuration. -# -#JDBC.Url=jdbc:mariadb://localhost/library -#JDBC.DriverClassName=org.mariadb.jdbc.Driver - -# The number of connections in the JDBC connection pool. This number -# should be at least as big as the number of the threads in the server -# thread pool. -JDBC.NumConnections=5 - -# Number of threads in the server-side dispatch thread pool. -Ice.ThreadPool.Server.Size=5 - -# -# How long to keep sessions alive with no activity. Its best to use -# the same value as config.glacier2. -# -SessionTimeout=30 - -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.VerifyPeer=0 -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password diff --git a/java/demo/Database/library/createTypes.sql b/java/demo/Database/library/createTypes.sql deleted file mode 100644 index d6d78144aeb..00000000000 --- a/java/demo/Database/library/createTypes.sql +++ /dev/null @@ -1,43 +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. -# -# ********************************************************************** -# -# Initialize SQL tables. -# -DROP TABLE IF EXISTS books; -CREATE TABLE books -( - id INT UNSIGNED AUTO_INCREMENT NOT NULL, - PRIMARY KEY (id), - isbn CHAR(13), - title VARCHAR(255), - renter_id INT -) ENGINE=InnoDB; - -DROP TABLE IF EXISTS authors_books; -CREATE TABLE authors_books -( - book_id INT, - author_id INT -) ENGINE=InnoDB; - -DROP TABLE IF EXISTS authors; -CREATE TABLE authors -( - id INT UNSIGNED NOT NULL AUTO_INCREMENT, - PRIMARY KEY(id), - name VARCHAR(255) -) ENGINE=InnoDB; - -DROP TABLE IF EXISTS customers; -CREATE TABLE customers -( - id INT UNSIGNED NOT NULL AUTO_INCREMENT, - PRIMARY KEY(id), - name VARCHAR(255) -) ENGINE=InnoDB; diff --git a/java/demo/Freeze/README b/java/demo/Freeze/README deleted file mode 100644 index 704148f8376..00000000000 --- a/java/demo/Freeze/README +++ /dev/null @@ -1,24 +0,0 @@ -Demos in this directory: - -- bench - - A simple benchmark to measure the performance of Freeze for various - data types. - -- casino - - A gambling operation implemented using Freeze transactional evictors. - -- library - - A simple application that allows you to borrow books from a library. - It illustrates how to use Freeze for persistence. - -- phonebook - - Another application to illustrate the use of Freeze. - -- transform - - Illustrates how to transform a Freeze map when its definition - changes. diff --git a/java/demo/Freeze/bench/.externalToolBuilders/demo.Freeze.bench.slice.launch b/java/demo/Freeze/bench/.externalToolBuilders/demo.Freeze.bench.slice.launch deleted file mode 100644 index 02044b906ea..00000000000 --- a/java/demo/Freeze/bench/.externalToolBuilders/demo.Freeze.bench.slice.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="${project}"/> -<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.Freeze.bench"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Freeze.bench/Test.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Freeze.bench/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/Freeze/bench/.gitignore b/java/demo/Freeze/bench/.gitignore deleted file mode 100644 index 9c39416c539..00000000000 --- a/java/demo/Freeze/bench/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db/* diff --git a/java/demo/Freeze/bench/Client.java b/java/demo/Freeze/bench/Client.java deleted file mode 100644 index eae26b6ae9d..00000000000 --- a/java/demo/Freeze/bench/Client.java +++ /dev/null @@ -1,604 +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 Demo.*; - -class Client extends Ice.Application -{ - void - IntIntMapTest(Freeze.Map<Integer, Integer> m, boolean fast) - { - // - // Populate the database. - // - _watch.start(); - Freeze.Transaction tx = _connection.beginTransaction(); - if(fast) - { - for(int i = 0; i < _repetitions; ++i) - { - m.fastPut(i, i); - } - } - else - { - for(int i = 0; i < _repetitions; ++i) - { - m.put(i, i); - } - } - tx.commit(); - - double total = _watch.stop(); - double perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " " + ((fast) ? "fast " : "") + "writes: " + total + "ms"); - System.out.println("\ttime per write: " + perRecord + "ms"); - - // - // Read each record. - // - _watch.start(); - for(int i = 0; i < _repetitions; ++i) - { - Integer n = m.get(i); - test(n.intValue() == i); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " reads: " + total + "ms"); - System.out.println("\ttime per read: " + perRecord + "ms"); - - if(m instanceof IndexedIntIntMap) - { - IndexedIntIntMap indexedM = (IndexedIntIntMap)m; - // - // Read each record using the index - // - _watch.start(); - for(int i = 0; i < _repetitions; ++i) - { - java.util.Iterator<java.util.Map.Entry<Integer, Integer>> p = indexedM.findByValue(i); - test(p.hasNext()); - java.util.Map.Entry<Integer, Integer> e = p.next(); - test(e.getKey().intValue() == i); - m.closeAllIterators(); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " indexed reads: " + total + "ms"); - System.out.println("\ttime per indexed read: " + perRecord + "ms"); - } - - // - // Remove each record. - // - _watch.start(); - tx = _connection.beginTransaction(); - if(fast) - { - for(int i = 0; i < _repetitions; ++i) - { - test(m.fastRemove(i)); - } - } - else - { - for(int i = 0; i < _repetitions; ++i) - { - Integer n = m.remove(i); - test(n.intValue() == i); - } - } - tx.commit(); - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " " + ((fast) ? "fast " : "") + "removes: " + total + "ms"); - System.out.println("\ttime per remove: " + perRecord + "ms"); - - m.close(); - } - - interface Generator - { - int next(); - String toString(); - } - - static class RandomGenerator implements Generator - { - RandomGenerator(int seed, int max) - { - _r = new java.util.Random(0); - _max = max; - } - - public int - next() - { - return _r.nextInt(_max); - } - - public String - toString() - { - return "random(" + _max + ")"; - } - - private java.util.Random _r; - private int _max; - } - - static class SequentialGenerator implements Generator - { - SequentialGenerator(int min, int max) - { - _min = min; - _max = max; - _current = _min; - } - - public int - next() - { - int n = _current; - ++_current; - if(_current > _max) - { - _current = _min; - } - return n; - } - - public String - toString() - { - return new Integer((_max - _min) + 1).toString(); - } - - private int _min; - private int _max; - private int _current; - } - - void - generatedRead(Freeze.Map<Integer, Integer> m, int reads, Generator gen) - { - _watch.start(); - for(int i = 0; i < reads; ++i) - { - int key = gen.next(); - Integer n = m.get(key); - test(n.intValue() == key); - } - double total = _watch.stop(); - double perRecord = total / reads; - - System.out.println("\ttime for " + reads + " reads of " + gen + " records: " + total + "ms"); - System.out.println("\ttime per read: " + perRecord + "ms"); - - if(m instanceof IndexedIntIntMap) - { - IndexedIntIntMap indexedM = (IndexedIntIntMap)m; - _watch.start(); - for(int i = 0; i < reads; ++i) - { - int val = gen.next(); - java.util.Iterator<java.util.Map.Entry<Integer, Integer>> p = indexedM.findByValue(val); - test(p.hasNext()); - java.util.Map.Entry<Integer, Integer> e = p.next(); - test(e.getKey().intValue() == val); - m.closeAllIterators(); - } - total = _watch.stop(); - perRecord = total / reads; - - System.out.println("\ttime for " + reads + " reverse (indexed) reads of " + gen + " records: " + total + - "ms"); - System.out.println("\ttime per reverse (indexed) read: " + perRecord + "ms"); - } - } - - void - IntIntMapReadTest(Freeze.Map<Integer, Integer> m) - { - // - // Populate the database. - // - _watch.start(); - Freeze.Transaction tx = _connection.beginTransaction(); - for(int i = 0; i < _repetitions; ++i) - { - m.fastPut(i, i); - } - tx.commit(); - double total = _watch.stop(); - double perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " writes: " + total + "ms"); - System.out.println("\ttime per write: " + perRecord + "ms"); - - // - // Do some read tests. - // - generatedRead(m, _repetitions, new SequentialGenerator(1000, 1000)); - generatedRead(m, _repetitions, new SequentialGenerator(2000, 2009)); - generatedRead(m, _repetitions, new SequentialGenerator(3000, 3099)); - generatedRead(m, _repetitions, new SequentialGenerator(4000, 4999)); - - // - // Do a random read test. - // - generatedRead(m, _repetitions, new RandomGenerator(0, 10000)); - - // - // Remove each record. - // -/* - * For this test I don't want to remove the records because I - * want to examine the cache stats for the database. - * - _watch.start(); - for(int i = 0; i < _repetitions; ++i) - { - test(m.fastRemove(i)); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " removes: " + total + "ms"); - System.out.println("\ttime per remove: " + perRecord + "ms"); -*/ - - m.close(); - } - - void - Struct1Struct2MapTest(Freeze.Map<Struct1, Struct2> m) - { - // - // Populate the database. - // - Struct1 s1 = new Struct1(); - Struct2 s2 = new Struct2(); - _watch.start(); - Freeze.Transaction tx = _connection.beginTransaction(); - for(int i = 0; i < _repetitions; ++i) - { - s1.l = i; - s2.s = new Integer(i).toString(); - s2.s1 = s1; - m.fastPut(s1, s2); - } - tx.commit(); - double total = _watch.stop(); - double perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " writes: " + total + "ms"); - System.out.println("\ttime per write: " + perRecord + "ms"); - - // - // Read each record. - // - _watch.start(); - for(int i = 0; i < _repetitions; ++i) - { - s1.l = i; - Struct2 ns2 = m.get(s1); - test(ns2.s.equals(new Integer(i).toString())); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " reads: " + total + "ms"); - System.out.println("\ttime per read: " + perRecord + "ms"); - - // - // Optional index test - // - - if(m instanceof IndexedStruct1Struct2Map) - { - IndexedStruct1Struct2Map indexedM = (IndexedStruct1Struct2Map)m; - _watch.start(); - for(int i = 0; i < _repetitions; ++i) - { - String s = (new Integer(i)).toString(); - java.util.Iterator<java.util.Map.Entry<Struct1, Struct2>> p = indexedM.findByS(s); - test(p.hasNext()); - java.util.Map.Entry<Struct1, Struct2> e = p.next(); - test(e.getKey().l == i); - m.closeAllIterators(); - } - - for(int i = 0; i < _repetitions; ++i) - { - s1.l = i; - java.util.Iterator<java.util.Map.Entry<Struct1, Struct2>> p = indexedM.findByS1(s1); - test(p.hasNext()); - java.util.Map.Entry<Struct1, Struct2> e = p.next(); - test(e.getKey().l == i); - m.closeAllIterators(); - } - total = _watch.stop(); - perRecord = total / (2 * _repetitions); - - System.out.println("\ttime for " + 2 * _repetitions + " indexed reads: " + total + "ms"); - System.out.println("\ttime per indexed read: " + perRecord + "ms"); - } - - // - // Remove each record. - // - _watch.start(); - tx = _connection.beginTransaction(); - for(int i = 0; i < _repetitions; ++i) - { - s1.l = i; - test(m.fastRemove(s1)); - } - tx.commit(); - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " removes: " + total + "ms"); - System.out.println("\ttime per remove: " + perRecord + "ms"); - - m.close(); - } - - void - Struct1Class1MapTest(Freeze.Map<Struct1, Class1> m) - { - // - // Populate the database. - // - Struct1 s1 = new Struct1(); - Class1 c1 = new Class1(); - _watch.start(); - Freeze.Transaction tx = _connection.beginTransaction(); - for(int i = 0; i < _repetitions; ++i) - { - s1.l = i; - c1.s = new Integer(i).toString(); - m.fastPut(s1, c1); - } - tx.commit(); - double total = _watch.stop(); - double perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " writes: " + total + "ms"); - System.out.println("\ttime per write: " + perRecord + "ms"); - - // - // Read each record. - // - _watch.start(); - for(int i = 0; i < _repetitions; ++i) - { - s1.l = i; - Class1 nc1 = m.get(s1); - test(nc1.s.equals(new Integer(i).toString())); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " reads: " + total + "ms"); - System.out.println("\ttime per read: " + perRecord + "ms"); - - // - // Optional index test - // - - if(m instanceof IndexedStruct1Class1Map) - { - IndexedStruct1Class1Map indexedM = (IndexedStruct1Class1Map)m; - _watch.start(); - for(int i = 0; i < _repetitions; ++i) - { - String s = (new Integer(i)).toString(); - java.util.Iterator<java.util.Map.Entry<Struct1, Class1>> p = indexedM.findByS(s); - test(p.hasNext()); - java.util.Map.Entry<Struct1, Class1> e = p.next(); - test(e.getKey().l == i); - m.closeAllIterators(); - } - - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " indexed reads: " + total + "ms"); - System.out.println("\ttime per indexed read: " + perRecord + "ms"); - } - - // - // Remove each record. - // - _watch.start(); - tx = _connection.beginTransaction(); - for(int i = 0; i < _repetitions; ++i) - { - s1.l = i; - test(m.fastRemove(s1)); - } - tx.commit(); - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " removes: " + total + "ms"); - System.out.println("\ttime per remove: " + perRecord + "ms"); - - m.close(); - } - - void - Struct1ObjectMapTest(Freeze.Map<Struct1, Ice.Object> m) - { - // - // Populate the database. - // - Struct1 s1 = new Struct1(); - Class1 c1 = new Class1(); - Class2 c2 = new Class2(); - c2.rec = c2; - c2.obj = c1; - _watch.start(); - Freeze.Transaction tx = _connection.beginTransaction(); - for(int i = 0; i < _repetitions; ++i) - { - s1.l = i; - Ice.Object o; - if((i % 2) == 0) - { - o = c2; - } - else - { - o = c1; - } - c1.s = new Integer(i).toString(); - - m.fastPut(s1, o); - } - tx.commit(); - - double total = _watch.stop(); - double perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " writes: " + total + "ms"); - System.out.println("\ttime per write: " + perRecord + "ms"); - - // - // Read each record. - // - _watch.start(); - for(int i = 0; i < _repetitions; ++i) - { - s1.l = i; - - Ice.Object o = m.get(s1); - - Class1 nc1; - if((i % 2) == 0) - { - Class2 nc2 = (Class2)o; - test(nc2.rec == nc2); - nc1 = (Class1)nc2.obj; - } - else - { - nc1 = (Class1)o; - } - - test(nc1.s.equals(new Integer(i).toString())); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " reads: " + total + "ms"); - System.out.println("\ttime per read: " + perRecord + "ms"); - - // - // Remove each record. - // - _watch.start(); - tx = _connection.beginTransaction(); - for(int i = 0; i < _repetitions; ++i) - { - s1.l = i; - test(m.fastRemove(s1)); - } - tx.commit(); - total = _watch.stop(); - perRecord = total / _repetitions; - - System.out.println("\ttime for " + _repetitions + " removes: " + total + "ms"); - System.out.println("\ttime per remove: " + perRecord + "ms"); - - m.close(); - } - - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - _connection = Freeze.Util.createConnection(communicator(), _envName); - - System.out.println("IntIntMap (Collections API)"); - IntIntMapTest(new IntIntMap(_connection, "IntIntMap", true), false); - - System.out.println("IntIntMap (Fast API)"); - IntIntMapTest(new IntIntMap(_connection, "IntIntMap.fast", true), true); - - System.out.println("IntIntMap with index (Collections API)"); - IntIntMapTest(new IndexedIntIntMap(_connection, "IndexedIntIntMap", true), false); - - System.out.println("IntIntMap with index (Fast API)"); - IntIntMapTest(new IndexedIntIntMap(_connection, "IndexedIntIntMap.fast", true), true); - - System.out.println("Struct1Struct2Map"); - Struct1Struct2MapTest(new Struct1Struct2Map(_connection, "Struct1Struct2", true)); - - System.out.println("Struct1Struct2Map with index"); - Struct1Struct2MapTest(new IndexedStruct1Struct2Map(_connection, "IndexedStruct1Struct2", true)); - - System.out.println("Struct1Class1Map"); - Struct1Class1MapTest(new Struct1Class1Map(_connection, "Struct1Class1", true)); - - System.out.println("Struct1Class1Map with index"); - Struct1Class1MapTest(new IndexedStruct1Class1Map(_connection, "IndexedStruct1Class1", true)); - - System.out.println("Struct1ObjectMap"); - Struct1ObjectMapTest(new Struct1ObjectMap(_connection, "Struct1Object", true)); - - System.out.println("IntIntMap (read test)"); - IntIntMapReadTest(new IntIntMap(_connection, "IntIntMap", true)); - - System.out.println("IntIntMap with index (read test)"); - IntIntMapReadTest(new IndexedIntIntMap(_connection, "IndexedIntIntMap", true)); - - _connection.close(); - - return 0; - } - - private static void - test(boolean b) - { - if(!b) - { - throw new RuntimeException(); - } - } - - Client(String envName) - { - _envName = envName; - } - - static public void - main(String[] args) - { - Client app = new Client("db"); - app.main("demo.Freeze.bench.Client", args); - } - - private Freeze.Connection _connection; - private int _repetitions = 10000; - private StopWatch _watch = new StopWatch(); - private String _envName; -} diff --git a/java/demo/Freeze/bench/README b/java/demo/Freeze/bench/README deleted file mode 100644 index 97a2d8f16a3..00000000000 --- a/java/demo/Freeze/bench/README +++ /dev/null @@ -1,6 +0,0 @@ -This demo is a simple benchmark to measure the performance of Freeze -for various data types. - -To run the demo, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Freeze/bench/StopWatch.java b/java/demo/Freeze/bench/StopWatch.java deleted file mode 100644 index ed689838f97..00000000000 --- a/java/demo/Freeze/bench/StopWatch.java +++ /dev/null @@ -1,37 +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. -// -// ********************************************************************** - -class StopWatch -{ - StopWatch() - { - } - - public void - start() - { - _stopped = false; - _start = System.currentTimeMillis(); - } - - public long - stop() - { - if(!_stopped) - { - _stop = System.currentTimeMillis(); - _stopped = true; - } - return _stop - _start; - } - - private boolean _stopped; - private long _start; - private long _stop; -} diff --git a/java/demo/Freeze/bench/Test.ice b/java/demo/Freeze/bench/Test.ice deleted file mode 100644 index 4b617733675..00000000000 --- a/java/demo/Freeze/bench/Test.ice +++ /dev/null @@ -1,37 +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 Demo -{ - -struct Struct1 -{ - long l; -}; - -struct Struct2 -{ - string s; - Struct1 s1; -}; - -class Class1 -{ - string s; -}; - -class Class2 extends Class1 -{ - Object obj; - Object rec; -}; - -}; diff --git a/java/demo/Freeze/bench/build.gradle b/java/demo/Freeze/bench/build.gradle deleted file mode 100644 index af95d66c90a..00000000000 --- a/java/demo/Freeze/bench/build.gradle +++ /dev/null @@ -1,86 +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. -// -// ********************************************************************** - -slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } - freezej { - files = [file("Test.ice")] - args = "--ice" - dict { - IntIntMap { - javaType = "Demo.IntIntMap" - key = "int" - value = "int" - } - IndexedIntIntMap { - javaType = "Demo.IndexedIntIntMap" - key = "int" - value = "int" - index = [[:]] - } - Struct1Struct2Map { - javaType = "Demo.Struct1Struct2Map" - key = "Demo::Struct1" - value = "Demo::Struct2" - } - Struct1Class1Map { - javaType = "Demo.Struct1Class1Map" - key = "Demo::Struct1" - value = "Demo::Class1" - } - Struct1ObjectMap { - javaType = "Demo.Struct1ObjectMap" - key = "Demo::Struct1" - value = "Object" - } - IndexedStruct1Struct2Map { - javaType = "Demo.IndexedStruct1Struct2Map" - key = "Demo::Struct1" - value = "Demo::Struct2" - index = [[ member: 's', case: 'false'], - [ member: 's1']] - } - IndexedStruct1Class1Map { - javaType = "Demo.IndexedStruct1Class1Map" - key = "Demo::Struct1" - value = "Demo::Class1" - index = [[ member: 's', case: 'true']] - } - } - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - compile localDependency("ice") - compile localDependency("freeze") - compile files(dbJar) - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } -} - -clean { - delete fileTree(dir: 'db', excludes:['.gitignore', 'DB_CONFIG']) -} - -// Don't create the default jar. -jar.enabled = false - -demoJar("client") diff --git a/java/demo/Freeze/bench/db/.gitignore b/java/demo/Freeze/bench/db/.gitignore deleted file mode 100644 index 39af5887579..00000000000 --- a/java/demo/Freeze/bench/db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# Dummy file, so that git retains this otherwise empty directory. diff --git a/java/demo/Freeze/bench/expect.py b/java/demo/Freeze/bench/expect.py deleted file mode 100755 index 4cefbeb6c79..00000000000 --- a/java/demo/Freeze/bench/expect.py +++ /dev/null @@ -1,31 +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 - -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 -from demoscript.Freeze import bench - -sys.stdout.write("cleaning databases... ") -sys.stdout.flush() -Util.cleanDbDir("db") -print("ok") - -client = Util.spawn('java -jar build/libs/client.jar') -bench.run(client, True) diff --git a/java/demo/Freeze/casino/.externalToolBuilders/demo.Freeze.casino.slice.launch b/java/demo/Freeze/casino/.externalToolBuilders/demo.Freeze.casino.slice.launch deleted file mode 100644 index 701c5ee8a1f..00000000000 --- a/java/demo/Freeze/casino/.externalToolBuilders/demo.Freeze.casino.slice.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.Freeze.casino"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Freeze.casino/Casino.ice" type="1"/> <item path="/demo.Freeze.casino/CasinoStore.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Freeze.casino/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/Freeze/casino/.gitignore b/java/demo/Freeze/casino/.gitignore deleted file mode 100644 index ffb4199a65d..00000000000 --- a/java/demo/Freeze/casino/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -db/__catalog -db/__catalogIndexList -db/bet -db/bank -db/player -db/log.* diff --git a/java/demo/Freeze/casino/BankI.java b/java/demo/Freeze/casino/BankI.java deleted file mode 100644 index 0c07ef9fe3d..00000000000 --- a/java/demo/Freeze/casino/BankI.java +++ /dev/null @@ -1,222 +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. -// -// ********************************************************************** - -class BankI extends CasinoStore.PersistentBank -{ - @Override - public boolean - buyChips(int chips, Casino.PlayerPrx p, Ice.Current current) - { - outstandingChips += chips; - chipsSold += chips; - - CasinoStore.PersistentPlayerPrx player = CasinoStore.PersistentPlayerPrxHelper.uncheckedCast(p); - - try - { - player.win(chips); - } - catch(Ice.ObjectNotExistException one) - { - _evictor.getCurrentTransaction().rollback(); - return false; - } - - return true; - } - - @Override - public Casino.PlayerPrx[] - getPlayers(Ice.Current current) - { - java.util.Vector<Casino.PlayerPrx> result = new java.util.Vector<Casino.PlayerPrx>(); - - Freeze.EvictorIterator p = _playerEvictor.getIterator("", 10); - - while(p.hasNext()) - { - Ice.Identity ident = p.next(); - result.add(Casino.PlayerPrxHelper.uncheckedCast(current.adapter.createProxy(ident))); - } - - return result.toArray(new Casino.PlayerPrx[0]); - } - - @Override - public int - getOutstandingChips(Ice.Current current) - { - return outstandingChips; - } - - @Override - public int - getEarnings(Ice.Current current) - { - return chipsSold - outstandingChips; - } - - @Override - public int - getLiveBetCount(Ice.Current current) - { - return _betResolver.getBetCount(); - } - - @Override - public boolean - checkAllChips(Ice.Current current) - { - int playerTotal = 0; - - Casino.PlayerPrx[] players = getPlayers(current); - for(Casino.PlayerPrx player : players) - { - playerTotal += player.getChips(); - } - - System.out.println("The players hold a total of " + playerTotal + " chips"); - - int betTotal = 0; - - CasinoStore.PersistentBetPrx[] bets = getBets(current.adapter); - for(CasinoStore.PersistentBetPrx bet : bets) - { - betTotal += bet.getChipsInPlay(); - } - System.out.println("The bets hold a total of " + betTotal + " chips"); - System.out.println("players + bets chips == " + (playerTotal + betTotal)); - - System.out.println("The bank has " + outstandingChips + " outstanding chips"); - - return (playerTotal + betTotal) == outstandingChips; - } - - @Override - public Casino.BetPrx - createBet(int amount, int lifetime, Ice.Current current) - { - Ice.Identity ident = new Ice.Identity(java.util.UUID.randomUUID().toString(), "bet"); - long closeTime = System.currentTimeMillis() + lifetime; - - outstandingChips += amount; - BetI betI = new BetI(amount, closeTime, _prx, _betEvictor, _bankEdge); - - CasinoStore.PersistentBetPrx newBet = - CasinoStore.PersistentBetPrxHelper.uncheckedCast(_betEvictor.add(betI, ident)); - - _betResolver.add(newBet, closeTime); - return newBet; - } - - @Override - public void - win(int count, Ice.Current current) - { - outstandingChips -= count; - } - - @Override - public void - returnAllChips(CasinoStore.PersistentPlayerPrx p, Ice.Current current) - { - int count = 0; - - try - { - count = p.getChips(); - } - catch(Ice.ObjectNotExistException ex) - { - // - // impossible - // - assert false; - throw new Freeze.DatabaseException("returnAllChips: player does not exist"); - } - - if(count != 0) - { - try - { - p.withdraw(count); - } - catch(Casino.OutOfChipsException e) - { - // - // Impossible - // - assert false; - throw new Freeze.DatabaseException("returnAllChips: out of chips"); - } - outstandingChips -= count; - chipsSold -= count; - } - } - - @Override - public void - reloadBets(Ice.Current current) - { - CasinoStore.PersistentBetPrx[] bets = getBets(current.adapter); - for(CasinoStore.PersistentBetPrx bet : bets) - { - _betResolver.add(bet, bet.getCloseTime()); - } - } - - BankI() - { - } - - BankI(CasinoStore.PersistentBankPrx prx, - Freeze.TransactionalEvictor evictor, Freeze.TransactionalEvictor playerEvictor, - Freeze.TransactionalEvictor betEvictor, BetResolver betResolver, int bankEdge) - { - chipsSold = 0; - outstandingChips = 0; - init(prx, evictor, playerEvictor, betEvictor, betResolver, bankEdge); - } - - void - init(CasinoStore.PersistentBankPrx prx, - Freeze.TransactionalEvictor evictor, Freeze.TransactionalEvictor playerEvictor, - Freeze.TransactionalEvictor betEvictor, BetResolver betResolver, int bankEdge) - { - _prx = prx; - _evictor = evictor; - _playerEvictor = playerEvictor; - _betEvictor = betEvictor; - _betResolver = betResolver; - _bankEdge = bankEdge; - } - - private CasinoStore.PersistentBetPrx[] - getBets(Ice.ObjectAdapter adapter) - { - java.util.Vector<CasinoStore.PersistentBetPrx> result = new java.util.Vector<CasinoStore.PersistentBetPrx>(); - - Freeze.EvictorIterator p = _betEvictor.getIterator("", 100); - - while(p.hasNext()) - { - Ice.Identity ident = p.next(); - result.add(CasinoStore.PersistentBetPrxHelper.uncheckedCast(adapter.createProxy(ident))); - } - - return result.toArray(new CasinoStore.PersistentBetPrx[0]); - } - - private CasinoStore.PersistentBankPrx _prx; - private Freeze.TransactionalEvictor _evictor; - private Freeze.TransactionalEvictor _playerEvictor; - private Freeze.TransactionalEvictor _betEvictor; - private BetResolver _betResolver; - private int _bankEdge; -} diff --git a/java/demo/Freeze/casino/BetI.java b/java/demo/Freeze/casino/BetI.java deleted file mode 100644 index 962b9fbd1e5..00000000000 --- a/java/demo/Freeze/casino/BetI.java +++ /dev/null @@ -1,121 +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. -// -// ********************************************************************** - -class BetI extends CasinoStore.PersistentBet -{ - @Override - public int - getAmount(Ice.Current current) - { - return amount; - } - - @Override - public void - accept(Casino.PlayerPrx p, Ice.Current current) - throws Casino.OutOfChipsException - { - if(p == null) - { - throw new Casino.OutOfChipsException(); - } - - CasinoStore.PersistentPlayerPrx player = CasinoStore.PersistentPlayerPrxHelper.uncheckedCast(p); - - try - { - player.withdraw(amount); - potentialWinners.add(player); - } - catch(Ice.ObjectNotExistException one) - { - throw new Casino.OutOfChipsException(); - } - } - - @Override - public int - getChipsInPlay(Ice.Current current) - { - return amount * potentialWinners.size(); - } - - @Override - public long - getCloseTime(Ice.Current current) - { - return closeTime; - } - - @Override - public void - complete(int random, Ice.Current current) - { - if(random < 0) - { - random = -random; - } - - int size = potentialWinners.size(); - - // - // Pick a winner using random - // - int winnerIndex = random % (size + (_bankEdge - 1)); - - if(winnerIndex >= size) - { - winnerIndex = 0; - } - - CasinoStore.WinnerPrx winner = potentialWinners.elementAt(winnerIndex); - - try - { - winner.win(amount * size); - } - catch(Ice.ObjectNotExistException ex) - { - // - // Goes to the bank - // - winner = potentialWinners.elementAt(0); - winner.win(amount * size); - } - - // - // Self-destroys - // - _evictor.remove(current.id); - } - - BetI() - { - } - - BetI(int amount, long closeTime, CasinoStore.PersistentBankPrx bank, Freeze.TransactionalEvictor evictor, - int bankEdge) - { - this.amount = amount; - this.closeTime = closeTime; - init(evictor, bankEdge); - potentialWinners = new java.util.Vector<CasinoStore.WinnerPrx>(); - potentialWinners.add(bank); - } - - void - init(Freeze.TransactionalEvictor evictor, int bankEdge) - { - _evictor = evictor; - _bankEdge = bankEdge; - } - - private Freeze.TransactionalEvictor _evictor; - private int _bankEdge; -} diff --git a/java/demo/Freeze/casino/BetResolver.java b/java/demo/Freeze/casino/BetResolver.java deleted file mode 100644 index 2c1c9f5f1aa..00000000000 --- a/java/demo/Freeze/casino/BetResolver.java +++ /dev/null @@ -1,73 +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. -// -// ********************************************************************** - -class BetResolver -{ - BetResolver() - { - // We want the executor to shutdown even if there are scheduled tasks. - _executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); - } - - void - add(final CasinoStore.PersistentBetPrx bet, long closeTime) - { - Runnable task = new Runnable() - { - @Override - public void - run() - { - // - // Note that this is a collocated call, from a non-dispatch - // thread; even then Freeze will properly create/commit the - // transaction. - // - - try - { - bet.complete(_random.nextInt()); - } - catch(Ice.ObjectNotExistException one) - { - // - // Looks like this bet was never saved (committed) - // - } - finally - { - _betCount.decrementAndGet(); - } - } - }; - - // closeTime is milliseconds from the epoch. Convert to relative time. - long now = new java.util.Date().getTime(); - _executor.schedule(task, closeTime - now, java.util.concurrent.TimeUnit.MILLISECONDS); - - _betCount.incrementAndGet(); - } - - void - cancel() - { - _executor.shutdown(); - } - - int - getBetCount() - { - return _betCount.get(); - } - - private java.util.concurrent.ScheduledThreadPoolExecutor _executor = - new java.util.concurrent.ScheduledThreadPoolExecutor(3); - private java.util.Random _random = new java.util.Random(); - private java.util.concurrent.atomic.AtomicInteger _betCount = new java.util.concurrent.atomic.AtomicInteger(); -} diff --git a/java/demo/Freeze/casino/Casino.ice b/java/demo/Freeze/casino/Casino.ice deleted file mode 100644 index 667950b020b..00000000000 --- a/java/demo/Freeze/casino/Casino.ice +++ /dev/null @@ -1,95 +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 Casino -{ - // - // A player places bets and then either looses his chips - // or wins more - // - interface Player - { - // - // The number of chips held by this player - // - int getChips(); - - // - // Destroy this player - // - ["freeze:write"] void destroy(); - }; - - sequence<Player*> PlayerPrxSeq; - - // - // Thrown when a Player does not have enough chips to place - // a bet - // - exception OutOfChipsException {}; - - interface Bet - { - // - // The number of chips each player needs to provide to join - // this bet - // - int getAmount(); - - // - // Player p attempts to accept this bet - // Raises ObjectNotExistException if the bet is over - // - // - ["freeze:write"] void accept(Player* p) throws OutOfChipsException; - }; - - interface Bank - { - // - // Buy a number of chips for Player p; returns false when player - // does not exist - // - ["freeze:write"] bool buyChips(int chips, Player* p); - - // - // List of all Players - // - PlayerPrxSeq getPlayers(); - - // - // The number of chips sold by this Bank - // - int getOutstandingChips(); - - // - // The number of live bets - // - int getLiveBetCount(); - - // - // The number of chips earned by the Bank - // - int getEarnings(); - - // - // Verify that the total number of chips held by all known players and bets; - // match getOutstandingChips(); - // - ["freeze:read:required"] bool checkAllChips(); - - // - // Create a new bet with the given amount to join; this bet ends in - // 'lifetime' milliseconds - // - ["freeze:write"] Bet* createBet(int amount, int lifetime); - }; -}; diff --git a/java/demo/Freeze/casino/CasinoStore.ice b/java/demo/Freeze/casino/CasinoStore.ice deleted file mode 100644 index 4012798b4e6..00000000000 --- a/java/demo/Freeze/casino/CasinoStore.ice +++ /dev/null @@ -1,91 +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 - -#include <Casino.ice> -#include <Ice/Identity.ice> - -// -// Provide the persistent classes used to implement Casino -// -module CasinoStore -{ - // - // Potential bet winner - // - interface Winner - { - // - // Win a bet - // - ["freeze:write:mandatory"] void win(int count); - }; - ["java:type:java.util.Vector<WinnerPrx>:java.util.Vector<WinnerPrx>"] sequence<Winner*> WinnerPrxSeq; - - - class PersistentPlayer implements Casino::Player, Winner - { - // - // A bet withdraws a number of chips from this player - // - ["freeze:write:mandatory"] void withdraw(int count) throws Casino::OutOfChipsException; - - int chips; - }; - - class PersistentBet implements Casino::Bet - { - // - // The total number of chips in play, i.e. amount * potentialWinners.size() - // - int getChipsInPlay(); - - // - // Milliseconds since the epoch - // - long getCloseTime(); - - // - // Decide who wins and self-destroys - // - ["freeze:write"] void complete(int random); - - // - // The first potential winner is the Bank - // - WinnerPrxSeq potentialWinners; - - // - // Each potential winner puts amount in play - // - int amount; - - // - // The time when the bet completes (ms since the epoch) - // - long closeTime; - }; - - class PersistentBank implements Casino::Bank, Winner - { - // - // Player p returns all its chips - // - ["freeze:write:mandatory"] void returnAllChips(PersistentPlayer* p); - - // - // Reload the existing bets into the Bet resolver - // - void reloadBets(); - - int chipsSold; - int outstandingChips; - }; -}; diff --git a/java/demo/Freeze/casino/Client.java b/java/demo/Freeze/casino/Client.java deleted file mode 100644 index 599441abf8d..00000000000 --- a/java/demo/Freeze/casino/Client.java +++ /dev/null @@ -1,217 +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. -// -// ********************************************************************** - -public class Client extends Ice.Application -{ - // - // Number of bets placed by each player - // You can (should) increase these values by a factor of 5 or more - // on a fast system - // - static final int betCount1 = 100; - static final int betCount2 = 20; - - private void - printBalances(Casino.PlayerPrx[] players) - { - for(int i = 0; i < players.length; ++i) - { - Casino.PlayerPrx player = players[i]; - - if(player != null) - { - try - { - System.out.println(player.ice_getIdentity().name + ": " + player.getChips() + " chips"); - } - catch(Ice.ObjectNotExistException one) - { - // - // This player is gone - // - players[i] = null; - } - } - } - } - - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - java.util.Random random = new java.util.Random(); - - System.out.print("Retrieve bank and players... "); - System.out.flush(); - - Casino.BankPrx bank = Casino.BankPrxHelper. - uncheckedCast(communicator().propertyToProxy("Bank.Proxy")); - - Casino.PlayerPrx[] players = bank.getPlayers(); - System.out.println("ok"); - - System.out.println("Starting balances"); - printBalances(players); - - System.out.println("Current bank earnings: " + bank.getEarnings() + " chips"); - - System.out.println("All chips accounted for? " + (bank.checkAllChips() ? "yes" : "no")); - - System.out.print("Each player buys 3,000 chips... "); - System.out.flush(); - - for(int i = 0; i < players.length; ++i) - { - Casino.PlayerPrx player = players[i]; - if(player != null) - { - if(!bank.buyChips(3000, player)) - { - System.out.print("(" + player.ice_getIdentity().name + " is gone) "); - players[i] = null; - } - } - } - System.out.println("ok"); - - System.out.println("All chips accounted for? " + (bank.checkAllChips() ? "yes" : "no")); - - System.out.print("Create " + betCount1 + " 10-chips bets... "); - System.out.flush(); - - for(int b = 0; b < betCount1; ++b) - { - Casino.BetPrx bet = bank.createBet(10, 200 + random.nextInt(4000)); - for(int i = 0; i < players.length; ++i) - { - Casino.PlayerPrx player = players[i]; - if(player != null) - { - try - { - bet.accept(player); - } - catch(Ice.ObjectNotExistException ex) - { - // - // Bet already resolved - // - } - catch(Casino.OutOfChipsException ex) - { - System.out.print("(" + player.ice_getIdentity().name + " is out) "); - - players[i] = null; - } - } - } - } - System.out.println(" ok"); - - System.out.println("Live bets: " + bank.getLiveBetCount()); - - int index = random.nextInt(players.length); - Casino.PlayerPrx gonner = players[index]; - players[index] = null; - - if(gonner != null) - { - System.out.print("Destroying " + gonner.ice_getIdentity().name + "... "); - try - { - gonner.destroy(); - } - catch(Ice.ObjectNotExistException e) - { - // - // Ignored - // - } - System.out.println("ok"); - } - - System.out.println("All chips accounted for? " + (bank.checkAllChips() ? "yes" : "no")); - - System.out.println("Sleep for 2 seconds"); - - try - { - Thread.sleep(2000); - } - catch(InterruptedException ex) - { - } - System.out.println("Live bets: " + bank.getLiveBetCount()); - - System.out.print("Create " + betCount2 + " 10-chips bets... "); - System.out.flush(); - - for(int b = 0; b < betCount2; ++b) - { - Casino.BetPrx bet = bank.createBet(10, 200 + random.nextInt(4000)); - for(int i = 0; i < players.length; ++i) - { - Casino.PlayerPrx player = players[i]; - if(player != null) - { - try - { - bet.accept(player); - } - catch(Ice.ObjectNotExistException ex) - { - // - // Bet already resolved - // - } - catch(Casino.OutOfChipsException ex) - { - System.out.print("(" + player.ice_getIdentity().name + " is out) "); - - players[i] = null; - } - } - } - } - System.out.println(" ok"); - - System.out.println("Live bets: " + bank.getLiveBetCount()); - System.out.println("Sleep for 10 seconds"); - try - { - Thread.sleep(10000); - } - catch(InterruptedException ex) - { - } - System.out.println("Live bets: " + bank.getLiveBetCount()); - - System.out.println("Ending balances"); - printBalances(players); - - System.out.println("Current bank earnings: " + bank.getEarnings() + " chips"); - - System.out.println("All chips accounted for? " + (bank.checkAllChips() ? "yes" : "no")); - - return 0; - } - - static public void - main(String[] args) - { - Client app = new Client(); - app.main("demo.Freeze.casino.Client", args, "config.client"); - } -} diff --git a/java/demo/Freeze/casino/PlayerI.java b/java/demo/Freeze/casino/PlayerI.java deleted file mode 100644 index a7cf7fb25e3..00000000000 --- a/java/demo/Freeze/casino/PlayerI.java +++ /dev/null @@ -1,60 +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. -// -// ********************************************************************** - -class PlayerI extends CasinoStore.PersistentPlayer -{ - @Override - public int - getChips(Ice.Current current) - { - return chips; - } - - @Override - public void - destroy(Ice.Current current) - { - _bank.returnAllChips(_myPrx); - _evictor.remove(current.id); - } - - @Override - public void - withdraw(int count, Ice.Current current) - throws Casino.OutOfChipsException - { - int newBalance = chips - count; - if(newBalance < 0) - { - throw new Casino.OutOfChipsException(); - } - chips = newBalance; - } - - @Override - public void - win(int count, Ice.Current current) - { - assert count >= 0; - chips += count; - } - - void - init(CasinoStore.PersistentPlayerPrx myPrx, Freeze.TransactionalEvictor evictor, - CasinoStore.PersistentBankPrx bank) - { - _myPrx = myPrx; - _evictor = evictor; - _bank = bank; - } - - private CasinoStore.PersistentPlayerPrx _myPrx; - private Freeze.TransactionalEvictor _evictor; - private CasinoStore.PersistentBankPrx _bank; -} diff --git a/java/demo/Freeze/casino/README b/java/demo/Freeze/casino/README deleted file mode 100644 index 386a632968f..00000000000 --- a/java/demo/Freeze/casino/README +++ /dev/null @@ -1,45 +0,0 @@ -This example demonstrates the use of the Freeze Transactional Evictor -to implement a reliable gambling operation. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In another window, start the client: - -$ java -jar build/libs/client.jar - -You can run a number of clients concurrently (in different windows) -to exercise the server even more. - -Highlights: ----------- - -- The public interface of the server is specified in Casino.ice; - CasinoStore.ice is just an implementation detail of the server. - -- This demo uses a transactional evictor per servant type; this - is more efficient than storing different types of servants in - the same Freeze transactional evictor. - -- Transactions often span servants in several evictors; this works - because all the evictors use the same underlying Berkeley DB - environment. - -- The application code does not deal at all with database deadlocks; - Freeze retries automatically (and correctly) each time a deadlock is - detected and reported by Berkeley DB. - -- The application code does not perform any synchronization: with - a Freeze transactional evictor, the servants you get are either - totally read-only or private to your thread/transaction. - -- Destroying a player while this player is participating in a bet - is an interesting life-cycle situation. What happens if this player - wins a bet and is destroyed at the same time? Will chips get lost? - In fact, there is no issue thanks to Berkeley DB locking: - when a bet picks a winner, it invokes an operation on this object - (through a proxy) within a transaction. At this point, if the - object is still alive, it's locked by the transaction, which - prevents another transaction from acquiring a write lock (for - example, to destroy it). diff --git a/java/demo/Freeze/casino/Server.java b/java/demo/Freeze/casino/Server.java deleted file mode 100644 index 8adcd4ecf17..00000000000 --- a/java/demo/Freeze/casino/Server.java +++ /dev/null @@ -1,262 +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. -// -// ********************************************************************** - -class Server extends Ice.Application -{ - static class ObjectFactory implements Ice.ObjectFactory - { - ObjectFactory(Class<?> factoryClass) - { - _factoryClass = factoryClass; - } - - @Override - public Ice.Object - create(String type) - { - try - { - return (Ice.Object)_factoryClass.newInstance(); - } - catch(InstantiationException ex) - { - throw new Ice.InitializationException(ex.toString()); - } - catch(IllegalAccessException ex) - { - throw new Ice.InitializationException(ex.toString()); - } - } - - @Override - public void - destroy() - { - } - - private Class<?> _factoryClass; - } - - private java.util.Map<String, String> - createTypeMap(String defaultFacetType) - { - java.util.Map<String, String> result = new java.util.HashMap<String, String>(); - result.put("", defaultFacetType); - return result; - } - - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.Properties properties = communicator().getProperties(); - - _bankEdge = properties.getPropertyAsInt("Bank.Edge"); - if(_bankEdge < 1) - { - _bankEdge = 1; - } - System.out.println("Bank edge is " + _bankEdge); - - // - // Create an object adapter - // - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Casino"); - - // - // Register factories - // - communicator().addObjectFactory(new ObjectFactory(BankI.class), CasinoStore.PersistentBank.ice_staticId()); - communicator().addObjectFactory(new ObjectFactory(PlayerI.class), CasinoStore.PersistentPlayer.ice_staticId()); - communicator().addObjectFactory(new ObjectFactory(BetI.class), CasinoStore.PersistentBet.ice_staticId()); - - // - // Create evictors; each type gets its own type-specific evictor - // - - // - // Bank evictor - // - - Freeze.ServantInitializer bankInitializer = new Freeze.ServantInitializer() - { - @Override - public void - initialize(Ice.ObjectAdapter adapter, Ice.Identity identity, String facet, Ice.Object servant) - { - ((BankI)servant).init(_bankPrx, _bankEvictor, _playerEvictor, _betEvictor, _betResolver, _bankEdge); - } - }; - - _bankEvictor = - Freeze.Util.createTransactionalEvictor(adapter, _envName, "bank", - createTypeMap(CasinoStore.PersistentBank.ice_staticId()), - bankInitializer, null, true); - - int size = properties.getPropertyAsInt("Bank.EvictorSize"); - if(size > 0) - { - _bankEvictor.setSize(size); - } - - adapter.addServantLocator(_bankEvictor, "bank"); - - // - // Player evictor - // - - Freeze.ServantInitializer playerInitializer = new Freeze.ServantInitializer() - { - @Override - public void - initialize(Ice.ObjectAdapter adapter, Ice.Identity identity, String facet, Ice.Object servant) - { - CasinoStore.PersistentPlayerPrx prx = - CasinoStore.PersistentPlayerPrxHelper.uncheckedCast(adapter.createProxy(identity)); - ((PlayerI)servant).init(prx, _playerEvictor, _bankPrx); - } - }; - - _playerEvictor = - Freeze.Util.createTransactionalEvictor(adapter, _envName, "player", - createTypeMap(CasinoStore.PersistentPlayer.ice_staticId()), - playerInitializer, null, true); - - size = properties.getPropertyAsInt("Player.EvictorSize"); - if(size > 0) - { - _playerEvictor.setSize(size); - } - - adapter.addServantLocator(_playerEvictor, "player"); - - // - // Bet evictor - // - - Freeze.ServantInitializer betInitializer = new Freeze.ServantInitializer() - { - @Override - public void - initialize(Ice.ObjectAdapter adapter, Ice.Identity identity, String facet, Ice.Object servant) - { - ((BetI)servant).init(_betEvictor, _bankEdge); - } - }; - - _betEvictor = - Freeze.Util.createTransactionalEvictor(adapter, _envName, "bet", - createTypeMap(CasinoStore.PersistentBet.ice_staticId()), - betInitializer, null, true); - size = properties.getPropertyAsInt("Bet.EvictorSize"); - if(size > 0) - { - _betEvictor.setSize(size); - } - - adapter.addServantLocator(_betEvictor, "bet"); - - // - // Prepare startup - // - - _betResolver = new BetResolver(); - - try - { - // - // Retrieve / create the bank - // - - Ice.Identity bankId = Ice.Util.stringToIdentity("bank/Montecito"); - _bankPrx = CasinoStore.PersistentBankPrxHelper.uncheckedCast(adapter.createProxy(bankId)); - - if(!_bankEvictor.hasObject(bankId)) - { - _bankEvictor.add( - new BankI(_bankPrx, _bankEvictor, _playerEvictor, _betEvictor, _betResolver, _bankEdge), - bankId); - } - - // - // reload existing bets into the bet resolver - // - _bankPrx.reloadBets(); - - // - // Create players / recreate missing players using a transaction - // (the transaction is not really necessary here, but a good demo) - // - - String[] players = - { "al", "bob", "charlie", "dave", "ed", "fred", "gene", "herb", "irvin", "joe", "ken", "lance" }; - - - Freeze.Connection connection = Freeze.Util.createConnection(communicator(), _envName); - Freeze.Transaction tx = connection.beginTransaction(); - - _playerEvictor.setCurrentTransaction(tx); - - for(String player : players) - { - Ice.Identity ident = new Ice.Identity(player, "player"); - if(!_playerEvictor.hasObject(ident)) - { - _playerEvictor.add(new PlayerI(), ident); - } - } - - tx.commit(); - assert(_playerEvictor.getCurrentTransaction() == null); - connection.close(); - - - // - // Everything is ready, activate - // - adapter.activate(); - - shutdownOnInterrupt(); - communicator().waitForShutdown(); - defaultInterrupt(); - } - finally - { - _betResolver.cancel(); - } - return 0; - } - - Server(String envName) - { - _envName = envName; - } - - static public void - main(String[] args) - { - Server app = new Server("db"); - app.main("demo.Freeze.casino.Server", args, "config.server"); - } - - private String _envName; - - private CasinoStore.PersistentBankPrx _bankPrx; - private Freeze.TransactionalEvictor _bankEvictor; - private Freeze.TransactionalEvictor _playerEvictor; - private Freeze.TransactionalEvictor _betEvictor; - private BetResolver _betResolver; - private int _bankEdge; -} diff --git a/java/demo/Freeze/casino/build.gradle b/java/demo/Freeze/casino/build.gradle deleted file mode 100644 index 5b3310e5d85..00000000000 --- a/java/demo/Freeze/casino/build.gradle +++ /dev/null @@ -1,47 +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. -// -// ********************************************************************** - -slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - compile localDependency("ice") - compile localDependency("freeze") - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } -} - -dependencies { - compile files(dbJar) -} - - -clean { - delete fileTree(dir: 'db', excludes:['.gitignore', 'DB_CONFIG']) -} - - -// Don't create the default jar. -jar.enabled = false - -demoJar("client") -demoJar("server") diff --git a/java/demo/Freeze/casino/config.client b/java/demo/Freeze/casino/config.client deleted file mode 100644 index 1ff154b7dd8..00000000000 --- a/java/demo/Freeze/casino/config.client +++ /dev/null @@ -1,5 +0,0 @@ -# -# The client reads this property to create the reference to the -# "bank" object in the server. -# -Bank.Proxy=bank/Montecito:default -h localhost -p 10000 diff --git a/java/demo/Freeze/casino/config.server b/java/demo/Freeze/casino/config.server deleted file mode 100644 index a5391de3e50..00000000000 --- a/java/demo/Freeze/casino/config.server +++ /dev/null @@ -1,53 +0,0 @@ -# -# Configure the server endpoints. -# -Casino.Endpoints=default -h localhost -p 10000 - -# -# The bank can have more chances of winning than regular players. -# must be >= 1 -# 1 : like 1 players -# 2 : like 2 players -# etc -# -Bank.Edge=2 - -# -# Configure the ice server thread pool with 10 threads. -# -Ice.ThreadPool.Server.Size=10 - -# -# Disable Freeze deadlock warnings. -# -Freeze.Warn.Deadlocks=1 - -# -# Freeze Evictor Tracing. -# -# 0 = No evictor activity trace (default). -# 1 = Trace Ice object and facet creation and destruction, facet -# streaming time, facet saving time, object eviction (every 50 -# objects) and evictor deactivation. -# 2 = Also trace object lookups, and all object evictions. -# 3 = Also trace object retrieval from the database. -# -#Freeze.Trace.Evictor=1 - -# -# Configure the bank/bet and player evictors to rollback the -# transaction on any user exception. The default is to commit the -# transaction. -# -Freeze.Evictor.db.bank.RollbackOnUserException=1 -Freeze.Evictor.db.bet.RollbackOnUserException=1 -Freeze.Evictor.db.player.RollbackOnUserException=1 - -# -# Freeze Transaction Tracing. -# -# 0 = No transaction activity trace (default). -# 1 = Trace transaction IDs and commit and rollback activity. -# -#Freeze.Trace.Transaction=1 - diff --git a/java/demo/Freeze/casino/db/DB_CONFIG b/java/demo/Freeze/casino/db/DB_CONFIG deleted file mode 100644 index 46c0c213e7f..00000000000 --- a/java/demo/Freeze/casino/db/DB_CONFIG +++ /dev/null @@ -1,5 +0,0 @@ -# -# This flag speeds up the demo, but it's a trade-off: we loose the D -# (Durable) in ACID. See the Berkeley DB documentation for details. -# -set_flags DB_TXN_NOSYNC diff --git a/java/demo/Freeze/casino/expect.py b/java/demo/Freeze/casino/expect.py deleted file mode 100755 index ec7f1cb8f49..00000000000 --- a/java/demo/Freeze/casino/expect.py +++ /dev/null @@ -1,25 +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 - -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 -from demoscript.Freeze import casino - -casino.run('java -jar build/libs/client.jar', 'java -jar build/libs/server.jar') diff --git a/java/demo/Freeze/library/.externalToolBuilders/demo.Freeze.library.slice.launch b/java/demo/Freeze/library/.externalToolBuilders/demo.Freeze.library.slice.launch deleted file mode 100644 index 5489b97c629..00000000000 --- a/java/demo/Freeze/library/.externalToolBuilders/demo.Freeze.library.slice.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.Freeze.library"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Freeze.library/Library.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Freeze.library/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/Freeze/library/.gitignore b/java/demo/Freeze/library/.gitignore deleted file mode 100644 index 9c39416c539..00000000000 --- a/java/demo/Freeze/library/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db/* diff --git a/java/demo/Freeze/library/BookFactory.java b/java/demo/Freeze/library/BookFactory.java deleted file mode 100644 index f056d71185f..00000000000 --- a/java/demo/Freeze/library/BookFactory.java +++ /dev/null @@ -1,32 +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. -// -// ********************************************************************** - -class BookFactory implements Ice.ObjectFactory -{ - @Override - public Ice.Object - create(String type) - { - assert(type.equals("::Demo::Book")); - return new BookI(_library); - } - - @Override - public void - destroy() - { - } - - BookFactory(LibraryI library) - { - _library = library; - } - - private LibraryI _library; -} diff --git a/java/demo/Freeze/library/BookI.java b/java/demo/Freeze/library/BookI.java deleted file mode 100644 index c73a4399d5b..00000000000 --- a/java/demo/Freeze/library/BookI.java +++ /dev/null @@ -1,124 +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 Demo.*; - -class BookI extends Book -{ - // - // No read/write mutexes in Java - hence use native - // synchronization. - // - - @Override - synchronized public BookDescription - getBookDescription(Ice.Current current) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - - // - // Immutable. - // - return description; - } - - @Override - synchronized public String - getRenterName(Ice.Current current) - throws BookNotRentedException - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - - if(rentalCustomerName.length() == 0) - { - throw new BookNotRentedException(); - } - return rentalCustomerName; - } - - @Override - synchronized public void - rentBook(String name, Ice.Current current) - throws BookRentedException - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - - if(rentalCustomerName.length() != 0) - { - throw new BookRentedException(); - } - rentalCustomerName = name; - } - - @Override - synchronized public void - returnBook(Ice.Current current) - throws BookNotRentedException - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - - if(rentalCustomerName.length() == 0) - { - throw new BookNotRentedException(); - } - rentalCustomerName = new String();; - } - - @Override - synchronized public void - destroy(Ice.Current current) - throws DatabaseException - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(); - } - - _destroyed = true; - - try - { - _library.remove(description); - } - catch(Freeze.DatabaseException ex) - { - DatabaseException e = new DatabaseException(); - e.message = ex.message; - throw e; - } - } - - BookI(LibraryI library) - { - _library = library; - _destroyed = false; - - // - // This could be avoided by having two constructors (one for - // new creation of a book, and the other for restoring a - // previously saved book). - // - rentalCustomerName = new String(); - } - - private LibraryI _library; - private boolean _destroyed; -} diff --git a/java/demo/Freeze/library/Client.java b/java/demo/Freeze/library/Client.java deleted file mode 100644 index ee95093ff03..00000000000 --- a/java/demo/Freeze/library/Client.java +++ /dev/null @@ -1,49 +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. -// -// ********************************************************************** - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - @Override - public int - run(String[] args) - { - // - // Since this is an interactive demo we want to clear the - // Application installed interrupt callback and install our - // own shutdown hook. - // - setInterruptHook(new ShutdownHook()); - - return RunParser.runParser(appName(), args, communicator()); - } - - static public void - main(String[] args) - { - Client app = new Client(); - app.main("demo.Freeze.library.Client", args, "config.client"); - } -} diff --git a/java/demo/Freeze/library/Collocated.java b/java/demo/Freeze/library/Collocated.java deleted file mode 100644 index 3fa9562e79f..00000000000 --- a/java/demo/Freeze/library/Collocated.java +++ /dev/null @@ -1,94 +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. -// -// ********************************************************************** - -class Collocated extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - @Override - public int - run(String[] args) - { - // - // Since this is an interactive demo we want to clear the - // Application installed interrupt callback and install our - // own shutdown hook. - // - setInterruptHook(new ShutdownHook()); - - Ice.Properties properties = communicator().getProperties(); - - // - // Create an Object Adapter - // - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Library"); - - // - // Create an Evictor for books. - // - Freeze.Evictor evictor = Freeze.Util.createBackgroundSaveEvictor(adapter, _envName, "books", null, null, true); - int evictorSize = properties.getPropertyAsInt("EvictorSize"); - if(evictorSize > 0) - { - evictor.setSize(evictorSize); - } - - adapter.addServantLocator(evictor, "book"); - - // - // Create the library, and add it to the Object Adapter. - // - LibraryI library = new LibraryI(communicator(), _envName, "authors", evictor); - adapter.add(library, communicator().stringToIdentity("library")); - - // - // Create and install a factory and initializer for books. - // - Ice.ObjectFactory bookFactory = new BookFactory(library); - communicator().addObjectFactory(bookFactory, Demo.Book.ice_staticId()); - - // - // Everything ok, let's go. - // - int status = RunParser.runParser(appName(), args, communicator()); - adapter.destroy(); - - library.close(); - return status; - } - - Collocated(String envName) - { - _envName = envName; - } - - static public void - main(String[] args) - { - Collocated app = new Collocated("db"); - app.main("demo.Freeze.library.Collocated", args, "config.collocated"); - } - - private String _envName; -} diff --git a/java/demo/Freeze/library/Grammar.java b/java/demo/Freeze/library/Grammar.java deleted file mode 100644 index 43060093e76..00000000000 --- a/java/demo/Freeze/library/Grammar.java +++ /dev/null @@ -1,186 +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. -// -// ********************************************************************** - -class Grammar -{ - Grammar(Parser p) - { - _parser = p; - _scanner = new Scanner(_parser); - } - - void - parse() - { - while(true) - { - try - { - _token = _scanner.nextToken(); - if(_token == null) - { - return; - } - else if(_token.type == Token.TOK_SEMI) - { - // Continue - } - else if(_token.type == Token.TOK_HELP) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.usage(); - } - else if(_token.type == Token.TOK_EXIT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - return; - } - else if(_token.type == Token.TOK_ADD_BOOK) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.addBook(s); - } - else if(_token.type == Token.TOK_FIND_ISBN) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.findIsbn(s); - } - else if(_token.type == Token.TOK_FIND_AUTHORS) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.findAuthors(s); - } - else if(_token.type == Token.TOK_NEXT_FOUND_BOOK) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.nextFoundBook(); - } - else if(_token.type == Token.TOK_PRINT_CURRENT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.printCurrent(); - } - else if(_token.type == Token.TOK_RENT_BOOK) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.rentCurrent(s); - } - else if(_token.type == Token.TOK_RETURN_BOOK) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.returnCurrent(); - } - else if(_token.type == Token.TOK_REMOVE_CURRENT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.removeCurrent(); - } - else if(_token.type == Token.TOK_SET_EVICTOR_SIZE) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.setEvictorSize(s); - } - else if(_token.type == Token.TOK_SHUTDOWN) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.shutdown(); - } - else - { - _parser.error("parse error"); - } - } - catch(ParseError e) - { - _parser.error("Parse error: " + e.getMessage()); - } - } - } - - private java.util.List<String> - strings() - { - java.util.List<String> l = new java.util.ArrayList<String>(); - while(true) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_STRING) - { - return l; - } - l.add(_token.value); - } - } - - static private class ParseError extends RuntimeException - { - ParseError(String msg) - { - super(msg); - } - } - - private Parser _parser; - private Scanner _scanner; - private Token _token; -} diff --git a/java/demo/Freeze/library/Library.ice b/java/demo/Freeze/library/Library.ice deleted file mode 100644 index b1073686736..00000000000 --- a/java/demo/Freeze/library/Library.ice +++ /dev/null @@ -1,232 +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 Demo -{ - -/** - * - * This exception is raised in the case of a database failure. - * - **/ -exception DatabaseException -{ - string message; -}; - -/** - * - * This exception is raised if the book already exists. - * - **/ -exception BookExistsException -{ -}; - -/** - * - * This exception is raised if a book has already been rented. - * - **/ -exception BookRentedException -{ -}; - -/** - * - * This exception is raised if the book has not been rented. - * - **/ -exception BookNotRentedException -{ -}; - -/** - * - * A description of a book. - * - **/ -struct BookDescription -{ - /** The ISBN number of the book. */ - string isbn; - - /** The title of the book. */ - string title; - - /** The authors of the book. */ - string authors; -}; - -/** - * - * This class represents a book. - * - **/ -class Book -{ - /** - * - * Get a description of the book. - * - * @return The book description. - * - **/ - idempotent BookDescription getBookDescription(); - - /** - * - * Destroy the book. - * - * @throws DatabaseException Raised if there is a problem with the - * database system. - * - **/ - ["freeze:write"] void destroy() - throws DatabaseException; - - /** - * - * Rent the book to the specified customer. - * - * @param name The name of the customer. - * - * @throws BookRentedException Raised if the book has already been - * rented. - * - **/ - ["freeze:write"] void rentBook(string name) - throws BookRentedException; - - /** - * - * Get the name of the renter. - * - * @return The name the current rental customer. - * - * @throws BookNotRentedException Raised if the book is not - * currently rented. - * - **/ - idempotent string getRenterName() - throws BookNotRentedException; - - /** - * - * Return the book. - * - * @throws BookNotRentedException Raised if the book is not - * currently rented. - * - **/ - ["freeze:write"] void returnBook() - throws BookNotRentedException; - - /** - * - * The description for this book. Once a book has been created - * this information is immutable. - * - **/ - BookDescription description; - - /** - * - * The name of the current rental customer, or the empty string if - * the book is not currently rented. - * - **/ - string rentalCustomerName; -}; - -/** - * - * A sequence of book proxies. - * - **/ -sequence<Book*> BookPrxSeq; - -/** - * - * This interface represents a library. - * - **/ -interface Library -{ - /** - * - * Create a book with the given description. - * - * @param description The book description. - * - * @return A proxy for the new book. - * - * @throws DatabaseException Raised if there is a problem with the - * database. - * - * @throws BookExistsException Raised if the book already exists. - * - **/ - Book* createBook(BookDescription description) - throws DatabaseException, BookExistsException; - - /** - * - * Find a book by its ISBN number. - * - * @param isbn The ISBN number. - * - * @return The result of the search, or an null proxy if the book - * was not found. - * - * @throws DatabaseException Raised if there is a problem with the database. - * - **/ - idempotent Book* findByIsbn(string isbn) - throws DatabaseException; - - /** - * - * Find all books with a given authors. - * - * @param title The search parameters. - * - * @return The result of the search, or an empty sequence if no - * books were found. - * - * @throws DatabaseException Raised if there is a problem with the database. - * - **/ - idempotent BookPrxSeq findByAuthors(string authors) - throws DatabaseException; - - /** - * - * Set the evictor size. - * - * @param size The new size for the evictor. - * - * @throws DatabaseException Raised if there is a problem with the - * database. - * - **/ - idempotent void setEvictorSize(int size) - throws DatabaseException; - - /** - * - * Shutdown the server. - * - **/ - void shutdown(); -}; - -}; diff --git a/java/demo/Freeze/library/LibraryI.java b/java/demo/Freeze/library/LibraryI.java deleted file mode 100644 index 6bdd3a61dee..00000000000 --- a/java/demo/Freeze/library/LibraryI.java +++ /dev/null @@ -1,255 +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 Demo.*; - -class LibraryI extends _LibraryDisp -{ - @Override - public synchronized BookPrx - createBook(BookDescription description, Ice.Current current) - throws DatabaseException, BookExistsException - { - BookPrx book = isbnToBook(description.isbn, current.adapter); - - try - { - book.ice_ping(); - - // - // The book already exists. - // - throw new BookExistsException(); - } - catch(Ice.ObjectNotExistException e) - { - // - // Book doesn't exist, ignore the exception. - // - } - - // - // Create a new book Servant. - // - BookI bookI = new BookI(this); - bookI.description = description; - - Ice.Identity ident = createBookIdentity(description.isbn); - - // - // Create a new Ice Object in the evictor, using the new - // identity and the new Servant. - // - // This can throw EvictorDeactivatedException (which indicates - // an internal error). The exception is currently ignored. - // - _evictor.add(bookI, ident); - - try - { - // - // Add the isbn number to the authors map. - // - String[] isbnSeq = _authors.get(description.authors); - int length = (isbnSeq == null) ? 0 : isbnSeq.length; - String[] newIsbnSeq = new String[length+1]; - - if(isbnSeq != null) - { - System.arraycopy(isbnSeq, 0, newIsbnSeq, 0, length); - } - newIsbnSeq[length] = description.isbn; - - _authors.fastPut(description.authors, newIsbnSeq); - - return book; - } - catch(Freeze.DatabaseException ex) - { - DatabaseException e = new DatabaseException(); - e.message = ex.message; - throw e; - } - } - - // - // No locking is necessary since no internal mutable state is - // accessed. - // - @Override - public BookPrx - findByIsbn(String isbn, Ice.Current current) - throws DatabaseException - { - try - { - BookPrx book = isbnToBook(isbn, current.adapter); - book.ice_ping(); - - return book; - } - catch(Ice.ObjectNotExistException ex) - { - // - // Book doesn't exist, return a null proxy. - // - return null; - } - } - - @Override - public synchronized BookPrx[] - findByAuthors(String authors, Ice.Current current) - throws DatabaseException - { - try - { - // - // Lookup all books that match the given authors, and - // return them to the caller. - // - String[] isbnSeq = _authors.get(authors); - - int length = (isbnSeq == null) ? 0 : isbnSeq.length; - BookPrx[] books = new BookPrx[length]; - - if(isbnSeq != null) - { - for(int i = 0; i < length; ++i) - { - books[i] = isbnToBook(isbnSeq[i], current.adapter); - } - } - - return books; - } - catch(Freeze.DatabaseException ex) - { - DatabaseException e = new DatabaseException(); - e.message = ex.message; - throw e; - } - } - - @Override - public void - setEvictorSize(int size, Ice.Current current) - throws DatabaseException - { - // - // No synchronization necessary, _evictor is immutable. - // - _evictor.setSize(size); - } - - @Override - public void - shutdown(Ice.Current current) - { - current.adapter.getCommunicator().shutdown(); - } - - protected synchronized void - remove(BookDescription description) - throws DatabaseException - { - try - { - String[] isbnSeq = _authors.get(description.authors); - - assert isbnSeq != null; - - int i; - for(i = 0; i < isbnSeq.length; ++i) - { - if(isbnSeq[i].equals(description.isbn)) - { - break; - } - } - - assert i < isbnSeq.length; - - if(isbnSeq.length == 1) - { - // - // If there are no further associated isbn numbers then remove - // the record. - // - _authors.fastRemove(description.authors); - } - else - { - // - // Remove the isbn number from the sequence and write - // back the new record. - // - String[] newIsbnSeq = new String[isbnSeq.length-1]; - System.arraycopy(isbnSeq, 0, newIsbnSeq, 0, i); - if(i < isbnSeq.length - 1) - { - System.arraycopy(isbnSeq, i+1, newIsbnSeq, i, isbnSeq.length - i - 1); - } - - _authors.fastPut(description.authors, newIsbnSeq); - } - - // - // This can throw EvictorDeactivatedException (which - // indicates an internal error). The exception is - // currently ignored. - // - _evictor.remove(createBookIdentity(description.isbn)); - } - catch(Freeze.DatabaseException ex) - { - DatabaseException e = new DatabaseException(); - e.message = ex.message; - throw e; - } - } - - LibraryI(Ice.Communicator communicator, String envName, String dbName, Freeze.Evictor evictor) - { - _evictor = evictor; - _connection = Freeze.Util.createConnection(communicator, envName); - _authors = new StringIsbnSeqDict(_connection, dbName, true); - } - - void - close() - { - _authors.close(); - _connection.close(); - } - - private Ice.Identity - createBookIdentity(String isbn) - { - // - // Note that the identity category is important since the - // locator was installed for the category 'book'. - // - Ice.Identity ident = new Ice.Identity(); - ident.category = "book"; - ident.name = isbn; - - return ident; - } - - private BookPrx - isbnToBook(String isbn, Ice.ObjectAdapter adapter) - { - return BookPrxHelper.uncheckedCast(adapter.createProxy(createBookIdentity(isbn))); - } - - private Freeze.Evictor _evictor; - private Freeze.Connection _connection; - private StringIsbnSeqDict _authors; -} diff --git a/java/demo/Freeze/library/Parser.java b/java/demo/Freeze/library/Parser.java deleted file mode 100644 index a6a8c58e3d8..00000000000 --- a/java/demo/Freeze/library/Parser.java +++ /dev/null @@ -1,365 +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 Demo.*; - -class Parser -{ - Parser(Ice.Communicator communicator, LibraryPrx library) - { - _library = library; - } - - void - usage() - { - System.err.print( - "help Print this message.\n" + - "exit, quit Exit this program.\n" + - "add isbn title authors Create new book.\n" + - "isbn NUMBER Find the book with given ISBN number.\n" + - "authors NAME Find all books by the given authors.\n" + - "next Set the current book to the next one that was found.\n" + - "current Display the current book.\n" + - "rent NAME Rent the current book for customer NAME.\n" + - "return Return the currently rented book.\n" + - "remove Permanently remove the current book from the library.\n" + - "size SIZE Set the evictor size for books to SIZE.\n" + - "shutdown Shut the library server down.\n"); - } - - void - addBook(java.util.List<String> args) - { - if(args.size() != 3) - { - error("`add' requires at exactly three arguments (type `help' for more info)"); - return; - } - - try - { - BookDescription desc = new BookDescription(); - desc.isbn = args.get(0); - desc.title = args.get(1); - desc.authors = args.get(2); - - _library.createBook(desc); - System.out.println("added new book with isbn " + desc.isbn); - } - catch(DatabaseException ex) - { - error(ex.message); - } - catch(BookExistsException ex) - { - error("the book already exists."); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - findIsbn(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`isbn' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - _foundBooks = null; - _current = 0; - - BookPrx book = _library.findByIsbn(args.get(0)); - if(book == null) - { - System.out.println("no book with that ISBN number exists."); - } - else - { - _foundBooks = new BookPrx[1]; - _foundBooks[0] = book; - printCurrent(); - } - } - catch(DatabaseException ex) - { - error(ex.message); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - findAuthors(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`authors' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - _foundBooks = _library.findByAuthors(args.get(0)); - _current = 0; - System.out.println("number of books found: " + _foundBooks.length); - printCurrent(); - } - catch(DatabaseException ex) - { - error(ex.message); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - nextFoundBook() - { - if(_foundBooks != null && _current != _foundBooks.length) - { - ++_current; - } - printCurrent(); - } - - void - printCurrent() - { - try - { - if(_foundBooks != null && _current != _foundBooks.length) - { - BookDescription desc = _foundBooks[_current].getBookDescription(); - String renter = null; - try - { - renter = _foundBooks[_current].getRenterName(); - } - catch(BookNotRentedException ex) - { - } - - System.out.println("current book is:" ); - System.out.println("isbn: " + desc.isbn); - System.out.println("title: " + desc.title); - System.out.println("authors: " + desc.authors); - if(renter != null) - { - System.out.println("rented: " + renter); - } - } - else - { - System.out.println("no current book"); - } - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current book no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - rentCurrent(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`rent' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - if(_foundBooks != null && _current != _foundBooks.length) - { - _foundBooks[_current].rentBook(args.get(0)); - System.out.println("the book is now rented by `" + args.get(0) + "'"); - } - else - { - System.out.println("no current book"); - } - } - catch(BookRentedException ex) - { - System.out.println("the book has already been rented."); - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current book no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - returnCurrent() - { - try - { - if(_foundBooks != null && _current != _foundBooks.length) - { - _foundBooks[_current].returnBook(); - System.out.println( "the book has been returned."); - } - else - { - System.out.println("no current book"); - } - } - catch(BookNotRentedException ex) - { - System.out.println("the book is not currently rented."); - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current book no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - removeCurrent() - { - try - { - if(_foundBooks != null && _current != _foundBooks.length) - { - _foundBooks[_current].destroy(); - System.out.println("removed current book" ); - } - else - { - System.out.println("no current book" ); - } - } - catch(DatabaseException ex) - { - error(ex.message); - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current book no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - setEvictorSize(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`size' requires exactly one argument (type `help' for more info)"); - return; - } - - String s = args.get(0); - try - { - _library.setEvictorSize(Integer.parseInt(s)); - } - catch(NumberFormatException ex) - { - error("not a number " + s); - } - catch(DatabaseException ex) - { - error(ex.message); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - shutdown() - { - try - { - _library.shutdown(); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - error(String s) - { - System.err.println("error: " + s); - } - - void - warning(String s) - { - System.err.println("warning: " + s); - } - - String - getInput() - { - System.out.print(">>> "); - System.out.flush(); - - try - { - return _in.readLine(); - } - catch(java.io.IOException e) - { - return null; - } - } - - int - parse() - { - _foundBooks = new BookPrx[0]; - _current = 0; - - _in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - private BookPrx[] _foundBooks; - private int _current; - - private LibraryPrx _library; - - private java.io.BufferedReader _in; -} diff --git a/java/demo/Freeze/library/README b/java/demo/Freeze/library/README deleted file mode 100644 index 6df6d1c02a1..00000000000 --- a/java/demo/Freeze/library/README +++ /dev/null @@ -1,28 +0,0 @@ -This example demonstrates the use of Freeze to manage books in a -library. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In another window, populate the server's database by starting the -client and redirecting its input from the file "books": - -$ java -jar build/libs/client.jar < books - -Then start the client again to use the demo interactively: - -$ java -jar build/libs/client.jar - -Type "help" to get a list of valid commands. - -The collocated executable combines the client and server into one -program. In this case you do not need to start a separate server. -If you have not already populated the database, you can do so using -the collocated executable as shown below: - -$ java -jar build/libs/collocated.jar < books - -Then start the interactive demo like this: - -$ java -jar build/libs/collocated.jar diff --git a/java/demo/Freeze/library/RunParser.java b/java/demo/Freeze/library/RunParser.java deleted file mode 100644 index 8524ebfba59..00000000000 --- a/java/demo/Freeze/library/RunParser.java +++ /dev/null @@ -1,27 +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 Demo.*; - -class RunParser -{ - static int - runParser(String appName, String[] args, Ice.Communicator communicator) - { - LibraryPrx library = LibraryPrxHelper.checkedCast(communicator.propertyToProxy("Library.Proxy")); - if(library == null) - { - System.err.println(appName + ": invalid object reference"); - return 1; - } - - Parser parser = new Parser(communicator, library); - return parser.parse(); - } -} diff --git a/java/demo/Freeze/library/Scanner.java b/java/demo/Freeze/library/Scanner.java deleted file mode 100644 index af7f2e9ca60..00000000000 --- a/java/demo/Freeze/library/Scanner.java +++ /dev/null @@ -1,287 +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. -// -// ********************************************************************** - -class Scanner -{ - Scanner(Parser p) - { - _parser = p; - } - - Token - nextToken() - { - String s = next(); - if(s == null) - { - return null; - } - - if(s.equals(";")) - { - return new Token(Token.TOK_SEMI); - } - else if(s.equals("help")) - { - return new Token(Token.TOK_HELP); - } - else if(s.equals("exit") || s.equals("quit")) - { - return new Token(Token.TOK_EXIT); - } - else if(s.equals("add")) - { - return new Token(Token.TOK_ADD_BOOK); - } - else if(s.equals("isbn")) - { - return new Token(Token.TOK_FIND_ISBN); - } - else if(s.equals("authors")) - { - return new Token(Token.TOK_FIND_AUTHORS); - } - else if(s.equals("next")) - { - return new Token(Token.TOK_NEXT_FOUND_BOOK); - } - else if(s.equals("current")) - { - return new Token(Token.TOK_PRINT_CURRENT); - } - else if(s.equals("rent")) - { - return new Token(Token.TOK_RENT_BOOK); - } - else if(s.equals("return")) - { - return new Token(Token.TOK_RETURN_BOOK); - } - else if(s.equals("remove")) - { - return new Token(Token.TOK_REMOVE_CURRENT); - } - else if(s.equals("size")) - { - return new Token(Token.TOK_SET_EVICTOR_SIZE); - } - else if(s.equals("shutdown")) - { - return new Token(Token.TOK_SHUTDOWN); - } - else - { - return new Token(Token.TOK_STRING, s); - } - } - - static private class EndOfInput extends Exception - { - } - - private char - get() - throws EndOfInput - { - // - // If there is an character in the unget buffer, return it. - // - if(_unget) - { - _unget = false; - return _ungetChar; - } - - // - // No current buffer? - // - if(_buf == null) - { - _buf = _parser.getInput(); - _pos = 0; - if(_buf == null) - { - throw new EndOfInput(); - } - } - - // - // At the end-of-buffer? - // - while(_pos >= _buf.length()) - { - _buf = null; - _pos = 0; - return '\n'; - } - - return _buf.charAt(_pos++); - } - - // - // unget only works with one character. - // - private void - unget(char c) - { - assert(!_unget); - _unget = true; - _ungetChar = c; - } - - private String - next() - { - // - // Eat any whitespace. - // - char c; - try - { - do - { - c = get(); - } - while(Character.isWhitespace(c) && c != '\n'); - } - catch(EndOfInput ignore) - { - return null; - } - - StringBuilder buf = new StringBuilder(128); - - if(c == ';' || c == '\n') - { - buf.append(';'); - } - else if(c == '\'') - { - try - { - while(true) - { - c = get(); - if(c == '\'') - { - break; - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else if(c == '\"') - { - try - { - while(true) - { - c = get(); - if(c == '\"') - { - break; - } - else if(c == '\\') - { - try - { - char next = get(); - switch(next) - { - case '\\': - case '"': - { - buf.append(next); - break; - } - - case 'n': - { - buf.append('\n'); - break; - } - - case 'r': - { - buf.append('\r'); - break; - } - - case 't': - { - buf.append('\t'); - break; - } - - case 'f': - { - buf.append('\f'); - break; - } - - default: - { - buf.append(c); - unget(next); - } - } - } - catch(EndOfInput e) - { - buf.append(c); - } - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else - { - // - // Otherwise it's a string. - // - try - { - do - { - buf.append(c); - c = get(); - } - while(!Character.isWhitespace(c) && c != ';' && c != '\n'); - - unget(c); - } - catch(EndOfInput ignore) - { - } - } - - return buf.toString(); - } - - private Parser _parser; - private boolean _unget = false; - private char _ungetChar; - private String _buf = null; - private int _pos; -} diff --git a/java/demo/Freeze/library/Server.java b/java/demo/Freeze/library/Server.java deleted file mode 100644 index 322f436c5be..00000000000 --- a/java/demo/Freeze/library/Server.java +++ /dev/null @@ -1,79 +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. -// -// ********************************************************************** - -class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.Properties properties = communicator().getProperties(); - - // - // Create an object adapter - // - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Library"); - - // - // Create an evictor for books. - // - Freeze.Evictor evictor = Freeze.Util.createBackgroundSaveEvictor(adapter, _envName, "books", null, null, true); - int evictorSize = properties.getPropertyAsInt("EvictorSize"); - if(evictorSize > 0) - { - evictor.setSize(evictorSize); - } - - adapter.addServantLocator(evictor, "book"); - - // - // Create the library, and add it to the object adapter. - // - LibraryI library = new LibraryI(communicator(), _envName, "authors", evictor); - adapter.add(library, communicator().stringToIdentity("library")); - - // - // Create and install a factory for books. - // - Ice.ObjectFactory bookFactory = new BookFactory(library); - communicator().addObjectFactory(bookFactory, Demo.Book.ice_staticId()); - - // - // Everything ok, let's go. - // - adapter.activate(); - - shutdownOnInterrupt(); - communicator().waitForShutdown(); - defaultInterrupt(); - - library.close(); - return 0; - } - - Server(String envName) - { - _envName = envName; - } - - static public void - main(String[] args) - { - Server app = new Server("db"); - app.main("demo.Freeze.library.Server", args, "config.server"); - } - - private String _envName; -} diff --git a/java/demo/Freeze/library/Token.java b/java/demo/Freeze/library/Token.java deleted file mode 100644 index eba9de18cf8..00000000000 --- a/java/demo/Freeze/library/Token.java +++ /dev/null @@ -1,41 +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. -// -// ********************************************************************** - -class Token -{ - public static final int TOK_HELP = 0; - public static final int TOK_EXIT = 1; - public static final int TOK_ADD_BOOK = 2; - public static final int TOK_FIND_ISBN = 3; - public static final int TOK_FIND_AUTHORS = 4; - public static final int TOK_NEXT_FOUND_BOOK = 5; - public static final int TOK_PRINT_CURRENT = 6; - public static final int TOK_RENT_BOOK = 7; - public static final int TOK_RETURN_BOOK = 8; - public static final int TOK_REMOVE_CURRENT = 9; - public static final int TOK_SET_EVICTOR_SIZE = 10; - public static final int TOK_SHUTDOWN = 11; - public static final int TOK_STRING = 12; - public static final int TOK_SEMI = 13; - - int type; - String value; - - Token(int t) - { - type = t; - value = null; - } - - Token(int t, String v) - { - type = t; - value = v; - } -} diff --git a/java/demo/Freeze/library/books b/java/demo/Freeze/library/books deleted file mode 100644 index 18836dbdba6..00000000000 --- a/java/demo/Freeze/library/books +++ /dev/null @@ -1,30 +0,0 @@ -add '096447963X' 'The Dragon Style (Learn to Play Go, Volume III)' 'Janice Kim, Jeong Soo-Hyun' ; -add '0964479613' "Learn to Play Go: A Master's Guide to the Ultimate Game (Volume I)" 'Janice Kim, Jeong Soo-Hyun' ; -add '0964479621' 'The Way of the Moving Horse (Learn to Play Go, Volume II)' 'Janice Kim, Jeong Soo-Hyun' ; -add '0964479648' 'Battle Strategies (Learn to Play Go Series)' 'Janice Kim, Jeong Soo-Hyun' ; -add '0201889544' 'The C++ Programming Language' 'Bjarne Stroustrup' ; -add '0201543303' 'The Design and Evolution of C++' 'Bjarne Stroustrup' ; -add '0201700735' 'The C++ Programming Language Special Edition' 'Bjarne Stroustrup' ; -add '0201379260' 'The C++ Standard Library : A Tutorial and Reference' 'Nicolai M. Josuttis' ; -add '0201749629' 'Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library' 'Scott Meyers' ; -add '0201924889' 'Effective C++: 50 Specific Ways to Improve Your Programs and Design' 'Scott Meyers' ; -add '020163371X' 'More Effective C++: 35 New Ways to Improve Your Programs and Designs' 'Scott Meyers' ; -add '0201615622' 'Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions' 'Herb Sutter' ; -add '020170434X' 'More Exceptional C++' 'Herb Sutter' ; -add '0201704315' 'Modern C++ Design: Generic Programming and Design Patterns Applied' 'Andrei Alexandrescu' ; -add '0735616353' 'Microsoft Visual C++ .NET Deluxe Learning Edition' 'Microsoft Corporation' ; -add '0735615497' 'Programming with Microsoft Visual C++ .NET, Sixth Edition (Core Reference)' 'George Shepherd, David Kruglinski' ; -add '0735614229' 'Applied Microsoft .NET Framework Programming' 'Jeffrey Richter' ; -add '0201824701' 'C++ Primer' 'Stanley B. Lippman, Josee Lajoie' ; -add '0201485184' 'Essential C++' 'Stanley B. Lippman' ; -add '020170353X' 'Accelerated C++: Practical Programming by Example' 'Andrew Koenig, Barbara E. Moo' ; -add '0201423391' 'Ruminations on C++ : A Decade of Programming Insight and Experience' 'Andrew Koenig, Barbara E. Moo' ; -add '0201179288' 'C Traps and Pitfalls' 'Andrew Koenig' ; -add '0131103628' 'The C Programming Language' 'Brian W. Kernighan, Dennis M. Ritchie' ; -add '020161586X' 'The Practice of Programming' 'Brian W. Kernighan, Rob Pike' ; -add '013937681X' 'UNIX Programming Environment, The' 'Brian W. Kernighan, Rob Pike' ; -add '0201563177' 'Advanced Programming in the UNIX(R) Environment' 'W. Richard Stevens' ; -add '0201633469' 'The Protocols (TCP/IP Illustrated, Volume 1)' 'W. Richard Stevens' ; -add '0201634953' 'TCP for Transactions, HTTP, NNTP, and the UNIX(R) Domain Protocols (TCP/IP Illustrated, Volume 3)' 'W. Richard Stevens' ; -add '013490012X' 'UNIX Network Programming, Volume 1: Networking APIs - Sockets and XTI' 'W. Richard Stevens' ; -add '0130810819' 'UNIX Network Programming: Interprocess Communications' 'W. Richard Stevens' ; diff --git a/java/demo/Freeze/library/build.gradle b/java/demo/Freeze/library/build.gradle deleted file mode 100644 index 4c67a7d6ed2..00000000000 --- a/java/demo/Freeze/library/build.gradle +++ /dev/null @@ -1,55 +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. -// -// ********************************************************************** - -slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } - freezej { - files = [file("${sliceDir}/Ice/BuiltinSequences.ice"), - file("Library.ice")] - args = "--ice" - dict { - StringIsbnSeqDict { - javaType = "StringIsbnSeqDict" - key = "string" - value = "Ice::StringSeq" - } - } - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - compile localDependency("ice") - compile localDependency("freeze") - compile files(dbJar) - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } -} - -clean { - delete fileTree(dir: 'db', excludes:['.gitignore', 'DB_CONFIG']) -} - -// Don't create the default jar. -jar.enabled = false - -demoJar("client") -demoJar("server") -demoJar("collocated") diff --git a/java/demo/Freeze/library/config.client b/java/demo/Freeze/library/config.client deleted file mode 100644 index 0488d4bd308..00000000000 --- a/java/demo/Freeze/library/config.client +++ /dev/null @@ -1,28 +0,0 @@ -# -# The client reads this property to create the reference to the -# "library" object in the server. -# -Library.Proxy=library:default -h localhost -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/Freeze/library/config.collocated b/java/demo/Freeze/library/config.collocated deleted file mode 100644 index acaea776861..00000000000 --- a/java/demo/Freeze/library/config.collocated +++ /dev/null @@ -1,70 +0,0 @@ -# -# Configure the server endpoints. -# -Library.Endpoints=default -h localhost -p 10000 - -# -# Set the evictor size. The size set here (3) is far too small for -# real-world applications. However, for the purposes of this demo, -# setting the size to 3 allows us to see the operation of the evictor -# with evictor tracing. -# -EvictorSize=3 - -# -# The client reads this property to create the reference to the -# "library" object in the server. -# -Library.Proxy=library:default -h localhost -p 10000 - -# -# Don't warn about unknown properties. If this is not set we'll get a -# warning about "Library.Proxy" since the Ice run time thinks this is -# an OA property due to the Object Adapter "Library". -# -Ice.Warn.UnknownProperties=0 - -# -# Freeze Map Tracing. -# -# 0 = No map activity trace (default). -# 1 = Trace database open and close. -# 2 = Also trace iterator and transaction operations, and reference -# counting of the underlying database. -# -Freeze.Trace.Map=1 - -# -# Freeze Evictor Tracing. -# -# 0 = No evictor activity trace (default). -# 1 = Trace Ice object and facet creation and destruction, facet -# streaming time, facet saving time, object eviction (every 50 -# objects) and evictor deactivation. -# 2 = Also trace object lookups, and all object evictions. -# 3 = Also trace object retrieval from the database. -# -Freeze.Trace.Evictor=2 - -# -# 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/Freeze/library/config.server b/java/demo/Freeze/library/config.server deleted file mode 100644 index 19b4ebe4e3c..00000000000 --- a/java/demo/Freeze/library/config.server +++ /dev/null @@ -1,57 +0,0 @@ -# -# Configure the server endpoints. -# -Library.Endpoints=default -h localhost -p 10000 - -# -# Set the evictor size. The size set here (3) is far too small for -# real-world applications. However, for the purposes of this demo, -# setting the size to 3 allows us to see the operation of the evictor -# with evictor tracing. -# -EvictorSize=3 - -# -# Freeze Map Tracing. -# -# 0 = No map activity trace (default). -# 1 = Trace database open and close. -# 2 = Also trace iterator and transaction operations, and reference -# counting of the underlying database. -# -Freeze.Trace.Map=1 - -# -# Freeze Evictor Tracing. -# -# 0 = No evictor activity trace (default). -# 1 = Trace Ice object and facet creation and destruction, facet -# streaming time, facet saving time, object eviction (every 50 -# objects) and evictor deactivation. -# 2 = Also trace object lookups, and all object evictions. -# 3 = Also trace object retrieval from the database. -# -Freeze.Trace.Evictor=2 - -# -# 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/Freeze/library/db/.gitignore b/java/demo/Freeze/library/db/.gitignore deleted file mode 100644 index 39af5887579..00000000000 --- a/java/demo/Freeze/library/db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# Dummy file, so that git retains this otherwise empty directory. diff --git a/java/demo/Freeze/library/expect.py b/java/demo/Freeze/library/expect.py deleted file mode 100755 index ef6eb52a582..00000000000 --- a/java/demo/Freeze/library/expect.py +++ /dev/null @@ -1,47 +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 - -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 -from demoscript.Freeze import library - -sys.stdout.write("cleaning databases... ") -sys.stdout.flush() -Util.cleanDbDir("db") -print("ok") - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar') -client.expect('>>> ') - -library.run(client, server) - -print("running with collocated server") - -sys.stdout.write("cleaning databases... ") -sys.stdout.flush() -Util.cleanDbDir("db") -print("ok") - -server = Util.spawn('java -jar build/libs/collocated.jar --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') -server.expect('>>> ') - -library.run(server, server) diff --git a/java/demo/Freeze/phonebook/.externalToolBuilders/demo.Freeze.phonebook.slice.launch b/java/demo/Freeze/phonebook/.externalToolBuilders/demo.Freeze.phonebook.slice.launch deleted file mode 100644 index fe88469c9ea..00000000000 --- a/java/demo/Freeze/phonebook/.externalToolBuilders/demo.Freeze.phonebook.slice.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="${project}"/> -<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.Freeze.phonebook"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Freeze.phonebook/PhoneBook.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Freeze.phonebook/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/Freeze/phonebook/.gitignore b/java/demo/Freeze/phonebook/.gitignore deleted file mode 100644 index 9c39416c539..00000000000 --- a/java/demo/Freeze/phonebook/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db/* diff --git a/java/demo/Freeze/phonebook/Client.java b/java/demo/Freeze/phonebook/Client.java deleted file mode 100644 index 8687cd29aa0..00000000000 --- a/java/demo/Freeze/phonebook/Client.java +++ /dev/null @@ -1,49 +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. -// -// ********************************************************************** - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - @Override - public int - run(String[] args) - { - // - // Since this is an interactive demo we want to clear the - // Application installed interrupt callback and install our - // own shutdown hook. - // - setInterruptHook(new ShutdownHook()); - - return RunParser.runParser(appName(), args, communicator()); - } - - static public void - main(String[] args) - { - Client app = new Client(); - app.main("demo.Freeze.phonebook.Client", args, "config.client"); - } -} diff --git a/java/demo/Freeze/phonebook/Collocated.java b/java/demo/Freeze/phonebook/Collocated.java deleted file mode 100644 index b9c986c5613..00000000000 --- a/java/demo/Freeze/phonebook/Collocated.java +++ /dev/null @@ -1,115 +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. -// -// ********************************************************************** - -class Collocated extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - @Override - public int - run(String[] args) - { - // - // Since this is an interactive demo we want to clear the - // Application installed interrupt callback and install our - // own shutdown hook. - // - setInterruptHook(new ShutdownHook()); - - Ice.Properties properties = communicator().getProperties(); - - // - // Create and install a factory for contacts. - // - ContactFactory contactFactory = new ContactFactory(); - communicator().addObjectFactory(contactFactory, Demo.Contact.ice_staticId()); - - // - // Create an object adapter - // - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("PhoneBook"); - - // - // Create the Name index - // - NameIndex index = new NameIndex("name"); - Freeze.Index[] indices = new Freeze.Index[1]; - indices[0] = index; - - // - // Create an evictor for contacts. - // When Freeze.Evictor.db.contacts.PopulateEmptyIndices is not 0 and the - // Name index is empty, Freeze will traverse the database to recreate - // the index during createEvictor(). Therefore the factories for the objects - // stored in evictor (contacts here) must be registered before the call - // to createEvictor(). - // - Freeze.Evictor evictor = Freeze.Util.createBackgroundSaveEvictor(adapter, _envName, "contacts", null, indices, true); - int evictorSize = properties.getPropertyAsInt("EvictorSize"); - if(evictorSize > 0) - { - evictor.setSize(evictorSize); - } - - // - // Completes the initialization of the contact factory. Note that ContactI/ - // ContactFactoryI uses this evictor only when a Contact is destroyed, - // which cannot happen during createEvictor(). - // - contactFactory.setEvictor(evictor); - - // - // Register the evictor with the adapter - // - adapter.addServantLocator(evictor, "contact"); - - // - // Create the phonebook, and add it to the Object Adapter. - // - PhoneBookI phoneBook = new PhoneBookI(evictor, contactFactory, index); - adapter.add(phoneBook, communicator().stringToIdentity("phonebook")); - - // - // Everything ok, let's go. - // - int status = RunParser.runParser(appName(), args, communicator()); - adapter.destroy(); - - return status; - } - - Collocated(String envName) - { - _envName = envName; - } - - static public void - main(String[] args) - { - Collocated app = new Collocated("db"); - app.main("demo.Freeze.phonebook.Collocated", args, "config.collocated"); - } - - private String _envName; -} diff --git a/java/demo/Freeze/phonebook/ContactFactory.java b/java/demo/Freeze/phonebook/ContactFactory.java deleted file mode 100644 index bab6623128e..00000000000 --- a/java/demo/Freeze/phonebook/ContactFactory.java +++ /dev/null @@ -1,43 +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. -// -// ********************************************************************** - -class ContactFactory implements Ice.ObjectFactory -{ - @Override - public Ice.Object - create(String type) - { - assert(type.equals("::Demo::Contact")); - return new ContactI(this); - } - - @Override - public void - destroy() - { - } - - ContactFactory() - { - } - - void - setEvictor(Freeze.Evictor evictor) - { - _evictor = evictor; - } - - Freeze.Evictor - getEvictor() - { - return _evictor; - } - - private Freeze.Evictor _evictor; -} diff --git a/java/demo/Freeze/phonebook/ContactI.java b/java/demo/Freeze/phonebook/ContactI.java deleted file mode 100644 index 4b905fb5215..00000000000 --- a/java/demo/Freeze/phonebook/ContactI.java +++ /dev/null @@ -1,94 +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 Demo.*; - -class ContactI extends Contact -{ - // - // No read/write mutexes in Java - hence use native - // synchronization. - // - - @Override - synchronized public String - getName(Ice.Current current) - { - return name; - } - - @Override - synchronized public void - setName(String name, Ice.Current current) - throws DatabaseException - { - this.name = name; - } - - @Override - synchronized public String - getAddress(Ice.Current current) - { - return address; - } - - @Override - synchronized public void - setAddress(String address, Ice.Current current) - { - this.address = address; - } - - @Override - synchronized public String - getPhone(Ice.Current current) - { - return phone; - } - - @Override - synchronized public void - setPhone(String phone, Ice.Current current) - { - this.phone = phone; - } - - @Override - public void - destroy(Ice.Current current) - throws DatabaseException - { - try - { - _factory.getEvictor().remove(current.id); - } - catch(Freeze.DatabaseException ex) - { - DatabaseException e = new DatabaseException(); - e.message = ex.message; - throw e; - } - } - - ContactI(ContactFactory factory) - { - _factory = factory; - // - // It's possible to avoid this if there were two constructors - // - one for original creation of the Contact and one for - // loading of an existing Contact. - // - name = new String(); - address = new String(); - phone = new String(); - } - - private ContactFactory _factory; - -} diff --git a/java/demo/Freeze/phonebook/Grammar.java b/java/demo/Freeze/phonebook/Grammar.java deleted file mode 100644 index 107a368a984..00000000000 --- a/java/demo/Freeze/phonebook/Grammar.java +++ /dev/null @@ -1,186 +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. -// -// ********************************************************************** - -class Grammar -{ - Grammar(Parser p) - { - _parser = p; - _scanner = new Scanner(_parser); - } - - void - parse() - { - while(true) - { - try - { - _token = _scanner.nextToken(); - if(_token == null) - { - return; - } - else if(_token.type == Token.TOK_SEMI) - { - // Continue - } - else if(_token.type == Token.TOK_HELP) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.usage(); - } - else if(_token.type == Token.TOK_EXIT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - return; - } - else if(_token.type == Token.TOK_ADD_CONTACTS) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.addContacts(s); - } - else if(_token.type == Token.TOK_FIND_CONTACTS) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.findContacts(s); - } - else if(_token.type == Token.TOK_NEXT_FOUND_CONTACT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.nextFoundContact(); - } - else if(_token.type == Token.TOK_PRINT_CURRENT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.printCurrent(); - } - else if(_token.type == Token.TOK_SET_CURRENT_NAME) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.setCurrentName(s); - } - else if(_token.type == Token.TOK_SET_CURRENT_ADDRESS) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.setCurrentAddress(s); - } - else if(_token.type == Token.TOK_SET_CURRENT_PHONE) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.setCurrentPhone(s); - } - else if(_token.type == Token.TOK_REMOVE_CURRENT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.removeCurrent(); - } - else if(_token.type == Token.TOK_SET_EVICTOR_SIZE) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.setEvictorSize(s); - } - else if(_token.type == Token.TOK_SHUTDOWN) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - - _parser.shutdown(); - } - else - { - _parser.error("parse error"); - } - } - catch(ParseError e) - { - _parser.error("Parse error: " + e.getMessage()); - } - } - } - - private java.util.List<String> - strings() - { - java.util.List<String> l = new java.util.ArrayList<String>(); - while(true) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_STRING) - { - return l; - } - l.add(_token.value); - } - } - - static private class ParseError extends RuntimeException - { - ParseError(String msg) - { - super(msg); - } - } - - private Parser _parser; - private Scanner _scanner; - private Token _token; -} diff --git a/java/demo/Freeze/phonebook/Parser.java b/java/demo/Freeze/phonebook/Parser.java deleted file mode 100644 index 9d4978882d9..00000000000 --- a/java/demo/Freeze/phonebook/Parser.java +++ /dev/null @@ -1,348 +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 Demo.*; - -class Parser -{ - Parser(PhoneBookPrx phoneBook) - { - _phoneBook = phoneBook; - } - - void - usage() - { - System.err.print( - "help Print this message.\n" + - "exit, quit Exit this program.\n" + - "add NAMES... Create new contacts for NAMES in the phonebook.\n" + - "find NAME Find all contacts in the phonebook that match NAME.\n" + - " Set the current contact to the first one found.\n" + - "next Set the current contact to the next one that was found.\n" + - "current Display the current contact.\n" + - "name NAME Set the name for the current contact to NAME.\n" + - "address ADDRESS Set the address for the current contact to ADDRESS.\n" + - "phone PHONE Set the phone number for the current contact to PHONE.\n" + - "remove Permanently remove the current contact from the phonebook.\n" + - "size SIZE Set the evictor size for contacts to SIZE.\n" + - "shutdown Shut the phonebook server down.\n"); - } - - void - addContacts(java.util.List<String> args) - { - if(args.isEmpty()) - { - error("`add' requires at least one argument (type `help' for more info)"); - return; - } - - try - { - for(String name : args) - { - ContactPrx contact = _phoneBook.createContact(); - contact.setName(name); - System.out.println("added new contact for `" + name + "'"); - } - } - catch(DatabaseException ex) - { - error(ex.message); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - findContacts(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`find' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - String name = args.get(0); - _foundContacts = _phoneBook.findContacts(name); - _current = 0; - System.out.println("number of contacts found: " + _foundContacts.length); - printCurrent(); - } - catch(DatabaseException ex) - { - error(ex.message); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - nextFoundContact() - { - if(_current != _foundContacts.length) - { - ++_current; - } - printCurrent(); - } - - void - printCurrent() - { - try - { - if(_current != _foundContacts.length) - { - System.out.println("current contact is:" ); - System.out.println("name: " + _foundContacts[_current].getName()); - System.out.println("address: " + _foundContacts[_current].getAddress() ); - System.out.println("phone: " + _foundContacts[_current].getPhone()); - } - else - { - System.out.println("no current contact"); - } - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current contact no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - setCurrentName(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`name' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - if(_current != _foundContacts.length) - { - String name = args.get(0); - _foundContacts[_current].setName(name); - System.out.println("changed name to `" + name + "'"); - } - else - { - System.out.println("no current contact"); - } - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current contact no longer exists"); - } - catch(DatabaseException ex) - { - error(ex.message); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - setCurrentAddress(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`address' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - if(_current != _foundContacts.length) - { - String addr = args.get(0); - _foundContacts[_current].setAddress(addr); - System.out.println( "changed address to `" + addr + "'" ); - } - else - { - System.out.println( "no current contact" ); - } - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current contact no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - setCurrentPhone(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`phone' requires exactly one argument (type `help' for more info)"); - return; - } - - try - { - if(_current != _foundContacts.length) - { - String number = args.get(0); - _foundContacts[_current].setPhone(number); - System.out.println( "changed phone number to `" + number + "'" ); - } - else - { - System.out.println( "no current contact" ); - } - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current contact no longer exists"); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - removeCurrent() - { - try - { - if(_current != _foundContacts.length) - { - _foundContacts[_current].destroy(); - System.out.println( "removed current contact" ); - } - else - { - System.out.println( "no current contact" ); - } - } - catch(Ice.ObjectNotExistException ex) - { - System.out.println("current contact no longer exists"); - } - catch(DatabaseException ex) - { - error(ex.message); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - setEvictorSize(java.util.List<String> args) - { - if(args.size() != 1) - { - error("`size' requires exactly one argument (type `help' for more info)"); - return; - } - - String s = args.get(0); - try - { - _phoneBook.setEvictorSize(Integer.parseInt(s)); - } - catch(NumberFormatException ex) - { - error("not a number " + s); - } - catch(DatabaseException ex) - { - error(ex.message); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - shutdown() - { - try - { - _phoneBook.shutdown(); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - error(String s) - { - System.err.println("error: " + s); - } - - void - warning(String s) - { - System.err.println("warning: " + s); - } - - String - getInput() - { - System.out.print(">>> "); - System.out.flush(); - - try - { - return _in.readLine(); - } - catch(java.io.IOException e) - { - return null; - } - } - - int - parse() - { - _foundContacts = new ContactPrx[0]; - _current = 0; - - _in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - private ContactPrx[] _foundContacts; - private int _current; - - private PhoneBookPrx _phoneBook; - - private java.io.BufferedReader _in; -} diff --git a/java/demo/Freeze/phonebook/PhoneBook.ice b/java/demo/Freeze/phonebook/PhoneBook.ice deleted file mode 100644 index 063c364d513..00000000000 --- a/java/demo/Freeze/phonebook/PhoneBook.ice +++ /dev/null @@ -1,50 +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 - -#include <Ice/Identity.ice> - -module Demo -{ - -exception DatabaseException -{ - string message; -}; - -class Contact -{ - idempotent string getName(); - ["freeze:write"] idempotent void setName(string name) throws DatabaseException; - - idempotent string getAddress(); - ["freeze:write"] idempotent void setAddress(string address); - - idempotent string getPhone(); - ["freeze:write"] idempotent void setPhone(string phone); - - ["freeze:write"] void destroy() throws DatabaseException; - - string name; - string address; - string phone; -}; - -sequence<Contact*> Contacts; - -interface PhoneBook -{ - Contact* createContact() throws DatabaseException; - idempotent Contacts findContacts(string name) throws DatabaseException; - void setEvictorSize(int size) throws DatabaseException; - void shutdown(); -}; - -}; diff --git a/java/demo/Freeze/phonebook/PhoneBookI.java b/java/demo/Freeze/phonebook/PhoneBookI.java deleted file mode 100644 index e29011162b6..00000000000 --- a/java/demo/Freeze/phonebook/PhoneBookI.java +++ /dev/null @@ -1,94 +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 Demo.*; - -class PhoneBookI extends _PhoneBookDisp -{ - @Override - public ContactPrx - createContact(Ice.Current current) - throws DatabaseException - { - // - // Generate a new unique identity. - // - Ice.Identity ident = new Ice.Identity(); - ident.name = java.util.UUID.randomUUID().toString(); - ident.category = "contact"; - - // - // Create a new Contact Servant. - // - ContactI contact = new ContactI(_contactFactory); - - // - // Create a new Ice Object in the evictor, using the new - // identity and the new Servant. - // - _evictor.add(contact, ident); - - return ContactPrxHelper.uncheckedCast(current.adapter.createProxy(ident)); - } - - @Override - public ContactPrx[] - findContacts(String name, Ice.Current current) - throws DatabaseException - { - try - { - Ice.Identity[] identities = _index.find(name); - - ContactPrx[] contacts = new ContactPrx[identities.length]; - for(int i = 0; i < identities.length; ++i) - { - contacts[i] = ContactPrxHelper.uncheckedCast - (current.adapter.createProxy(identities[i])); - } - return contacts; - } - catch(Freeze.DatabaseException ex) - { - DatabaseException e = new DatabaseException(); - e.message = ex.message; - throw e; - } - } - - @Override - public void - setEvictorSize(int size, Ice.Current current) - throws DatabaseException - { - // - // No synchronization necessary, _evictor is immutable. - // - _evictor.setSize(size); - } - - @Override - public void - shutdown(Ice.Current current) - { - current.adapter.getCommunicator().shutdown(); - } - - PhoneBookI(Freeze.Evictor evictor, ContactFactory contactFactory, - NameIndex index) - { - _evictor = evictor; - _contactFactory = contactFactory; - _index = index; - } - - private Freeze.Evictor _evictor; - private ContactFactory _contactFactory; - private NameIndex _index; -} diff --git a/java/demo/Freeze/phonebook/README b/java/demo/Freeze/phonebook/README deleted file mode 100644 index 45233b9db38..00000000000 --- a/java/demo/Freeze/phonebook/README +++ /dev/null @@ -1,28 +0,0 @@ -This example demonstrates the use of Freeze to manage contacts in a -phone book. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In another window, populate the server's database by starting the -client and redirecting its input from the file "contacts": - -$ java -jar build/libs/client.jar < contacts - -Then start the client again to use the demo interactively: - -$ java -jar build/libs/client.jar - -Type "help" to get a list of valid commands. - -The collocated executable combines the client and server into one -program. In this case you do not need to start a separate server. -If you have not already populated the database, you can do so using -the collocated executable as shown below: - -$ java -jar build/libs/collocated.jar < contacts - -Then start the interactive demo like this: - -$ java -jar build/libs/collocated.jar diff --git a/java/demo/Freeze/phonebook/RunParser.java b/java/demo/Freeze/phonebook/RunParser.java deleted file mode 100644 index 79dda050408..00000000000 --- a/java/demo/Freeze/phonebook/RunParser.java +++ /dev/null @@ -1,27 +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 Demo.*; - -class RunParser -{ - static int - runParser(String appName, String[] args, Ice.Communicator communicator) - { - PhoneBookPrx phoneBook = PhoneBookPrxHelper.checkedCast(communicator.propertyToProxy("PhoneBook.Proxy")); - if(phoneBook == null) - { - System.err.println(appName + ": invalid object reference"); - return 1; - } - - Parser parser = new Parser(phoneBook); - return parser.parse(); - } -} diff --git a/java/demo/Freeze/phonebook/Scanner.java b/java/demo/Freeze/phonebook/Scanner.java deleted file mode 100644 index 7fee631fda6..00000000000 --- a/java/demo/Freeze/phonebook/Scanner.java +++ /dev/null @@ -1,287 +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. -// -// ********************************************************************** - -class Scanner -{ - Scanner(Parser p) - { - _parser = p; - } - - Token - nextToken() - { - String s = next(); - if(s == null) - { - return null; - } - - if(s.equals(";")) - { - return new Token(Token.TOK_SEMI); - } - else if(s.equals("help")) - { - return new Token(Token.TOK_HELP); - } - else if(s.equals("exit") || s.equals("quit")) - { - return new Token(Token.TOK_EXIT); - } - else if(s.equals("add")) - { - return new Token(Token.TOK_ADD_CONTACTS); - } - else if(s.equals("find")) - { - return new Token(Token.TOK_FIND_CONTACTS); - } - else if(s.equals("next")) - { - return new Token(Token.TOK_NEXT_FOUND_CONTACT); - } - else if(s.equals("current")) - { - return new Token(Token.TOK_PRINT_CURRENT); - } - else if(s.equals("name")) - { - return new Token(Token.TOK_SET_CURRENT_NAME); - } - else if(s.equals("address")) - { - return new Token(Token.TOK_SET_CURRENT_ADDRESS); - } - else if(s.equals("phone")) - { - return new Token(Token.TOK_SET_CURRENT_PHONE); - } - else if(s.equals("remove")) - { - return new Token(Token.TOK_REMOVE_CURRENT); - } - else if(s.equals("size")) - { - return new Token(Token.TOK_SET_EVICTOR_SIZE); - } - else if(s.equals("shutdown")) - { - return new Token(Token.TOK_SHUTDOWN); - } - else - { - return new Token(Token.TOK_STRING, s); - } - } - - static private class EndOfInput extends Exception - { - } - - private char - get() - throws EndOfInput - { - // - // If there is an character in the unget buffer, return it. - // - if(_unget) - { - _unget = false; - return _ungetChar; - } - - // - // No current buffer? - // - if(_buf == null) - { - _buf = _parser.getInput(); - _pos = 0; - if(_buf == null) - { - throw new EndOfInput(); - } - } - - // - // At the end-of-buffer? - // - while(_pos >= _buf.length()) - { - _buf = null; - _pos = 0; - return '\n'; - } - - return _buf.charAt(_pos++); - } - - // - // unget only works with one character. - // - private void - unget(char c) - { - assert(!_unget); - _unget = true; - _ungetChar = c; - } - - private String - next() - { - // - // Eat any whitespace. - // - char c; - try - { - do - { - c = get(); - } - while(Character.isWhitespace(c) && c != '\n'); - } - catch(EndOfInput ignore) - { - return null; - } - - StringBuilder buf = new StringBuilder(128); - - if(c == ';' || c == '\n') - { - buf.append(';'); - } - else if(c == '\'') - { - try - { - while(true) - { - c = get(); - if(c == '\'') - { - break; - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else if(c == '\"') - { - try - { - while(true) - { - c = get(); - if(c == '\"') - { - break; - } - else if(c == '\\') - { - try - { - char next = get(); - switch(next) - { - case '\\': - case '"': - { - buf.append(next); - break; - } - - case 'n': - { - buf.append('\n'); - break; - } - - case 'r': - { - buf.append('\r'); - break; - } - - case 't': - { - buf.append('\t'); - break; - } - - case 'f': - { - buf.append('\f'); - break; - } - - default: - { - buf.append(c); - unget(next); - } - } - } - catch(EndOfInput e) - { - buf.append(c); - } - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else - { - // - // Otherwise it's a string. - // - try - { - do - { - buf.append(c); - c = get(); - } - while(!Character.isWhitespace(c) && c != ';' && c != '\n'); - - unget(c); - } - catch(EndOfInput ignore) - { - } - } - - return buf.toString(); - } - - private Parser _parser; - private boolean _unget = false; - private char _ungetChar; - private String _buf = null; - private int _pos; -} diff --git a/java/demo/Freeze/phonebook/Server.java b/java/demo/Freeze/phonebook/Server.java deleted file mode 100644 index cbca1e1eb60..00000000000 --- a/java/demo/Freeze/phonebook/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. -// -// ********************************************************************** - -class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.Properties properties = communicator().getProperties(); - - // - // Create and install a factory for contacts. - // - ContactFactory contactFactory = new ContactFactory(); - communicator().addObjectFactory(contactFactory, Demo.Contact.ice_staticId()); - - // - // Create an object adapter - // - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("PhoneBook"); - - // - // Create the name index. - // - NameIndex index = new NameIndex("name"); - Freeze.Index[] indices = new Freeze.Index[1]; - indices[0] = index; - - // - // Create an evictor for contacts. - // When Freeze.Evictor.db.contacts.PopulateEmptyIndices is not 0 and the - // Name index is empty, Freeze will traverse the database to recreate - // the index during createEvictor(). Therefore the factories for the objects - // stored in evictor (contacts here) must be registered before the call - // to createEvictor(). - // - Freeze.Evictor evictor = Freeze.Util.createBackgroundSaveEvictor(adapter, _envName, "contacts", null, indices, true); - int evictorSize = properties.getPropertyAsInt("EvictorSize"); - if(evictorSize > 0) - { - evictor.setSize(evictorSize); - } - - // - // Completes the initialization of the contact factory. Note that ContactI/ - // ContactFactoryI uses this evictor only when a Contact is destroyed, - // which cannot happen during createEvictor(). - // - contactFactory.setEvictor(evictor); - - // - // Register the evictor with the adapter - // - adapter.addServantLocator(evictor, "contact"); - - // - // Create the phonebook, and add it to the object adapter. - // - PhoneBookI phoneBook = new PhoneBookI(evictor, contactFactory, index); - adapter.add(phoneBook, communicator().stringToIdentity("phonebook")); - - // - // Everything ok, let's go. - // - adapter.activate(); - - shutdownOnInterrupt(); - communicator().waitForShutdown(); - defaultInterrupt(); - return 0; - } - - Server(String envName) - { - _envName = envName; - } - - static public void - main(String[] args) - { - Server app = new Server("db"); - app.main("demo.Freeze.phonebook.Server", args, "config.server"); - } - - private String _envName; -} diff --git a/java/demo/Freeze/phonebook/Token.java b/java/demo/Freeze/phonebook/Token.java deleted file mode 100644 index 32940480b40..00000000000 --- a/java/demo/Freeze/phonebook/Token.java +++ /dev/null @@ -1,41 +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. -// -// ********************************************************************** - -class Token -{ - public static final int TOK_HELP = 0; - public static final int TOK_EXIT = 1; - public static final int TOK_ADD_CONTACTS = 2; - public static final int TOK_FIND_CONTACTS = 3; - public static final int TOK_NEXT_FOUND_CONTACT = 4; - public static final int TOK_PRINT_CURRENT = 5; - public static final int TOK_SET_CURRENT_NAME = 6; - public static final int TOK_SET_CURRENT_ADDRESS = 7; - public static final int TOK_SET_CURRENT_PHONE = 8; - public static final int TOK_REMOVE_CURRENT = 9; - public static final int TOK_SET_EVICTOR_SIZE = 10; - public static final int TOK_SHUTDOWN = 11; - public static final int TOK_STRING = 12; - public static final int TOK_SEMI = 13; - - int type; - String value; - - Token(int t) - { - type = t; - value = null; - } - - Token(int t, String v) - { - type = t; - value = v; - } -} diff --git a/java/demo/Freeze/phonebook/build.gradle b/java/demo/Freeze/phonebook/build.gradle deleted file mode 100644 index 815cb468d8d..00000000000 --- a/java/demo/Freeze/phonebook/build.gradle +++ /dev/null @@ -1,55 +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. -// -// ********************************************************************** - -slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } - freezej { - files = [file("PhoneBook.ice")] - args = "--ice" - index { - NameIndex { - javaType = "NameIndex" - type = "Demo::Contact" - member = "name" - casesensitive = false - } - } - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - compile localDependency("ice") - compile localDependency("freeze") - compile files(dbJar) - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } -} - -clean { - delete fileTree(dir: 'db', excludes:['.gitignore', 'DB_CONFIG']) -} - -// Don't create the default jar. -jar.enabled = false - -demoJar("client") -demoJar("server") -demoJar("collocated") diff --git a/java/demo/Freeze/phonebook/config.client b/java/demo/Freeze/phonebook/config.client deleted file mode 100644 index 9c6da7f62f8..00000000000 --- a/java/demo/Freeze/phonebook/config.client +++ /dev/null @@ -1,29 +0,0 @@ -# -# The client reads this property to create the reference to the -# "phonebook" object in the server. -# -PhoneBook.Proxy=phonebook:default -h localhost -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/Freeze/phonebook/config.collocated b/java/demo/Freeze/phonebook/config.collocated deleted file mode 100644 index 9be79c92996..00000000000 --- a/java/demo/Freeze/phonebook/config.collocated +++ /dev/null @@ -1,75 +0,0 @@ -# -# Configure the server endpoints. -# -PhoneBook.Endpoints=default -h localhost -p 10000 - -# -# Set the evictor size. The size set here (3) is far too small for -# real-world applications. However, for the purposes of this demo, -# setting the size to 3 allows us to see the operation of the evictor -# with evictor tracing. -# -EvictorSize=3 - -# -# The client reads this property to create the reference to the -# "phonebook" object in the server. -# -PhoneBook.Proxy=phonebook:default -h localhost -p 10000 - -# -# Don't warn about unknown properties. If this is not set we'll get a -# warning about "PhoneBook.Proxy" since the Ice run time thinks this is -# an OA property due to the Object Adapter "PhoneBook". -# -Ice.Warn.UnknownProperties=0 - -# -# Set the save period for the contacts Freeze evictor -# to 10 seconds. -# -Freeze.Evictor.db.contacts.SavePeriod=10000 - -# -# Freeze Evictor Tracing. -# -# 0 = No evictor activity trace (default). -# 1 = Trace Ice object and facet creation and destruction, facet -# streaming time, facet saving time, object eviction (every 50 -# objects) and evictor deactivation. -# 2 = Also trace object lookups, and all object evictions. -# 3 = Also trace object retrieval from the database. -# -Freeze.Trace.Evictor=2 - -# -# Freeze Database Environment Tracing. -# -# 0 = No database environment activity trace (default). -# 1 = Trace database open and close. -# 2 = Also trace checkpoints and the removal of old log files. -# -Freeze.Trace.DbEnv=2 - -# -# 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/Freeze/phonebook/config.server b/java/demo/Freeze/phonebook/config.server deleted file mode 100644 index 45e5b9a0055..00000000000 --- a/java/demo/Freeze/phonebook/config.server +++ /dev/null @@ -1,62 +0,0 @@ -# -# Configure the server endpoints. -# -PhoneBook.Endpoints=default -h localhost -p 10000 - -# -# Set the evictor size. The size set here (3) is far too small for -# real-world applications. However, for the purposes of this demo, -# setting the size to 3 allows us to see the operation of the evictor -# with evictor tracing. -# -EvictorSize=3 - -# -# Set the save period for the contacts Freeze evictor -# to 10 seconds. -# -Freeze.Evictor.db.contacts.SavePeriod=10000 - -# -# Freeze Evictor Tracing. -# -# 0 = No evictor activity trace (default). -# 1 = Trace Ice object and facet creation and destruction, facet -# streaming time, facet saving time, object eviction (every 50 -# objects) and evictor deactivation. -# 2 = Also trace object lookups, and all object evictions. -# 3 = Also trace object retrieval from the database. -# -Freeze.Trace.Evictor=2 - -# -# Freeze Database Environment Tracing. -# -# 0 = No database environment activity trace (default). -# 1 = Trace database open and close. -# 2 = Also trace checkpoints and the removal of old log files. -# -Freeze.Trace.DbEnv=2 - -# -# 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/Freeze/phonebook/contacts b/java/demo/Freeze/phonebook/contacts deleted file mode 100644 index 4270fc7f770..00000000000 --- a/java/demo/Freeze/phonebook/contacts +++ /dev/null @@ -1,36 +0,0 @@ -add "Doe, John" "Doe, Jane" "Doe, Jack" "Doe, Bob" -add "Doe, John" "Doe, John" - -find "Doe, John" -address "10 Main Street, Smalltown, XY 01234, USA" -phone "(123) 345-7890" - -next -address "10 Broadway, Mutable City, CD 22222, USA" -phone "(555) 111-2222" - -next -address "11 Narrowway, Static Town, EF 33333, USA" -phone "(678) 234-2299" - -find "Doe, Jane" -address "10 Main Street, Smalltown, XY 01234, USA" -phone "(123) 345-7890" - -find "Doe, Jack" -address "11 Great Road, Bigtown, YZ 43210, USA" -phone "(777) 123-456" - -find "Doe, Bob" -address "99 Little Road, Nowhere, AB 11111, USA" -phone "(777) 123-456" - -add "Mustermann, Manfred" "Mustermann, Matilda" - -find "Mustermann, Manfred" -address "Musterstrasse 10, D-12345 Kleinstadt, Germany" -phone "(01234) 56789" - -find "Mustermann, Matilda" -address "Musterstrasse 10, D-12345 Kleinstadt, Germany" -phone "(01234) 56789" diff --git a/java/demo/Freeze/phonebook/db/.gitignore b/java/demo/Freeze/phonebook/db/.gitignore deleted file mode 100644 index 39af5887579..00000000000 --- a/java/demo/Freeze/phonebook/db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# Dummy file, so that git retains this otherwise empty directory. diff --git a/java/demo/Freeze/phonebook/expect.py b/java/demo/Freeze/phonebook/expect.py deleted file mode 100755 index 8938f4bc301..00000000000 --- a/java/demo/Freeze/phonebook/expect.py +++ /dev/null @@ -1,47 +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 - -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 -from demoscript.Freeze import phonebook - -sys.stdout.write("cleaning databases... ") -sys.stdout.flush() -Util.cleanDbDir("db") -print("ok") - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar') -client.expect('>>> ') - -phonebook.run(client, server) - -print("running with collocated server") - -sys.stdout.write("cleaning databases... ") -sys.stdout.flush() -Util.cleanDbDir("db") -print("ok") - -server = Util.spawn('java -jar build/libs/collocated.jar --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') -server.expect('>>> ') - -phonebook.run(server, server) diff --git a/java/demo/Freeze/transform/.externalToolBuilders/demo.Freeze.transform.slice.launch b/java/demo/Freeze/transform/.externalToolBuilders/demo.Freeze.transform.slice.launch deleted file mode 100644 index 8b69a023fcd..00000000000 --- a/java/demo/Freeze/transform/.externalToolBuilders/demo.Freeze.transform.slice.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="${project}"/> -<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.Freeze.transform"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Freeze.transform/ContactData.ice" type="1"/> <item path="/demo.Freeze.transform/NewContactData.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Freeze.transform/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/Freeze/transform/.gitignore b/java/demo/Freeze/transform/.gitignore deleted file mode 100644 index 7af6d958762..00000000000 --- a/java/demo/Freeze/transform/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -db/* -dbnew/* diff --git a/java/demo/Freeze/transform/ContactData.ice b/java/demo/Freeze/transform/ContactData.ice deleted file mode 100644 index 81599fe5f6d..00000000000 --- a/java/demo/Freeze/transform/ContactData.ice +++ /dev/null @@ -1,23 +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 Demo -{ - -// -// The original contact data -// -struct ContactData -{ - string phoneNumber; -}; - -}; diff --git a/java/demo/Freeze/transform/Create.java b/java/demo/Freeze/transform/Create.java deleted file mode 100644 index e58d49c05e4..00000000000 --- a/java/demo/Freeze/transform/Create.java +++ /dev/null @@ -1,86 +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 Demo.*; -import Freeze.*; - -class Create extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - final String[] names = { "don", "ed", "frank", "gary", "arnold", "bob", "carlos" }; - final String[] phoneNumbers = { "(777)777-7777", "(666)666-6666", "(555)555-5555 x123", - "(444)444-4444", "(333)333-3333 x1234", "(222)222-2222", "(111)111-1111" }; - - Connection connection = Util.createConnection(communicator(), "db"); - - final java.util.Comparator<String> less = new java.util.Comparator<String>() - { - @Override - public int compare(String s1, String s2) - { - if(s1 == s2) - { - return 0; - } - else if(s1 == null) - { - return -s2.compareTo(s1); - } - else - { - return s1.compareTo(s2); - } - } - }; - - Contacts.IndexComparators indexComparators = new Contacts.IndexComparators(less); - Contacts contacts = new Contacts(connection, "contacts", true, less, indexComparators); - - // - // Create a bunch of contacts within one transaction, and commit it - // - try - { - Transaction tx = connection.beginTransaction(); - - for(int i = 0; i < names.length; ++i) - { - ContactData data = new ContactData(phoneNumbers[i]); - contacts.put(names[i], data); - } - - tx.commit(); - } - finally - { - connection.close(); - } - - System.out.println(names.length + " contacts were successfully created or updated"); - - return 0; - } - - static public void - main(String[] args) - { - Create app = new Create(); - int status = app.main("demo.Freeze.transform.Create", args); - System.exit(status); - } -} diff --git a/java/demo/Freeze/transform/NewContactData.ice b/java/demo/Freeze/transform/NewContactData.ice deleted file mode 100644 index dcd475e575e..00000000000 --- a/java/demo/Freeze/transform/NewContactData.ice +++ /dev/null @@ -1,29 +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 Demo -{ - -// -// A new, improved version of ContactData -// -// Typically we would keep the same type name (ContactData). -// For this Java demo we pick a different names to be able to -// build both old and new versions in the same directory. -// - -struct NewContactData -{ - string phoneNumber; - string emailAddress; -}; - -}; diff --git a/java/demo/Freeze/transform/README b/java/demo/Freeze/transform/README deleted file mode 100644 index 2cdce4e3b53..00000000000 --- a/java/demo/Freeze/transform/README +++ /dev/null @@ -1,111 +0,0 @@ -This demo shows how to transform a Freeze map when its definition -changes. - -In this demo, we start with a simple "contacts" map: - - key = string - value = struct ContactData - { - string phoneNumber; - }; - -Later on, we want to add a new data member to ContactData: - -// -// New version of ContactData defined in NewContactData.ice -// -struct NewContactData -{ - string phoneNumber; - string emailAddress; -}; - -If the contacts map was not sorted on its key, the transformation -would be a straightforward 'FreezeScript' transformation: - -$ transformdb --old ContactData.ice --new NewContactData.ice db dbnew - -(with -f <xml-file> if you want a customized transformation) - -With a sorted map, the situation is more complicated. transformdb -is unaware of the sort order, and as a result transforms the map into -an unsorted map -- or more precisely, a new map sorted using Berkeley -DB's default sort order (comparison of binary strings that correspond -to data encoded using the Ice encoding). - -The solution, illustrated in this demo, is to recreate the map -after the successful transformdb transformation. - -This demo provides four programs: - - - Create - - Creates or updates the contacts map in the 'db' directory (uses - the old version of ContactData) - - - Read - - Reads and displays the contents of the contacts map in the 'db' - directory (uses the old version of ContactData) - - - ReadNew - - Reads and displays the contents of the contacts map in the 'dbnew' - directory (uses the new version of ContactData) - - - Recreate - - Recreate the contacts map in the 'dbnew' directory (uses the new - version of ContactData) - - -Running the demo ----------------- - - - first create the original map, by running Create: - - $ java -jar build/libs/create.jar - - - display the entries created by create: - - $ java -jar build/libs/read.jar - - Please notice the alphabetical sort order. - - - transform the contacts database to the new format: - - $ transformdb --old ContactData.ice --new NewContactData.ice \ - -f transform.xml db dbnew - - - read the transformed contacts map: - - $ java -jar build/libs/readnew.jar - - You'll notice the sort order (looks random), and the corrupt index. - The index is actually created by ReadNew when it opens contacts; - the mismatch between the expected sort order (alphabetical) and - actual sort order leads to this corruption. - - If you prefer, you can update ReadNew with - - boolean createDb = false - - With this update, ReadNew does not create the index and will fail - to open the contacts map when the associated phoneNumber index does - not exist. - - - recreate the new contacts map with: - - $ java -jar build/libs/recreate.jar - - Recreate reads and rewrites the contacts map with the proper sort - order; it also removes and recreates the phoneNumber index. You can - run 'java Recreate --Freeze.Trace.Map=2' to get more information on - the actions performed by Recreate. - - - read again the new contacts map: - - $ java -jar build/libs/readnew.jar - - This time, the sort order should be alphabetical again, and ReadNew - is expected to complete successfully. diff --git a/java/demo/Freeze/transform/Read.java b/java/demo/Freeze/transform/Read.java deleted file mode 100644 index 5b07a4dcd68..00000000000 --- a/java/demo/Freeze/transform/Read.java +++ /dev/null @@ -1,84 +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 Demo.*; -import Freeze.*; - -class Read extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Connection connection = Util.createConnection(communicator(), "db"); - - final java.util.Comparator<String> less = new java.util.Comparator<String>() - { - @Override - public int compare(String s1, String s2) - { - if(s1 == s2) - { - return 0; - } - else if(s1 == null) - { - return -s2.compareTo(s1); - } - else - { - return s1.compareTo(s2); - } - } - }; - - try - { - Contacts.IndexComparators indexComparators = new Contacts.IndexComparators(less); - Contacts contacts = new Contacts(connection, "contacts", false, less, indexComparators); - - System.out.println("All contacts (default order)"); - for(java.util.Map.Entry<String, ContactData> entry : contacts.entrySet()) - { - System.out.println(entry.getKey() + ":\t\t" + entry.getValue().phoneNumber); - } - - System.out.println("\nAll contacts (ordered by phone number)"); - java.util.SortedMap<String, java.util.Set<java.util.Map.Entry<String, ContactData>>> phoneNumberMap = - contacts.mapForPhoneNumber(); - for(java.util.Set<java.util.Map.Entry<String, ContactData>> entries : phoneNumberMap.values()) - { - for(java.util.Map.Entry<String, ContactData> entry : entries) - { - System.out.println(entry.getKey() + ":\t\t" + entry.getValue().phoneNumber); - } - } - } - finally - { - connection.close(); - } - - return 0; - } - - static public void - main(String[] args) - { - Read app = new Read(); - int status = app.main("demo.Freeze.transform.Read", args); - System.exit(status); - } -} diff --git a/java/demo/Freeze/transform/ReadNew.java b/java/demo/Freeze/transform/ReadNew.java deleted file mode 100644 index 2c8ff43f8ae..00000000000 --- a/java/demo/Freeze/transform/ReadNew.java +++ /dev/null @@ -1,87 +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 Demo.*; -import Freeze.*; - -class ReadNew extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Connection connection = Util.createConnection(communicator(), "dbnew"); - - final java.util.Comparator<String> less = new java.util.Comparator<String>() - { - @Override - public int compare(String s1, String s2) - { - if(s1 == s2) - { - return 0; - } - else if(s1 == null) - { - return -s2.compareTo(s1); - } - else - { - return s1.compareTo(s2); - } - } - }; - - try - { - NewContacts.IndexComparators indexComparators = new NewContacts.IndexComparators(less); - boolean createDb = true; - NewContacts contacts = new NewContacts(connection, "contacts", createDb, less, indexComparators); - - System.out.println("All contacts (default order)"); - for(java.util.Map.Entry<String, NewContactData> entry : contacts.entrySet()) - { - NewContactData data = entry.getValue(); - System.out.println(entry.getKey() + ":\t\t" + data.phoneNumber + " " + data.emailAddress); - } - - System.out.println("\nAll contacts (ordered by phone number)"); - java.util.SortedMap<String, java.util.Set<java.util.Map.Entry<String, NewContactData>>> phoneNumberMap = - contacts.mapForPhoneNumber(); - for(java.util.Set<java.util.Map.Entry<String, NewContactData>> entries : phoneNumberMap.values()) - { - for(java.util.Map.Entry<String, NewContactData> entry : entries) - { - NewContactData data = entry.getValue(); - System.out.println(entry.getKey() + ":\t\t" + data.phoneNumber + " " + data.emailAddress); - } - } - } - finally - { - connection.close(); - } - - return 0; - } - - static public void - main(String[] args) - { - ReadNew app = new ReadNew(); - int status = app.main("demo.Freeze.transform.ReadNew", args); - System.exit(status); - } -} diff --git a/java/demo/Freeze/transform/Recreate.java b/java/demo/Freeze/transform/Recreate.java deleted file mode 100644 index 689d8199c92..00000000000 --- a/java/demo/Freeze/transform/Recreate.java +++ /dev/null @@ -1,69 +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 Demo.*; -import Freeze.*; - -class Recreate extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Connection connection = Util.createConnection(communicator(), "dbnew"); - - final java.util.Comparator<String> less = new java.util.Comparator<String>() - { - @Override - public int compare(String s1, String s2) - { - if(s1 == s2) - { - return 0; - } - else if(s1 == null) - { - return -s2.compareTo(s1); - } - else - { - return s1.compareTo(s2); - } - } - }; - - try - { - NewContacts.IndexComparators indexComparators = new NewContacts.IndexComparators(less); - NewContacts.recreate(connection, "contacts", less, indexComparators); - } - finally - { - connection.close(); - } - - System.out.println("Recreated contacts database successfully!"); - - return 0; - } - - static public void - main(String[] args) - { - Recreate app = new Recreate(); - int status = app.main("demo.Freeze.transform.Recreate", args); - System.exit(status); - } -} diff --git a/java/demo/Freeze/transform/build.gradle b/java/demo/Freeze/transform/build.gradle deleted file mode 100644 index 790515e2ca9..00000000000 --- a/java/demo/Freeze/transform/build.gradle +++ /dev/null @@ -1,121 +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. -// -// ********************************************************************** - -slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } - freezej { - files = [file("ContactData.ice"), file("NewContactData.ice")] - include = ["${projectDir}"] - args = "--ice" - dict { - Contacts { - javaType = "Demo.Contacts" - key = "string" - value = "Demo::ContactData" - index = [[ member: 'phoneNumber', case: 'false']] - } - NewContacts { - javaType = "Demo.NewContacts" - key = "string" - value = "Demo::NewContactData" - index = [[ member: 'phoneNumber', case: 'false']] - } - } - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - compile localDependency("ice") - compile localDependency("freeze") - compile files(dbJar) - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } -} - -// Create a jar for the client & server which includes everything in the demo. -task createJar(type: Jar) { - version = "" - baseName = "create" - from(sourceSets.main.output) { - include "**" - } -} - -task recreateJar(type: Jar) { - version = "" - baseName = "recreate" - from(sourceSets.main.output) { - include "**" - } -} - -task readJar(type: Jar) { - version = "" - baseName = "read" - from(sourceSets.main.output) { - include "**" - } -} - -task readnewJar(type: Jar) { - version = "" - baseName = "readnew" - from(sourceSets.main.output) { - include "**" - } -} - -createJar { - manifest { - attributes("Main-Class": "Create") - attributes("Class-Path": configurations.compile.resolve().collect { it.toURI() }.join(' ')) - } -} - -recreateJar { - manifest { - attributes("Main-Class": "Recreate") - attributes("Class-Path": configurations.compile.resolve().collect { it.toURI() }.join(' ')) - } -} - -readJar { - manifest { - attributes("Main-Class": "Read") - attributes("Class-Path": configurations.compile.resolve().collect { it.toURI() }.join(' ')) - } -} - -readnewJar { - manifest { - attributes("Main-Class": "ReadNew") - attributes("Class-Path": configurations.compile.resolve().collect { it.toURI() }.join(' ')) - } -} - -clean { - delete fileTree(dir: 'db', excludes:['.gitignore', 'DB_CONFIG']) - delete fileTree(dir: 'dbNew', excludes:['.gitignore', 'DB_CONFIG']) -} - -artifacts { - archives createJar, recreateJar, readJar, readnewJar; -} diff --git a/java/demo/Freeze/transform/db/.gitignore b/java/demo/Freeze/transform/db/.gitignore deleted file mode 100644 index 39af5887579..00000000000 --- a/java/demo/Freeze/transform/db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# Dummy file, so that git retains this otherwise empty directory. diff --git a/java/demo/Freeze/transform/dbnew/.gitignore b/java/demo/Freeze/transform/dbnew/.gitignore deleted file mode 100644 index 39af5887579..00000000000 --- a/java/demo/Freeze/transform/dbnew/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# Dummy file, so that git retains this otherwise empty directory. diff --git a/java/demo/Freeze/transform/expect.py b/java/demo/Freeze/transform/expect.py deleted file mode 100755 index 4522ed88d57..00000000000 --- a/java/demo/Freeze/transform/expect.py +++ /dev/null @@ -1,25 +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 -from demoscript.Freeze import transform - -transform.run('java -jar build/libs/create.jar', 'java -jar build/libs/recreate.jar', 'java -jar build/libs/read.jar', 'java -jar build/libs/readnew.jar') diff --git a/java/demo/Freeze/transform/transform.xml b/java/demo/Freeze/transform/transform.xml deleted file mode 100644 index 6f36871de54..00000000000 --- a/java/demo/Freeze/transform/transform.xml +++ /dev/null @@ -1,13 +0,0 @@ - -<transformdb> - - <database name="contacts" key="string" value="::Demo::ContactData,::Demo::NewContactData"> - <record> - <set target="newvalue.phoneNumber" - value="oldvalue.phoneNumber"/> - <set target="newvalue.emailAddress" - value="oldkey + '@gmail.com'"/> - </record> - </database> - -</transformdb> diff --git a/java/demo/Glacier2/README b/java/demo/Glacier2/README deleted file mode 100644 index aedb88a9fa1..00000000000 --- a/java/demo/Glacier2/README +++ /dev/null @@ -1,15 +0,0 @@ -Demos in this directory: - -- callback - - Illustrates how to allow a server to call back into a client via a - Glacier2 connection. - -- chat - - A swing application that shows how to use write a graphical Glacier2 - client. - -- voip - - This demo contains the server side for the Ice Touch VOIP demo.
\ No newline at end of file diff --git a/java/demo/Glacier2/build.gradle b/java/demo/Glacier2/build.gradle deleted file mode 100644 index ff06e7a9136..00000000000 --- a/java/demo/Glacier2/build.gradle +++ /dev/null @@ -1,49 +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. -// -// ********************************************************************** - -['callback', 'chat', 'voip'].each { - def name = it - project(":demoGlacier2${it.capitalize()}") { - slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } - } - - sourceSets { - main { - java { - srcDir '.' - } - } - } - - dependencies { - compile localDependency("ice") - compile localDependency("glacier2") - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } - } - - // Don't create the default jar. - jar.enabled = false - - // The voip demo has no clientJar. - if(name != "voip") { - demoJar("client") - } - - // The chat demo has no serverJar. - if(name != "chat") { - demoJar("server") - } - } -} diff --git a/java/demo/Glacier2/callback/.externalToolBuilders/demo.Glacier2.callback.slice.launch b/java/demo/Glacier2/callback/.externalToolBuilders/demo.Glacier2.callback.slice.launch deleted file mode 100644 index 9785ae35cce..00000000000 --- a/java/demo/Glacier2/callback/.externalToolBuilders/demo.Glacier2.callback.slice.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="${project}"/> -<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.Glacier2.callback"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Glacier2.callback/Callback.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Glacier2.callback/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/Glacier2/callback/Callback.ice b/java/demo/Glacier2/callback/Callback.ice deleted file mode 100644 index f9b8bee8bce..00000000000 --- a/java/demo/Glacier2/callback/Callback.ice +++ /dev/null @@ -1,26 +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 Demo -{ - -interface CallbackReceiver -{ - void callback(); -}; - -interface Callback -{ - void initiateCallback(CallbackReceiver* proxy); - void shutdown(); -}; - -}; diff --git a/java/demo/Glacier2/callback/CallbackI.java b/java/demo/Glacier2/callback/CallbackI.java deleted file mode 100644 index 48a8ca45e8f..00000000000 --- a/java/demo/Glacier2/callback/CallbackI.java +++ /dev/null @@ -1,43 +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 Demo.*; - -public final class CallbackI extends _CallbackDisp -{ - @Override - public void - initiateCallback(CallbackReceiverPrx proxy, Ice.Current current) - { - System.out.println("initiating callback to: " + current.adapter.getCommunicator().proxyToString(proxy)); - try - { - proxy.callback(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - - @Override - public void - shutdown(Ice.Current current) - { - System.out.println("shutting down..."); - try - { - current.adapter.getCommunicator().shutdown(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } -} diff --git a/java/demo/Glacier2/callback/CallbackReceiverI.java b/java/demo/Glacier2/callback/CallbackReceiverI.java deleted file mode 100644 index a9e53aa0e32..00000000000 --- a/java/demo/Glacier2/callback/CallbackReceiverI.java +++ /dev/null @@ -1,20 +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 Demo.*; - -public final class CallbackReceiverI extends _CallbackReceiverDisp -{ - @Override - public void - callback(Ice.Current current) - { - System.out.println("received callback"); - } -} diff --git a/java/demo/Glacier2/callback/Client.java b/java/demo/Glacier2/callback/Client.java deleted file mode 100644 index 07eab42ad0d..00000000000 --- a/java/demo/Glacier2/callback/Client.java +++ /dev/null @@ -1,267 +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 Demo.*; - -public class Client extends Glacier2.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private static void - menu() - { - System.out.println( - "usage:\n" + - "t: send callback as twoway\n" + - "o: send callback as oneway\n" + - "O: send callback as batch oneway\n" + - "f: flush all batch requests\n" + - "v: set/reset override context field\n" + - "F: set/reset fake category\n" + - "s: shutdown server\n" + - "r: restart the session\n" + - "x: exit\n" + - "?: help\n"); - } - - @Override - public void sessionDestroyed() - { - System.out.println("The Glacier2 session has been destroyed."); - } - - @Override - public Glacier2.SessionPrx createSession() - { - Glacier2.SessionPrx session; - while(true) - { - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - System.out.println("This demo accepts any user-id / password combination."); - - String id; - String pw; - try - { - System.out.print("user id: "); - System.out.flush(); - id = in.readLine(); - - System.out.print("password: "); - System.out.flush(); - pw = in.readLine(); - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - continue; - } - - try - { - session = router().createSession(id, pw); - break; - } - catch(Glacier2.PermissionDeniedException ex) - { - System.out.println("permission denied:\n" + ex.reason); - } - catch(Glacier2.CannotCreateSessionException ex) - { - System.out.println("cannot create session:\n" + ex.reason); - } - } - return session; - } - - @Override - public int - runWithSession(String[] args) - throws RestartSessionException - { - 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()); - - try - { - Ice.Identity callbackReceiverIdent = createCallbackIdentity("callbackReceiver"); - Ice.Identity callbackReceiverFakeIdent = new Ice.Identity("fake", "callbackReceiver"); - - Ice.ObjectPrx base = communicator().propertyToProxy("Callback.Proxy"); - CallbackPrx twoway = CallbackPrxHelper.checkedCast(base); - CallbackPrx oneway = CallbackPrxHelper.uncheckedCast(twoway.ice_oneway()); - CallbackPrx batchOneway = CallbackPrxHelper.uncheckedCast(twoway.ice_batchOneway()); - - objectAdapter().add(new CallbackReceiverI(), callbackReceiverFakeIdent); - - CallbackReceiverPrx twowayR = CallbackReceiverPrxHelper.uncheckedCast( - objectAdapter().add(new CallbackReceiverI(), callbackReceiverIdent)); - CallbackReceiverPrx onewayR = CallbackReceiverPrxHelper.uncheckedCast(twowayR.ice_oneway()); - - - menu(); - - String line = null; - String override = null; - boolean fake = false; - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - do - { - System.out.print("==> "); - System.out.flush(); - try - { - line = in.readLine(); - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - line = null; - } - - if(line == null) - { - break; - } - - if(line.equals("t")) - { - java.util.Map<String, String> context = new java.util.HashMap<String, String>(); - context.put("_fwd", "t"); - if(override != null) - { - context.put("_ovrd", override); - } - twoway.initiateCallback(twowayR, context); - } - else if(line.equals("o")) - { - java.util.Map<String, String> context = new java.util.HashMap<String, String>(); - context.put("_fwd", "o"); - if(override != null) - { - context.put("_ovrd", override); - } - oneway.initiateCallback(onewayR, context); - } - else if(line.equals("O")) - { - java.util.Map<String, String> context = new java.util.HashMap<String, String>(); - context.put("_fwd", "O"); - if(override != null) - { - context.put("_ovrd", override); - } - batchOneway.initiateCallback(onewayR, context); - } - else if(line.equals("f")) - { - batchOneway.ice_flushBatchRequests(); - } - else if(line.equals("v")) - { - if(override == null) - { - override = "some_value"; - System.out.println("override context field is now `" + override + "'"); - } - else - { - override = null; - System.out.println("override context field is empty"); - } - } - else if(line.equals("F")) - { - fake = !fake; - - if(fake) - { - twowayR = CallbackReceiverPrxHelper.uncheckedCast( - twowayR.ice_identity(callbackReceiverFakeIdent)); - onewayR = CallbackReceiverPrxHelper.uncheckedCast( - onewayR.ice_identity(callbackReceiverFakeIdent)); - } - else - { - twowayR = CallbackReceiverPrxHelper.uncheckedCast( - twowayR.ice_identity(callbackReceiverIdent)); - onewayR = CallbackReceiverPrxHelper.uncheckedCast( - onewayR.ice_identity(callbackReceiverIdent)); - } - - System.out.println("callback receiver identity: " + - communicator().identityToString(twowayR.ice_getIdentity())); - } - else if(line.equals("s")) - { - twoway.shutdown(); - } - else if(line.equals("r")) - { - restart(); - } - else if(line.equals("x")) - { - // Nothing to do - } - else if(line.equals("?")) - { - menu(); - } - else - { - System.out.println("unknown command `" + line + "'"); - menu(); - } - } - while(!line.equals("x")); - } - catch(Glacier2.SessionNotExistException ex) - { - System.err.println(appName() + ": " + ex.toString()); - return 1; - } - - 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/Glacier2/callback/README b/java/demo/Glacier2/callback/README deleted file mode 100644 index 8d5aabb2dd9..00000000000 --- a/java/demo/Glacier2/callback/README +++ /dev/null @@ -1,24 +0,0 @@ -This example demonstrates the use of a Glacier2 router with a set of -well known server objects. In this demo no Glacier2 session manager is -used. - -To run the demo: - -Start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the Glacier2 router: - -$ glacier2router --Ice.Config=config.glacier2 - -In a separate window, start the client: - -$ java -jar build/libs/client.jar - -If you plan to run this demo using clients on different hosts than the -router, you must first modify the configuration. You need to change -the Glacier2.Client.Endpoints property in config.glacier2 and the -Ice.Default.Router properties in config.client. In all cases you must -replace the "-h 127.0.0.1" parameter with the actual external address -of the machine on which glacier2router is running. diff --git a/java/demo/Glacier2/callback/Server.java b/java/demo/Glacier2/callback/Server.java deleted file mode 100644 index 8e05db7c991..00000000000 --- a/java/demo/Glacier2/callback/Server.java +++ /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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Callback.Server"); - adapter.add(new CallbackI(), communicator().stringToIdentity("callback")); - 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/Glacier2/callback/config.client b/java/demo/Glacier2/callback/config.client deleted file mode 100644 index fb6dadb75d2..00000000000 --- a/java/demo/Glacier2/callback/config.client +++ /dev/null @@ -1,50 +0,0 @@ -# -# The proxy to the Glacier2 router for all outgoing connections. This -# must match the value of Glacier2.Client.Endpoints in config.glacier2. -# -Ice.Default.Router=DemoGlacier2/router:ssl -p 4064 -h localhost - -# -# This must match the value of Callback.Server.Endpoints in -# config.server. -# -Callback.Proxy=callback:tcp -h localhost -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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password diff --git a/java/demo/Glacier2/callback/config.glacier2 b/java/demo/Glacier2/callback/config.glacier2 deleted file mode 100644 index b50a5317570..00000000000 --- a/java/demo/Glacier2/callback/config.glacier2 +++ /dev/null @@ -1,131 +0,0 @@ -# -# Set the instance name -# -Glacier2.InstanceName=DemoGlacier2 - -# -# The client-visible endpoint of Glacier2. This should be an endpoint -# visible from the public Internet, and it should be secure. -# -Glacier2.Client.Endpoints=ssl -p 4064 -h localhost - -# -# The server-visible endpoint of Glacier2. This endpoint is only -# required if callbacks are needed (leave empty otherwise). This -# should be an endpoint on an internal network (like 192.168.x.x), or -# on the loopback, so that the server is not directly accessible from -# the Internet. -# -Glacier2.Server.Endpoints=tcp -h localhost - -# -# For this demo, we use a null permissions verifier. -# -Glacier2.PermissionsVerifier=DemoGlacier2/NullPermissionsVerifier - -# -# The timeout for inactive sessions. If any client session is inactive -# for longer than this value, the session expires and is removed. The -# unit is seconds. -# -Glacier2.SessionTimeout=30 - -# -# Glacier can forward requests buffered or unbuffered. Unbuffered -# means a lower resource consumption, as buffering requires one -# additional thread per connected client or server. However, without -# buffering, messages cannot be batched and message overriding doesn't -# work either. Also, with unbuffered request forwarding, the caller -# thread blocks for twoway requests. -# The default is to use buffering (=1), in both directions. -#Glacier2.Client.Buffered=0 -#Glacier2.Server.Buffered=0 - -# -# These two lines instruct Glacier2 to forward contexts both for -# regular routing, as well as for callbacks (reverse routing). -# -Glacier2.Client.ForwardContext=1 -Glacier2.Server.ForwardContext=1 - -# -# To prevent Glacier2 from being flooded with requests from or to one -# particular client, Glacier2 can be configured to sleep for a certain -# period after all current requests for this client have been -# forwarded. During this sleep period, new requests for the client are -# queued. These requests are then all sent once the sleep period is -# over. The unit is milliseconds. -# -Glacier2.Client.SleepTime=500 -Glacier2.Server.SleepTime=500 - -# -# With the two settings below, Glacier2 can be instructed to always -# batch oneways, even if they are sent with a _fwd/o instead of a -# _fwd/O context. -# The default value for Glacier2.Client.AlwaysBatch and -# Glacier2.Server.AlwaysBatch is 0. -#Glacier2.Client.AlwaysBatch=1 -#Glacier2.Server.AlwaysBatch=1 - -# -# Glacier2 always disables active connection management so there is no -# need to configure this manually. Connection retry does not need to -# be disabled, as it's safe for Glacier2 to retry outgoing connections -# to servers. Retry for incoming connections from clients must be -# disabled in the clients. -# - -# -# Various settings to trace requests, overrides, etc. -# -Glacier2.Client.Trace.Request=1 -Glacier2.Server.Trace.Request=1 -Glacier2.Client.Trace.Override=1 -Glacier2.Server.Trace.Override=1 -Glacier2.Client.Trace.Reject=1 -Glacier2.Trace.Session=1 -Glacier2.Trace.RoutingTable=1 - -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing (default) -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL:createIceSSL -IceSSL.DefaultDir=../../../../certs -IceSSL.CertAuthFile=cacert.pem -IceSSL.CertFile=s_rsa1024.pfx -IceSSL.Password=password - -# Required for a Java 1.8 client to talk to a C++ server on OSX -IceSSL.ProtocolVersionMax=tls1_1 diff --git a/java/demo/Glacier2/callback/config.server b/java/demo/Glacier2/callback/config.server deleted file mode 100644 index dcf653ea5e9..00000000000 --- a/java/demo/Glacier2/callback/config.server +++ /dev/null @@ -1,30 +0,0 @@ -# -# The endpoint of the server's object adapter. This should be an -# endpoint on an internal network (like 192.168.x.x), or on the -# loopback, so that the server is not directly accessible from the -# Internet. -# -Callback.Server.Endpoints=tcp -h localhost -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/Glacier2/callback/expect.py b/java/demo/Glacier2/callback/expect.py deleted file mode 100755 index 7ebdb070d9a..00000000000 --- a/java/demo/Glacier2/callback/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 - -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 -from demoscript.Glacier2 import callback - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') - -glacier2 = Util.spawn('glacier2router --Ice.Config=config.glacier2 --Ice.PrintAdapterReady --Glacier2.SessionTimeout=5') -glacier2.expect('Glacier2.Client ready') -glacier2.expect('Glacier2.Server ready') - -client = Util.spawn('java -jar build/libs/client.jar') - -callback.run(client, server, glacier2) diff --git a/java/demo/Glacier2/chat/.externalToolBuilders/dmeo.Glacier2.chat.slice.launch b/java/demo/Glacier2/chat/.externalToolBuilders/dmeo.Glacier2.chat.slice.launch deleted file mode 100644 index 4aabaf82760..00000000000 --- a/java/demo/Glacier2/chat/.externalToolBuilders/dmeo.Glacier2.chat.slice.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="${project}"/> -<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.Glacier2.chat"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Glacier2.chat/Chat.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Glacier2.chat/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/Glacier2/chat/Chat.ice b/java/demo/Glacier2/chat/Chat.ice deleted file mode 100644 index 476b49e0dcf..00000000000 --- a/java/demo/Glacier2/chat/Chat.ice +++ /dev/null @@ -1,28 +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 - -#include <Glacier2/Session.ice> - -module Demo -{ - -interface ChatCallback -{ - void message(string data); -}; - -interface ChatSession extends Glacier2::Session -{ - void setCallback(ChatCallback* callback); - void say(string data); -}; - -}; diff --git a/java/demo/Glacier2/chat/Client.java b/java/demo/Glacier2/chat/Client.java deleted file mode 100644 index f61bf601984..00000000000 --- a/java/demo/Glacier2/chat/Client.java +++ /dev/null @@ -1,543 +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 java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridLayout; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -import javax.swing.BoxLayout; -import javax.swing.JDialog; -import javax.swing.AbstractAction; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPasswordField; -import javax.swing.JPopupMenu; -import javax.swing.JScrollBar; -import javax.swing.JScrollPane; -import javax.swing.JSeparator; -import javax.swing.JSplitPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.ScrollPaneConstants; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.WindowConstants; -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.DefaultEditorKit; -import javax.swing.text.Document; -import javax.swing.text.Element; - -import Glacier2.SessionFactoryHelper; -import Glacier2.SessionHelper; -import Glacier2.SessionCallback; -import Glacier2.SessionNotExistException; -import Ice.Current; -import Ice.LocalException; -import Ice.StringSeqHolder; -import Ice.Util; - -@SuppressWarnings("serial") -public class Client extends JFrame -{ - public static void - main(final String[] args) - { - SwingUtilities.invokeLater(new Runnable() - { - @Override - public void - run() - { - try - { - // - // Create and set up the window. - // - new Client(args); - } - catch(Ice.LocalException e) - { - JOptionPane.showMessageDialog(null, - e.toString(), - "Initialization failed", - JOptionPane.ERROR_MESSAGE); - } - } - }); - } - - Client(String[] args) - { - // Build the JTextArea that shows the chat conversation. - _output = new JTextArea(""); - _output.setLineWrap(true); - _output.setEditable(false); - - final JPopupMenu textMenu = new JPopupMenu(); - textMenu.add(new DefaultEditorKit.CopyAction()); - textMenu.pack(); - - _output.addMouseListener(new MouseAdapter() - { - @Override - public void - mousePressed(MouseEvent e) - { - if(e.isPopupTrigger()) - { - textMenu.show(_output, e.getX(), e.getY()); - } - } - }); - - // Build the JTextArea where the user writes input messages. - _input = new JTextArea(""); - _input.setLineWrap(true); - _input.setEditable(true); - _input.addKeyListener(new KeyListener() - { - @Override - public void - keyTyped(KeyEvent e) - { - if(e.getKeyChar() == KeyEvent.VK_ENTER) - { - Document doc = _input.getDocument(); - try - { - String msg = doc.getText(0, doc.getLength()).trim(); - if(msg.length() > 0) - { - _chat.begin_say(msg, new Demo.Callback_ChatSession_say() - { - @Override - public void - response() - { - } - - @Override - public void - exception(final LocalException ex) - { - appendMessage("<system-message> - " + ex); - } - }); - } - } - catch(BadLocationException e1) - { - } - - _input.setText(""); - } - } - - @Override - public void - keyPressed(KeyEvent e) - { - } - - @Override - public void - keyReleased(KeyEvent e) - { - } - }); - - _outputScroll = new JScrollPane(_output); - _outputScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - _outputScroll.setBorder(null); - - _outputScroll.setMinimumSize(new Dimension(100, 100)); - _outputScroll.setPreferredSize(new Dimension(100, 100)); - - JSplitPane verticalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - verticalSplit.setTopComponent(_outputScroll); - - JScrollPane conversationInputScroll = new JScrollPane(_input); - conversationInputScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - conversationInputScroll.setBorder(null); - - conversationInputScroll.setMinimumSize(new Dimension(100, 100)); - conversationInputScroll.setPreferredSize(new Dimension(100, 100)); - verticalSplit.setBottomComponent(conversationInputScroll); - - verticalSplit.setResizeWeight(0.9); - - _output.addComponentListener(new ComponentListener() - { - @Override - public void - componentResized(ComponentEvent e) - { - JScrollBar vertivalScrollbar = _outputScroll.getVerticalScrollBar(); - vertivalScrollbar.setValue(vertivalScrollbar.getMaximum()); - } - @Override - public void - componentHidden(ComponentEvent e) - { - } - - @Override - public void - componentMoved(ComponentEvent e) - { - } - - @Override - public void - componentShown(ComponentEvent e) - { - } - }); - - add(verticalSplit, BorderLayout.CENTER); - - JPanel statusPanel = new JPanel(); - JSeparator statusPanelSeparator = new JSeparator(); - _status = new JLabel(); - _status.setText("Not connected"); - - statusPanel.add(statusPanelSeparator, BorderLayout.NORTH); - statusPanel.add(_status, BorderLayout.SOUTH); - - add(statusPanel, BorderLayout.SOUTH); - - JMenuBar menuBar = new JMenuBar(); - JMenu connectMenu = new JMenu("Session"); - - _login = new AbstractAction("Login") - { - @Override - public void - actionPerformed(ActionEvent e) - { - login(); - } - }; - - _logout = new AbstractAction("Logout") - { - @Override - public void - actionPerformed(ActionEvent e) - { - setEnabled(false); - _status.setText("Logging out"); - destroySession(); - _chat = null; - } - }; - _logout.setEnabled(false); - - _exit = new AbstractAction("Exit") - { - @Override - public void - actionPerformed(ActionEvent e) - { - exit(); - } - }; - - connectMenu.add(_login); - connectMenu.add(_logout); - if(!System.getProperty("os.name").startsWith("Mac OS")) - { - connectMenu.add(_exit); - } - - menuBar.add(connectMenu); - - setJMenuBar(menuBar); - - setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); - - addWindowListener(new WindowAdapter() - { - @Override - public void - windowClosing(WindowEvent e) - { - exit(); - } - }); - - pack(); - setSize(640, 480); - locateOnScreen(this); - setVisible(true); - - // Create the labels and text fields. - JLabel hostLabel = new JLabel("Host: ", SwingConstants.RIGHT); - _hostField = new JTextField("", 12); - _hostField.setText("127.0.0.1"); - JLabel userNameLabel = new JLabel("Username: ", SwingConstants.RIGHT); - _userNameField = new JTextField("", 12); - _userNameField.setText("test"); - JLabel passwordLabel = new JLabel("Password: ", SwingConstants.RIGHT); - _passwordField = new JPasswordField("", 12); - _connectionPanel = new JPanel(false); - _connectionPanel.setLayout(new BoxLayout(_connectionPanel, BoxLayout.X_AXIS)); - - JPanel labelPanel = new JPanel(false); - labelPanel.setLayout(new GridLayout(0, 1)); - labelPanel.add(hostLabel); - labelPanel.add(userNameLabel); - labelPanel.add(passwordLabel); - JPanel fieldPanel = new JPanel(false); - fieldPanel.setLayout(new GridLayout(0, 1)); - fieldPanel.add(_hostField); - fieldPanel.add(_userNameField); - fieldPanel.add(_passwordField); - _connectionPanel.add(labelPanel); - _connectionPanel.add(fieldPanel); - - _input.setEnabled(false); - - Ice.InitializationData initData = new Ice.InitializationData(); - - // Load the configuration file. - initData.properties = Ice.Util.createProperties(); - initData.properties.load("config.client"); - StringSeqHolder argHolder = new StringSeqHolder(args); - initData.properties = Util.createProperties(argHolder, initData.properties); - - // Setup a dispatcher to dispath Ice and Glacier2 helper callbacks to the GUI thread. - initData.dispatcher = new Ice.Dispatcher() - { - @Override - public void - dispatch(Runnable runnable, Ice.Connection connection) - { - SwingUtilities.invokeLater(runnable); - } - }; - - _factory = new SessionFactoryHelper(initData, new SessionCallback() - { - @Override - public void - connected(SessionHelper session) - throws SessionNotExistException - { - // If the session has been reassigned avoid the spurious callback. - if(session != _session) - { - return; - } - - // The chat callback servant. We use an anonymous - // inner class since the implementation is very - // simple. - Demo._ChatCallbackDisp servant = new Demo._ChatCallbackDisp() - { - @Override - public void - message(final String data, Current current) - { - appendMessage(data); - } - }; - - Demo.ChatCallbackPrx callback = Demo.ChatCallbackPrxHelper.uncheckedCast(_session.addWithUUID(servant)); - - _chat = Demo.ChatSessionPrxHelper.uncheckedCast(_session.session()); - _chat.begin_setCallback(callback, new Demo.Callback_ChatSession_setCallback() - { - @Override - public void - response() - { - assert _loginDialog != null; - _loginDialog.dispose(); - - _login.setEnabled(false); - _logout.setEnabled(true); - - _input.setEnabled(true); - - _status.setText("Connected with " + _hostField.getText()); - } - - @Override - public void - exception(LocalException ex) - { - destroySession(); - } - }); - } - - @Override - public void - disconnected(SessionHelper session) - { - // If the session has been reassigned avoid the spurious callback. - if(session != _session) - { - return; - } - - if(_loginDialog != null) - { - _loginDialog.dispose(); - } - - _session = null; - _chat = null; - - _login.setEnabled(true); - _logout.setEnabled(false); - - _input.setEnabled(false); - _status.setText("Not connected"); - } - - @Override - public void - connectFailed(SessionHelper session, Throwable ex) - { - // If the session has been reassigned avoid the - // spurious callback. - if(session != _session) - { - return; - } - - if(_loginDialog != null) - { - _loginDialog.dispose(); - } - _status.setText(ex.getClass().getName()); - } - - @Override - public void - createdCommunicator(SessionHelper session) - { - } - }); - _factory.setRouterIdentity(new Ice.Identity("router", "DemoGlacier2")); - - login(); - } - - protected void - login() - { - String[] options = {"Login", "Cancel" }; - // Show Login Dialog. - int option = JOptionPane.showOptionDialog(this, _connectionPanel, "Login", JOptionPane.OK_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); - - if(option == 0) - { - _factory.setRouterHost(_hostField.getText()); - // Connect to Glacier2 using SessionFactoryHelper - _session = _factory.connect(_userNameField.getText(), _passwordField.getText()); - String[] cancel = { "Cancel" }; - - // Show Connecting Dialog - JOptionPane pane = new JOptionPane("Please wait while connecting...", JOptionPane.INFORMATION_MESSAGE, - JOptionPane.DEFAULT_OPTION, null, cancel, cancel[0]); - _loginDialog = pane.createDialog(this, "Connecting"); - _loginDialog.setVisible(true); - - // User pressed cancel. - if(pane.getValue() != JOptionPane.UNINITIALIZED_VALUE) - { - // Destroy session - destroySession(); - } - } - } - - private void - destroySession() - { - if(_session != null) - { - _session.destroy(); - //The session will be set to null on disconnected. - } - } - - private void - exit() - { - destroySession(); - dispose(); - Runtime.getRuntime().exit(0); - } - - public void - appendMessage(String message) - { - Document doc = _output.getDocument(); - Element e = doc.getDefaultRootElement(); - AttributeSet attr = e.getAttributes().copyAttributes(); - try - { - doc.insertString(doc.getLength(), message + "\n", attr); - } - catch(BadLocationException ex) - { - } - _output.setCaretPosition(doc.getLength()); - } - - private static void - locateOnScreen(Component component) - { - Dimension paneSize = component.getSize(); - Dimension screenSize = component.getToolkit().getScreenSize(); - component.setLocation((screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2); - } - - private JLabel _status; - private JTextArea _output; - private JTextArea _input; - private JScrollPane _outputScroll; - - // Login/Logout actions. - private AbstractAction _login; - private AbstractAction _logout; - private AbstractAction _exit; - - // Login dialog - private JDialog _loginDialog; - private JTextField _userNameField; - private JTextField _passwordField; - private JTextField _hostField; - private JPanel _connectionPanel; - - // The session factory and current session. - private SessionFactoryHelper _factory; - private SessionHelper _session; - private Demo.ChatSessionPrx _chat; -} diff --git a/java/demo/Glacier2/chat/README b/java/demo/Glacier2/chat/README deleted file mode 100644 index 436addd0a87..00000000000 --- a/java/demo/Glacier2/chat/README +++ /dev/null @@ -1,9 +0,0 @@ -This demo demonstrates the use of a Glacier2 session helpers and swing -to create a graphical client for the simple chat server. - -First follow the instructions in the C++ Glacier2 chat demo README -to start the server and the Glacier2 router. - -In a separate window, start the swing client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Glacier2/chat/config.client b/java/demo/Glacier2/chat/config.client deleted file mode 100644 index 586a39ca738..00000000000 --- a/java/demo/Glacier2/chat/config.client +++ /dev/null @@ -1,46 +0,0 @@ -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10003 -Ice.Admin.InstanceName=client -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/Glacier2/voip/.externalToolBuilders/demo.Glacier2.voip.slice.launch b/java/demo/Glacier2/voip/.externalToolBuilders/demo.Glacier2.voip.slice.launch deleted file mode 100644 index 4303666a7c8..00000000000 --- a/java/demo/Glacier2/voip/.externalToolBuilders/demo.Glacier2.voip.slice.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="${project}"/> -<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.Glacier2.voip"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Glacier2.voip/Voip.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Glacier2.voip/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/Glacier2/voip/README b/java/demo/Glacier2/voip/README deleted file mode 100644 index 9c916fd640e..00000000000 --- a/java/demo/Glacier2/voip/README +++ /dev/null @@ -1,27 +0,0 @@ -This demo contains the server side for the Ice Touch VOIP demo. - -A running instance of this server is also publicly available on -demo2.zeroc.com. - -====================================================================== -Running the VOIP server -====================================================================== - -Before running the server, review the server and Glacier2 router -configuration files, config.server and config.glacier2 respectively. - -To run the demo: - -Start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the Glacier2 router: - -$ glacier2router --Ice.Config=config.glacier2 - -====================================================================== -Running the VOIP client -====================================================================== - -The client for this demo is part of the Ice Touch distribution.
\ No newline at end of file diff --git a/java/demo/Glacier2/voip/Server.java b/java/demo/Glacier2/voip/Server.java deleted file mode 100644 index f5ed220bfcd..00000000000 --- a/java/demo/Glacier2/voip/Server.java +++ /dev/null @@ -1,173 +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 java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import Glacier2.CannotCreateSessionException; -import Glacier2.SessionControlPrx; -import Glacier2.SessionPrx; -import Glacier2._PermissionsVerifierDisp; -import Glacier2._SessionManagerDisp; -import Ice.Current; -import Ice.LocalException; -import Ice.NotRegisteredException; -import Ice.ObjectNotExistException; -import Ice.StringHolder; -import Voip.Callback_Control_incomingCall; -import Voip.ControlPrx; -import Voip.SessionPrxHelper; -import Voip._SessionDisp; - -public class Server extends Ice.Application -{ - private final ScheduledThreadPoolExecutor _executor = new ScheduledThreadPoolExecutor(1); - - class SessionI extends _SessionDisp - { - private ControlPrx _ctrl; - private long _timestamp = System.currentTimeMillis(); - - @Override - public void setControl(ControlPrx ctrl, Current current) - { - _ctrl = ctrl; - } - - @Override - public void simulateCall(int delay, Current current) - { - _executor.schedule(new Runnable() - { - @Override - public void run() - { - if(_ctrl != null) - { - System.out.println("calling incoming call"); - _ctrl.begin_incomingCall(new Callback_Control_incomingCall() - { - @Override - public void exception(LocalException ex) - { - System.out.println("incoming call failed"); - ex.printStackTrace(); - } - - @Override - public void response() - { - System.out.println("incoming call succeeded"); - } - }); - } - } - }, delay, TimeUnit.MILLISECONDS); - } - - @Override - public void destroy(Current current) - { - try - { - current.adapter.remove(current.id); - } - catch(NotRegisteredException ex) - { - // Ignore. - } - } - - @Override - public void refresh(Current current) - { - _timestamp = System.currentTimeMillis(); - } - - long getTimestamp() - { - return _timestamp; - } - } - - class PermissionsVerifierI extends _PermissionsVerifierDisp - { - @Override - public boolean checkPermissions(String userId, String password, StringHolder reason, Current current) - { - return true; - } - } - - class SessionManagerI extends _SessionManagerDisp - { - @Override - public SessionPrx create(String userId, SessionControlPrx control, - Current current) throws CannotCreateSessionException - { - // The configured timeout must be greater than 600. This is 601 * 2. - final long sessionTimeout = 1202; - final SessionI session = new SessionI(); - final Ice.Identity ident = new Ice.Identity(); - ident.name = java.util.UUID.randomUUID().toString(); - ident.category = "session"; - final SessionPrx proxy = SessionPrxHelper.uncheckedCast(current.adapter.add(session, ident)); - _executor.scheduleWithFixedDelay(new Runnable() - { - @Override - public void run() - { - // If the session has already been destroyed the ONE will - // fall out of run canceling the task. - if (System.currentTimeMillis() - session.getTimestamp() > (sessionTimeout * 1000L * 2)) - { - proxy.destroy(); - throw new ObjectNotExistException(); - } - } - }, sessionTimeout, sessionTimeout, TimeUnit.SECONDS); - - return proxy; - } - }; - - Server() - { - // We want the executor to shutdown even if there are scheduled tasks. - _executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); - } - - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("VoipServer"); - adapter.add(new PermissionsVerifierI(), communicator().stringToIdentity("VoipVerifier")); - adapter.add(new SessionManagerI(), communicator().stringToIdentity("VoipSessionManager")); - adapter.activate(); - communicator().waitForShutdown(); - _executor.shutdown(); - 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/Glacier2/voip/Voip.ice b/java/demo/Glacier2/voip/Voip.ice deleted file mode 100644 index 91d55439962..00000000000 --- a/java/demo/Glacier2/voip/Voip.ice +++ /dev/null @@ -1,31 +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 - -#include <Glacier2/Session.ice> - -module Voip -{ - -interface Control -{ - void incomingCall(); -}; - -interface Session extends Glacier2::Session -{ - void setControl(Control* ctrl); - - void simulateCall(int delay); - - void refresh(); -}; - -}; diff --git a/java/demo/Glacier2/voip/config.glacier2 b/java/demo/Glacier2/voip/config.glacier2 deleted file mode 100644 index 8b54835c769..00000000000 --- a/java/demo/Glacier2/voip/config.glacier2 +++ /dev/null @@ -1,63 +0,0 @@ -# -# Set the Glacier2 instance name. -# -Glacier2.InstanceName=Glacier2 - -# -# The client-visible endpoint of Glacier2. This should be an endpoint -# visible from the public Internet, and it should be secure. -# -Glacier2.Client.Endpoints=ssl -p 4064 -h localhost:tcp -p 4063 -h localhost - -# -# The server-visible endpoint of Glacier2. This endpoint is only -# required if callbacks are needed (leave empty otherwise). This -# should be an endpoint on an internal network (like 192.168.x.x), or -# on the loopback, so that the server is not directly accessible from -# the Internet. -# -Glacier2.Server.Endpoints=tcp -h localhost - -# -# The proxy of the session manager. -# -Glacier2.SessionManager=VoipSessionManager:tcp -h localhost -p 10001 - -# -# For this demo, we use a custom permissions verifier collocated with -# the session manager. -# -Glacier2.PermissionsVerifier=VoipVerifier:tcp -h localhost -p 10001 - -# -# The timeout for inactive sessions. If any client session is inactive -# for longer than this value, the session expires and is removed. The -# unit is seconds. -# -# The minimum keep alive timeout for background apps with iOS 4 is -# 601 seconds. Hence we use twice that. -# -Glacier2.SessionTimeout=1202 - -# -# Only allow access to back end "sesion" objects. -# -Glacier2.Filter.Category.Accept=session - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL:createIceSSL -IceSSL.VerifyPeer=0 -IceSSL.DefaultDir=../../../../certs -IceSSL.CertAuthFile=cacert.pem -IceSSL.CertFile=s_rsa1024.pfx -IceSSL.Password=password diff --git a/java/demo/Glacier2/voip/config.server b/java/demo/Glacier2/voip/config.server deleted file mode 100644 index 27a26e143c3..00000000000 --- a/java/demo/Glacier2/voip/config.server +++ /dev/null @@ -1,31 +0,0 @@ -# -# The endpoint of the session server's object adapter. This should be -# an endpoint on an internal network (like 192.168.x.x), or on the -# loopback, so that the session server is not directly accessible from -# the Internet. -# -VoipServer.Endpoints=tcp -h localhost -p 10001 - -# -# 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/README b/java/demo/Ice/README deleted file mode 100644 index 9c159d36823..00000000000 --- a/java/demo/Ice/README +++ /dev/null @@ -1,98 +0,0 @@ -Demos in this directory: - -- async - - This demo illustrates the use of Asynchronous Method Invocation - (AMI) and Asynchronous Method Dispatch (AMD). - -- bidir - - This demo shows how to use bidirectional connections for callbacks. - This is typically used if the server cannot open a connection to the - client to send callbacks, for example, because firewalls block - incoming connections to the client. - -- callback - - A simple callback demo that illustrates how a client can pass a - proxy to a server, invoke an operation in the server, and the server - call back into an object provided by the client as part of that - invocation. - -- context - - This demo shows how to use Ice request contexts. - -- hello - - This demo illustrates how to invoke ordinary (twoway) operations, as - well as how to invoke oneway operations, use datagrams, secure - invocations, and how to use batched invocations. - -- interrupt - - This demo shows how to use Thread.interrupt to interrupt blocking - client-side invocations, and forcibly shutdown servers. - -- invoke - - This demo illustrates the use of the Ice streaming API. - -- latency - - A simple latency test that measures the basic call dispatch delay of - Ice. - -- minimal - - This demo illustrates a minimal Ice application. - -- multicast - - This demo illustrates the use of UDP multicast. - -- nested - - A demo to illustrate how nested callbacks work, and how the size of - the thread pool affects the maximum nesting depth. - -- optional - - This demo shows the use of the optional keyword. - -- plugin - - A demo to illustrate how to write and use Ice plugins. - -- properties - - Shows how to access a server's PropertiesAdmin facet in order to - retrieve and modify its configuration properties, and how the server - can receive notifications whenever its properties are changed. - -- 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 - resources in a server after the client shuts down or crashes. - -- swing - - A swing application that shows how to use Asynchronous Method - Invocation (AMI) in a graphical client. - -- throughput - - A simple throughput demo that allows you to send sequences of - various types between client and server and to measure the maximum - bandwidth that can be achieved using serialized synchronous - requests. - -- value - - This demo shows how to use classes, class factories, and the - difference between local and remote invocations of class operations. diff --git a/java/demo/Ice/async/.externalToolBuilders/demo.Ice.async.launch b/java/demo/Ice/async/.externalToolBuilders/demo.Ice.async.launch deleted file mode 100644 index 310ba28b633..00000000000 --- a/java/demo/Ice/async/.externalToolBuilders/demo.Ice.async.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="${project}"/> -<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.Ice.async"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.async/Hello.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.async/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/Ice/async/Client.java b/java/demo/Ice/async/Client.java deleted file mode 100644 index 6c2938c2877..00000000000 --- a/java/demo/Ice/async/Client.java +++ /dev/null @@ -1,158 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - public class Callback_Hello_sayHelloI extends Callback_Hello_sayHello - { - @Override - public void response() - { - } - - @Override - public void exception(Ice.LocalException ex) - { - System.err.println("sayHello AMI call failed:"); - ex.printStackTrace(); - } - - @Override - public void exception(Ice.UserException ex) - { - if(ex instanceof Demo.RequestCanceledException) - { - System.out.println("Demo.RequestCanceledException"); - } - else - { - ex.printStackTrace(); - } - } - } - - private static void - menu() - { - System.out.println( - "usage:\n" + - "i: send immediate greeting\n" + - "d: send delayed greeting\n" + - "s: shutdown the server\n" + - "x: exit\n" + - "?: help\n"); - } - - @Override - 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; - } - - 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("i")) - { - hello.sayHello(0); - } - else if(line.equals("d")) - { - hello.begin_sayHello(5000, new Callback_Hello_sayHelloI()); - } - else if(line.equals("s")) - { - hello.shutdown(); - } - else if(line.equals("x")) - { - // Nothing to do - } - else - { - System.out.println("unknown command `" + line + "'"); - menu(); - } - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - } - catch(Ice.UserException 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/async/Hello.ice b/java/demo/Ice/async/Hello.ice deleted file mode 100644 index 2d9b0da0fdd..00000000000 --- a/java/demo/Ice/async/Hello.ice +++ /dev/null @@ -1,27 +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 Demo -{ - -exception RequestCanceledException -{ -}; - -interface Hello -{ - ["amd"] idempotent void sayHello(int delay) - throws RequestCanceledException; - - void shutdown(); -}; - -}; diff --git a/java/demo/Ice/async/HelloI.java b/java/demo/Ice/async/HelloI.java deleted file mode 100644 index 01713c61b8e..00000000000 --- a/java/demo/Ice/async/HelloI.java +++ /dev/null @@ -1,46 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - public - HelloI(WorkQueue workQueue) - { - _workQueue = workQueue; - } - - @Override - public void - sayHello_async(AMD_Hello_sayHello cb, int delay, Ice.Current current) - { - if(delay == 0) - { - System.out.println("Hello World!"); - cb.ice_response(); - } - else - { - _workQueue.add(cb, delay); - } - } - - @Override - public void - shutdown(Ice.Current current) - { - System.out.println("Shutting down..."); - - _workQueue._destroy(); - current.adapter.getCommunicator().shutdown(); - } - - private WorkQueue _workQueue; -} diff --git a/java/demo/Ice/async/README b/java/demo/Ice/async/README deleted file mode 100644 index 720e5020788..00000000000 --- a/java/demo/Ice/async/README +++ /dev/null @@ -1,17 +0,0 @@ -This demo illustrates the use of Asynchronous Message Invocation (AMI) -and Asynchronous Message Dispatch (AMD). - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a second window, start the client: - -$ java -jar build/libs/client.jar - -The demo invocation can either have a short response time or require a -significant amount of time to complete. For the long running request -the client uses AMI and the server uses AMD plus a worker thread to -process the request. While a long request is processing, short -requests are still able to be processed and more long requests can be -queued for processing by the worker thread. diff --git a/java/demo/Ice/async/Server.java b/java/demo/Ice/async/Server.java deleted file mode 100644 index d20144b1174..00000000000 --- a/java/demo/Ice/async/Server.java +++ /dev/null @@ -1,65 +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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - _workQueue._destroy(); - communicator().shutdown(); - } - } - - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - setInterruptHook(new ShutdownHook()); - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); - _workQueue = new WorkQueue(); - adapter.add(new HelloI(_workQueue), communicator().stringToIdentity("hello")); - _workQueue.start(); - adapter.activate(); - - communicator().waitForShutdown(); - - try - { - _workQueue.join(); - } - catch(java.lang.InterruptedException ex) - { - } - - return 0; - } - - public static void - main(String[] args) - { - Server app = new Server(); - int status = app.main("Server", args, "config.server"); - System.exit(status); - } - - private WorkQueue _workQueue; -} diff --git a/java/demo/Ice/async/WorkQueue.java b/java/demo/Ice/async/WorkQueue.java deleted file mode 100644 index 712c0eab29d..00000000000 --- a/java/demo/Ice/async/WorkQueue.java +++ /dev/null @@ -1,114 +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 Demo.*; - -public class WorkQueue extends Thread -{ - class CallbackEntry - { - AMD_Hello_sayHello cb; - int delay; - } - - @Override - public synchronized void - run() - { - while(!_done) - { - if(_callbacks.size() == 0) - { - try - { - wait(); - } - catch(java.lang.InterruptedException ex) - { - } - } - - if(_callbacks.size() != 0) - { - // - // Get next work item. - // - CallbackEntry entry = _callbacks.getFirst(); - - // - // Wait for the amount of time indicated in delay to - // emulate a process that takes a significant period of - // time to complete. - // - try - { - wait(entry.delay); - } - catch(java.lang.InterruptedException ex) - { - } - - if(!_done) - { - // - // Print greeting and send response. - // - _callbacks.removeFirst(); - System.err.println("Belated Hello World!"); - entry.cb.ice_response(); - } - } - } - - // - // Throw exception for any outstanding requests. - // - for(CallbackEntry p : _callbacks) - { - p.cb.ice_exception(new RequestCanceledException()); - } - } - - public synchronized void - add(AMD_Hello_sayHello cb, int delay) - { - if(!_done) - { - // - // Add the work item. - // - CallbackEntry entry = new CallbackEntry(); - entry.cb = cb; - entry.delay = delay; - - if(_callbacks.size() == 0) - { - notify(); - } - _callbacks.add(entry); - } - else - { - // - // Destroyed, throw exception. - // - cb.ice_exception(new RequestCanceledException()); - } - } - - public synchronized void - _destroy() // Thread.destroy is deprecated. - { - _done = true; - notify(); - } - - private java.util.LinkedList<CallbackEntry> _callbacks = new java.util.LinkedList<CallbackEntry>(); - private boolean _done = false; -} diff --git a/java/demo/Ice/async/config.client b/java/demo/Ice/async/config.client deleted file mode 100644 index 39639f01c51..00000000000 --- a/java/demo/Ice/async/config.client +++ /dev/null @@ -1,28 +0,0 @@ -# -# The client reads this property to create the reference to the -# "hello" object in the server. -# -Hello.Proxy=hello:tcp -h localhost -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/async/config.server b/java/demo/Ice/async/config.server deleted file mode 100644 index 21c50e72b22..00000000000 --- a/java/demo/Ice/async/config.server +++ /dev/null @@ -1,29 +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 -h localhost -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/async/expect.py b/java/demo/Ice/async/expect.py deleted file mode 100755 index 6a20417ce9e..00000000000 --- a/java/demo/Ice/async/expect.py +++ /dev/null @@ -1,30 +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 - -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 -from demoscript.Ice import async - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar') -client.expect('.*==>') - -async.run(client, server) diff --git a/java/demo/Ice/bidir/.externalToolBuilders/demo.Ice.bidir.launch b/java/demo/Ice/bidir/.externalToolBuilders/demo.Ice.bidir.launch deleted file mode 100644 index 8a509439904..00000000000 --- a/java/demo/Ice/bidir/.externalToolBuilders/demo.Ice.bidir.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="${project}"/> -<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.Ice.bidir"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.bidir/Callback.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.bidir/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/Ice/bidir/Callback.ice b/java/demo/Ice/bidir/Callback.ice deleted file mode 100644 index f76b118e574..00000000000 --- a/java/demo/Ice/bidir/Callback.ice +++ /dev/null @@ -1,27 +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 - -#include <Ice/Identity.ice> - -module Demo -{ - -interface CallbackReceiver -{ - void callback(int num); -}; - -interface CallbackSender -{ - void addClient(Ice::Identity ident); -}; - -}; diff --git a/java/demo/Ice/bidir/CallbackReceiverI.java b/java/demo/Ice/bidir/CallbackReceiverI.java deleted file mode 100644 index 967ac14896e..00000000000 --- a/java/demo/Ice/bidir/CallbackReceiverI.java +++ /dev/null @@ -1,24 +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 Demo.*; - -class CallbackReceiverI extends _CallbackReceiverDisp -{ - CallbackReceiverI() - { - } - - @Override - public void - callback(int num, Ice.Current current) - { - System.out.println("received callback #" + num); - } -} diff --git a/java/demo/Ice/bidir/CallbackSenderI.java b/java/demo/Ice/bidir/CallbackSenderI.java deleted file mode 100644 index 6758c72ddc2..00000000000 --- a/java/demo/Ice/bidir/CallbackSenderI.java +++ /dev/null @@ -1,94 +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 Demo.*; - -class CallbackSenderI extends _CallbackSenderDisp implements java.lang.Runnable -{ - CallbackSenderI(Ice.Communicator communicator) - { - _communicator = communicator; - } - - synchronized public void - destroy() - { - System.out.println("destroying callback sender"); - _destroy = true; - - this.notify(); - } - - @Override - synchronized public void - addClient(Ice.Identity ident, Ice.Current current) - { - System.out.println("adding client `" + _communicator.identityToString(ident) + "'"); - - Ice.ObjectPrx base = current.con.createProxy(ident); - CallbackReceiverPrx client = CallbackReceiverPrxHelper.uncheckedCast(base); - _clients.add(client); - } - - @Override - public void - run() - { - int num = 0; - while(true) - { - java.util.List<CallbackReceiverPrx> clients; - synchronized(this) - { - try - { - this.wait(2000); - } - catch(java.lang.InterruptedException ex) - { - } - - if(_destroy) - { - break; - } - - clients = new java.util.ArrayList<CallbackReceiverPrx>(_clients); - } - - if(!clients.isEmpty()) - { - ++num; - - for(CallbackReceiverPrx p : clients) - { - try - { - p.callback(num); - } - catch(Exception ex) - { - System.out.println("removing client `" + _communicator.identityToString(p.ice_getIdentity()) + - "':"); - ex.printStackTrace(); - - synchronized(this) - { - _clients.remove(p); - } - } - } - } - } - } - - private Ice.Communicator _communicator; - private boolean _destroy = false; - private java.util.List<CallbackReceiverPrx> _clients = new java.util.ArrayList<CallbackReceiverPrx>(); -} diff --git a/java/demo/Ice/bidir/Client.java b/java/demo/Ice/bidir/Client.java deleted file mode 100644 index dc46865c953..00000000000 --- a/java/demo/Ice/bidir/Client.java +++ /dev/null @@ -1,52 +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 Demo.*; - -public class Client extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - CallbackSenderPrx server = CallbackSenderPrxHelper.checkedCast( - communicator().propertyToProxy("CallbackSender.Proxy")); - if(server == null) - { - System.err.println("invalid proxy"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter(""); - Ice.Identity ident = new Ice.Identity(); - ident.name = java.util.UUID.randomUUID().toString(); - ident.category = ""; - adapter.add(new CallbackReceiverI(), ident); - adapter.activate(); - server.ice_getConnection().setAdapter(adapter); - server.addClient(ident); - communicator().waitForShutdown(); - - 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/bidir/README b/java/demo/Ice/bidir/README deleted file mode 100644 index fa6d6a3183f..00000000000 --- a/java/demo/Ice/bidir/README +++ /dev/null @@ -1,12 +0,0 @@ -This demo shows how to use bidirectional connections for callbacks. -This is typically used if the server cannot open a connection to the -client to send callbacks, for example, because firewalls block -incoming connections to the client. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/bidir/Server.java b/java/demo/Ice/bidir/Server.java deleted file mode 100644 index 09a92aafb17..00000000000 --- a/java/demo/Ice/bidir/Server.java +++ /dev/null @@ -1,58 +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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Callback.Server"); - CallbackSenderI sender = new CallbackSenderI(communicator()); - adapter.add(sender, communicator().stringToIdentity("sender")); - adapter.activate(); - - Thread t = new Thread(sender); - t.start(); - - try - { - communicator().waitForShutdown(); - } - finally - { - sender.destroy(); - try - { - t.join(); - } - catch(java.lang.InterruptedException ex) - { - } - } - - 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/bidir/config.client b/java/demo/Ice/bidir/config.client deleted file mode 100644 index ac4ffad5a9a..00000000000 --- a/java/demo/Ice/bidir/config.client +++ /dev/null @@ -1,33 +0,0 @@ -# -# The client reads this property to create the reference to the -# "CallbackSender" object in the server. -# -CallbackSender.Proxy=sender:tcp -h localhost -p 10000 - -# -# Uncomment to use the WebSocket transport instead. -# -#CallbackSender.Proxy=sender:ws -h localhost -p 10002 - -# -# 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/bidir/config.server b/java/demo/Ice/bidir/config.server deleted file mode 100644 index 0da6951449d..00000000000 --- a/java/demo/Ice/bidir/config.server +++ /dev/null @@ -1,29 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Callback.Server". The following line sets the endpoints for this -# adapter. -# -Callback.Server.Endpoints=tcp -h localhost -p 10000:ws -h localhost -p 10002 - -# -# 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/bidir/expect.py b/java/demo/Ice/bidir/expect.py deleted file mode 100755 index 1ba44c81474..00000000000 --- a/java/demo/Ice/bidir/expect.py +++ /dev/null @@ -1,28 +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 - -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 -from demoscript.Ice import bidir - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') - -bidir.run('java -jar build/libs/client.jar', server) diff --git a/java/demo/Ice/build.gradle b/java/demo/Ice/build.gradle deleted file mode 100644 index 5dec4069121..00000000000 --- a/java/demo/Ice/build.gradle +++ /dev/null @@ -1,46 +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. -// -// ********************************************************************** - -['async', 'bidir', 'callback', 'hello', 'invoke', - 'interrupt', 'latency', 'minimal', 'multicast', 'nested', - 'plugin', 'properties', 'serialize','session', - 'throughput', 'value', 'optional','context'].each { - def name = it - project(":demoIce${it.capitalize()}") { - slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } - } - - sourceSets { - main { - java { - srcDir '.' - } - } - } - - dependencies { - compile localDependency("ice") - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } - } - - // Don't create the default jar. - jar.enabled = false - - demoJar("client") - demoJar("server") - } -} - -project(":demoIceInvoke").slice.java.default.args += " --stream" diff --git a/java/demo/Ice/callback/.externalToolBuilders/demo.Ice.callback.launch b/java/demo/Ice/callback/.externalToolBuilders/demo.Ice.callback.launch deleted file mode 100644 index f90461243c9..00000000000 --- a/java/demo/Ice/callback/.externalToolBuilders/demo.Ice.callback.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="${project}"/> -<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.Ice.callback"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.callback/Callback.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.callback/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/Ice/callback/Callback.ice b/java/demo/Ice/callback/Callback.ice deleted file mode 100644 index 53613303755..00000000000 --- a/java/demo/Ice/callback/Callback.ice +++ /dev/null @@ -1,26 +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 Demo -{ - -interface CallbackReceiver -{ - void callback(); -}; - -interface CallbackSender -{ - void initiateCallback(CallbackReceiver* proxy); - void shutdown(); -}; - -}; diff --git a/java/demo/Ice/callback/CallbackReceiverI.java b/java/demo/Ice/callback/CallbackReceiverI.java deleted file mode 100644 index a9e53aa0e32..00000000000 --- a/java/demo/Ice/callback/CallbackReceiverI.java +++ /dev/null @@ -1,20 +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 Demo.*; - -public final class CallbackReceiverI extends _CallbackReceiverDisp -{ - @Override - public void - callback(Ice.Current current) - { - System.out.println("received callback"); - } -} diff --git a/java/demo/Ice/callback/CallbackSenderI.java b/java/demo/Ice/callback/CallbackSenderI.java deleted file mode 100644 index 8723e8d892e..00000000000 --- a/java/demo/Ice/callback/CallbackSenderI.java +++ /dev/null @@ -1,43 +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 Demo.*; - -public final class CallbackSenderI extends _CallbackSenderDisp -{ - @Override - public void - initiateCallback(CallbackReceiverPrx proxy, Ice.Current current) - { - System.out.println("initiating callback"); - try - { - proxy.callback(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - - @Override - public void - shutdown(Ice.Current current) - { - System.out.println("Shutting down..."); - try - { - current.adapter.getCommunicator().shutdown(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } -} diff --git a/java/demo/Ice/callback/Client.java b/java/demo/Ice/callback/Client.java deleted file mode 100644 index abb066d35b0..00000000000 --- a/java/demo/Ice/callback/Client.java +++ /dev/null @@ -1,135 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private static void - menu() - { - System.out.println( - "usage:\n" + - "t: send callback\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); - } - - @Override - 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()); - - CallbackSenderPrx sender = CallbackSenderPrxHelper.checkedCast( - communicator().propertyToProxy("CallbackSender.Proxy"). - ice_twoway().ice_timeout(-1).ice_secure(false)); - if(sender == null) - { - System.err.println("invalid proxy"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Callback.Client"); - adapter.add(new CallbackReceiverI(), communicator().stringToIdentity("callbackReceiver")); - adapter.activate(); - - CallbackReceiverPrx receiver = - CallbackReceiverPrxHelper.uncheckedCast(adapter.createProxy( - communicator().stringToIdentity("callbackReceiver"))); - - 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")) - { - sender.initiateCallback(receiver); - } - else if(line.equals("s")) - { - sender.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/callback/README b/java/demo/Ice/callback/README deleted file mode 100644 index 732cd2a669d..00000000000 --- a/java/demo/Ice/callback/README +++ /dev/null @@ -1,11 +0,0 @@ -A simple callback demo that illustrates how a client can pass a proxy -to a server, invoke an operation in the server, and the server call -back into an object provided by the client as part of that invocation. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/callback/Server.java b/java/demo/Ice/callback/Server.java deleted file mode 100644 index 1ed33663ca3..00000000000 --- a/java/demo/Ice/callback/Server.java +++ /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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Callback.Server"); - adapter.add(new CallbackSenderI(), communicator().stringToIdentity("callbackSender")); - 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/callback/config.client b/java/demo/Ice/callback/config.client deleted file mode 100644 index 482a50fcf94..00000000000 --- a/java/demo/Ice/callback/config.client +++ /dev/null @@ -1,51 +0,0 @@ -# -# The client reads this property to create the reference to the -# "CallbackSender" object in the server. -# -CallbackSender.Proxy=callbackSender:default -h localhost -p 10000 - -# -# The client creates one single object adapter with the name -# "Callback.Client". The following line sets the endpoints for this -# adapter. -# -Callback.Client.Endpoints=default - -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password diff --git a/java/demo/Ice/callback/config.server b/java/demo/Ice/callback/config.server deleted file mode 100644 index b690d852654..00000000000 --- a/java/demo/Ice/callback/config.server +++ /dev/null @@ -1,45 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Callback.Server". The following line sets the endpoints for this -# adapter. -# -Callback.Server.Endpoints=default -h localhost -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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password diff --git a/java/demo/Ice/callback/expect.py b/java/demo/Ice/callback/expect.py deleted file mode 100755 index a795cada81f..00000000000 --- a/java/demo/Ice/callback/expect.py +++ /dev/null @@ -1,30 +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 - -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 -from demoscript.Ice import callback - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar') -client.expect('.*==>') - -callback.run(client, server) diff --git a/java/demo/Ice/context/.externalToolBuilders/demo.Ice.context.slice.launch b/java/demo/Ice/context/.externalToolBuilders/demo.Ice.context.slice.launch deleted file mode 100644 index e6169ecacdc..00000000000 --- a/java/demo/Ice/context/.externalToolBuilders/demo.Ice.context.slice.launch +++ /dev/null @@ -1,15 +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_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="${project}"/> -<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.Ice.context"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.context/Context.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.context/build.xml}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/> -<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> -</launchConfiguration> diff --git a/java/demo/Ice/context/Client.java b/java/demo/Ice/context/Client.java deleted file mode 100644 index ab2fac89300..00000000000 --- a/java/demo/Ice/context/Client.java +++ /dev/null @@ -1,151 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private static void - menu() - { - System.out.println( - "usage:\n" + - "1: call with no request context\n" + - "2: call with explicit request context\n" + - "3: call with per-proxy request context\n" + - "4: call with implicit request context\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); - } - - @Override - 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()); - - ContextPrx proxy = ContextPrxHelper.checkedCast(communicator().propertyToProxy("Context.Proxy")); - if(proxy == null) - { - System.err.println("invalid proxy"); - return 1; - } - - 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("1")) - { - proxy.call(); - } - else if(line.equals("2")) - { - java.util.Map<String, String> ctx = new java.util.HashMap<String, String>(); - ctx.put("type", "Explicit"); - proxy.call(ctx); - } - else if(line.equals("3")) - { - java.util.Map<String, String> ctx = new java.util.HashMap<String, String>(); - ctx.put("type", "Per-Proxy"); - ContextPrx proxy2 = ContextPrxHelper.uncheckedCast(proxy.ice_context(ctx)); - proxy2.call(); - } - else if(line.equals("4")) - { - Ice.ImplicitContext ic = communicator().getImplicitContext(); - java.util.Map<String, String> ctx = new java.util.HashMap<String, String>(); - ctx.put("type", "Implicit"); - ic.setContext(ctx); - proxy.call(); - ic.setContext(new java.util.HashMap<String, String>()); - } - else if(line.equals("s")) - { - proxy.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/context/Context.ice b/java/demo/Ice/context/Context.ice deleted file mode 100644 index f3e621f3a00..00000000000 --- a/java/demo/Ice/context/Context.ice +++ /dev/null @@ -1,22 +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 Demo -{ - -interface Context -{ - idempotent void call(); - void shutdown(); -}; - -}; - diff --git a/java/demo/Ice/context/ContextI.java b/java/demo/Ice/context/ContextI.java deleted file mode 100644 index 5830c20879f..00000000000 --- a/java/demo/Ice/context/ContextI.java +++ /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. -// -// ********************************************************************** - -import Demo.*; - -public class ContextI extends _ContextDisp -{ - @Override - public void - call(Ice.Current current) - { - System.out.print("Type = "); - String type = current.ctx.get("type"); - if(type != null) - { - System.out.print(type); - } - else - { - System.out.print("None"); - } - System.out.println(); - } - - @Override - public void - shutdown(Ice.Current current) - { - System.out.println("Shutting down..."); - current.adapter.getCommunicator().shutdown(); - } -} diff --git a/java/demo/Ice/context/README b/java/demo/Ice/context/README deleted file mode 100644 index 52062db235d..00000000000 --- a/java/demo/Ice/context/README +++ /dev/null @@ -1,9 +0,0 @@ -This demo illustrates how to use Ice request contexts. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/context/Server.java b/java/demo/Ice/context/Server.java deleted file mode 100644 index 09e5c04f42a..00000000000 --- a/java/demo/Ice/context/Server.java +++ /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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Context"); - adapter.add(new ContextI(), communicator().stringToIdentity("context")); - 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/context/config.client b/java/demo/Ice/context/config.client deleted file mode 100644 index 4d5b7e097cc..00000000000 --- a/java/demo/Ice/context/config.client +++ /dev/null @@ -1,49 +0,0 @@ -# -# The client reads this property to create the reference to the -# "context" object in the server. -# -Context.Proxy=context:default -p 10000 - -# -# Enable implicit context on the communicator -# -Ice.ImplicitContext=Shared - -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password diff --git a/java/demo/Ice/context/config.server b/java/demo/Ice/context/config.server deleted file mode 100644 index 1cfbb2052da..00000000000 --- a/java/demo/Ice/context/config.server +++ /dev/null @@ -1,46 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Context". The following line sets the endpoints for this -# adapter. -# -Context.Endpoints=default -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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password -#IceSSL.VerifyPeer=0 diff --git a/java/demo/Ice/context/expect.py b/java/demo/Ice/context/expect.py deleted file mode 100755 index ef1f0313c2a..00000000000 --- a/java/demo/Ice/context/expect.py +++ /dev/null @@ -1,30 +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 - -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 -from demoscript.Ice import context - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar --Ice.Warn.Connections=0') -client.expect('.*==>') - -context.run(client, server) diff --git a/java/demo/Ice/hello/Client.java b/java/demo/Ice/hello/Client.java deleted file mode 100644 index 5a728fc79da..00000000000 --- a/java/demo/Ice/hello/Client.java +++ /dev/null @@ -1,240 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private static void - menu() - { - System.out.println( - "usage:\n" + - "t: send greeting as twoway\n" + - "o: send greeting as oneway\n" + - "O: send greeting as batch oneway\n" + - "d: send greeting as datagram\n" + - "D: send greeting as batch datagram\n" + - "f: flush all batch requests\n" + - "T: set a timeout\n" + - "P: set a server delay\n" + - "S: switch secure mode on/off\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); - } - - @Override - 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 twoway = HelloPrxHelper.checkedCast( - communicator().propertyToProxy("Hello.Proxy").ice_twoway().ice_secure(false)); - if(twoway == null) - { - System.err.println("invalid proxy"); - return 1; - } - HelloPrx oneway = (HelloPrx)twoway.ice_oneway(); - HelloPrx batchOneway = (HelloPrx)twoway.ice_batchOneway(); - HelloPrx datagram = (HelloPrx)twoway.ice_datagram(); - HelloPrx batchDatagram = (HelloPrx)twoway.ice_batchDatagram(); - - boolean secure = false; - int timeout = -1; - int delay = 0; - - 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")) - { - twoway.sayHello(delay); - } - else if(line.equals("o")) - { - oneway.sayHello(delay); - } - else if(line.equals("O")) - { - batchOneway.sayHello(delay); - } - else if(line.equals("d")) - { - if(secure) - { - System.out.println("secure datagrams are not supported"); - } - else - { - datagram.sayHello(delay); - } - } - else if(line.equals("D")) - { - if(secure) - { - System.out.println("secure datagrams are not supported"); - } - else - { - batchDatagram.sayHello(delay); - } - } - else if(line.equals("f")) - { - batchOneway.ice_flushBatchRequests(); - batchDatagram.ice_flushBatchRequests(); - } - else if(line.equals("T")) - { - if(timeout == -1) - { - timeout = 2000; - } - else - { - timeout = -1; - } - - twoway = (HelloPrx)twoway.ice_invocationTimeout(timeout); - oneway = (HelloPrx)oneway.ice_invocationTimeout(timeout); - batchOneway = (HelloPrx)batchOneway.ice_invocationTimeout(timeout); - - if(timeout == -1) - { - System.out.println("timeout is now switched off"); - } - else - { - System.out.println("timeout is now set to 2000ms"); - } - } - else if(line.equals("P")) - { - if(delay == 0) - { - delay = 2500; - } - else - { - delay = 0; - } - - if(delay == 0) - { - System.out.println("server delay is now deactivated"); - } - else - { - System.out.println("server delay is now set to 2500ms"); - } - } - else if(line.equals("S")) - { - secure = !secure; - - twoway = (HelloPrx)twoway.ice_secure(secure); - oneway = (HelloPrx)oneway.ice_secure(secure); - batchOneway = (HelloPrx)batchOneway.ice_secure(secure); - datagram = (HelloPrx)datagram.ice_secure(secure); - batchDatagram = (HelloPrx)batchDatagram.ice_secure(secure); - - if(secure) - { - System.out.println("secure mode is now on"); - } - else - { - System.out.println("secure mode is now off"); - } - } - else if(line.equals("s")) - { - twoway.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/hello/Hello.ice b/java/demo/Ice/hello/Hello.ice deleted file mode 100644 index e33b79c0798..00000000000 --- a/java/demo/Ice/hello/Hello.ice +++ /dev/null @@ -1,21 +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 Demo -{ - -interface Hello -{ - idempotent void sayHello(int delay); - void shutdown(); -}; - -}; diff --git a/java/demo/Ice/hello/HelloI.java b/java/demo/Ice/hello/HelloI.java deleted file mode 100644 index c5afa79d2bc..00000000000 --- a/java/demo/Ice/hello/HelloI.java +++ /dev/null @@ -1,39 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - @Override - public void - sayHello(int delay, Ice.Current current) - { - if(delay > 0) - { - try - { - Thread.currentThread(); - Thread.sleep(delay); - } - catch(InterruptedException ex1) - { - } - } - System.out.println("Hello World!"); - } - - @Override - public void - shutdown(Ice.Current current) - { - System.out.println("Shutting down..."); - current.adapter.getCommunicator().shutdown(); - } -} diff --git a/java/demo/Ice/hello/README b/java/demo/Ice/hello/README deleted file mode 100644 index 77ff44c520d..00000000000 --- a/java/demo/Ice/hello/README +++ /dev/null @@ -1,18 +0,0 @@ -This demo illustrates how to invoke ordinary (twoway) operations, as -well as how to make oneway, datagram, secure, and batched invocations. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar - -To test timeouts you can use 'T' to set a timeout on the client proxy -and 'P' to set a delayed response in the server to cause a timeout. -You will notice that two "Hello World!" messages will be printed by -the server in this case. This is because the sayHello method is marked -as idempotent in the slice, meaning that Ice does not need to follow -the at-most-once retry semantics. See the manual for more information -about retry behavior. diff --git a/java/demo/Ice/hello/Server.java b/java/demo/Ice/hello/Server.java deleted file mode 100644 index 543ae76612e..00000000000 --- a/java/demo/Ice/hello/Server.java +++ /dev/null @@ -1,36 +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. -// -// ********************************************************************** - -public class Server extends Ice.Application -{ - @Override - 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/hello/config.client b/java/demo/Ice/hello/config.client deleted file mode 100644 index b9d8f7ba7fb..00000000000 --- a/java/demo/Ice/hello/config.client +++ /dev/null @@ -1,62 +0,0 @@ -# -# The client reads this property to create the reference to the -# "hello" object in the server. -# -Hello.Proxy=hello:tcp -p 10000:udp -p 10000:ssl -p 10001 - -# -# Uncomment to use the WebSocket transports instead. -# -#Hello.Proxy=hello:ws -p 10002:udp -p 10000:wss -p 10003 - -# -# Only connect to the localhost interface by default. -# -Ice.Default.Host=localhost - -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10003 -Ice.Admin.InstanceName=client -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/Ice/hello/config.server b/java/demo/Ice/hello/config.server deleted file mode 100644 index 3fc8014f162..00000000000 --- a/java/demo/Ice/hello/config.server +++ /dev/null @@ -1,65 +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:udp -p 10000:ssl -p 10001:ws -p 10002:wss -p 10003 - -# -# Only listen on the localhost interface by default. -# -Ice.Default.Host=localhost - -# -# For secure WebSocket (WSS) clients and Windows Store App clients, -# you should disable this property. JavaScript browser clients and -# Windows Store App clients don't use client-side authentication. -# -#IceSSL.VerifyPeer=0 - -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10002 -Ice.Admin.InstanceName=server -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/Ice/hello/expect.py b/java/demo/Ice/hello/expect.py deleted file mode 100755 index 34c9859568e..00000000000 --- a/java/demo/Ice/hello/expect.py +++ /dev/null @@ -1,30 +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 - -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 -from demoscript.Ice import hello - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar --Ice.Warn.Connections=0') -client.expect('.*==>') - -hello.run(client, server) diff --git a/java/demo/Ice/interrupt/.externalToolBuilders/demo.Ice.interrupt.slice.launch b/java/demo/Ice/interrupt/.externalToolBuilders/demo.Ice.interrupt.slice.launch deleted file mode 100644 index f46189ef4a2..00000000000 --- a/java/demo/Ice/interrupt/.externalToolBuilders/demo.Ice.interrupt.slice.launch +++ /dev/null @@ -1,15 +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_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="${project}"/> -<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.Ice.interrupt"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.interrupt/TaskManager.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.interrupt/build.xml}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/> -<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> -</launchConfiguration> diff --git a/java/demo/Ice/interrupt/Client.java b/java/demo/Ice/interrupt/Client.java deleted file mode 100644 index 28c49d1f68c..00000000000 --- a/java/demo/Ice/interrupt/Client.java +++ /dev/null @@ -1,199 +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 java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import Demo.*; -import Ice.LocalException; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private static void - menu() - { - System.out.println( - "usage:\n" + - "t: start a task\n" + - "b: start a blocking task\n" + - "i: interrupt the blocking task\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); - } - - @Override - 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()); - - final TaskManagerPrx taskManager = TaskManagerPrxHelper.checkedCast(communicator().propertyToProxy("TaskManager.Proxy")); - if(taskManager == null) - { - System.err.println("invalid proxy"); - return 1; - } - - menu(); - - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - ExecutorService executor = Executors.newFixedThreadPool(5); - List<Future<?> > futures = new ArrayList<Future<?> >(); - int nextId = 0; - String line = null; - do - { - try - { - System.out.print("==> "); - System.out.flush(); - line = in.readLine(); - if(line == null) - { - break; - } - if(line.equals("t")) - { - final int id = nextId++; - taskManager.begin_run(id, new Callback_TaskManager_run() - { - @Override - public void response() - { - System.out.println("task " + id + " completed running"); - } - - @Override - public void exception(LocalException ex) - { - System.out.println("blocking task " + id + " failed"); - ex.printStackTrace(); - } - }); - } - else if(line.equals("b")) - { - // - // Remove any completed tasks. - // - Iterator<Future<?> > iterator = futures.iterator(); - while(iterator.hasNext()) { - Future<?> f = iterator.next(); - if(f.isDone()) { - iterator.remove(); - } - } - - final int id = nextId++; - Future<?> future = executor.submit(new Runnable() { - @Override - public void - run() - { - try - { - taskManager.run(id); - System.out.println("task " + id + " completed running"); - } - catch(Ice.OperationInterruptedException e) - { - System.out.println("blocking task " + id + " interrupted"); - } - catch(Ice.Exception e) - { - System.out.println("blocking task " + id + " failed"); - e.printStackTrace(); - } - } - }); - futures.add(future); - } - else if(line.equals("i")) - { - for(Future<?> f : futures) - { - f.cancel(true); - } - futures.clear(); - } - else if(line.equals("s")) - { - taskManager.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/interrupt/README b/java/demo/Ice/interrupt/README deleted file mode 100644 index bdc4015713f..00000000000 --- a/java/demo/Ice/interrupt/README +++ /dev/null @@ -1,37 +0,0 @@ -This demo illustrates how to interrupt blocking servant dispatches on -the server and interrupt blocking proxy invocations on the client by -using Thread.interrupt(). - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar - -Calling TaskManager::run on the server simulates a long running task -by sleeping 10 seconds. Ordinarily a server will not shutdown until -all executing dispatched requests are complete. By interrupting -dispatch threads using Thread.interrupt() a server shutdown will -proceed, as long as the servant implementation correctly handles the -interrupt. - -The simplest way to interrupt dispatch threads is by using an -Ice.Dispatcher and ExecutorService. Calling shutdownNow on the -ExecutorService interrupts any executing tasks. - -Pressing ^C in the server calls shutdownNow on the executor service, -as does pressing 's' in the client which calls TaskManager::shutdown, -the implementation of which itself calls shutdownNow. - -It is also possible to interrupt blocking invocations on an Ice proxy -by calling Thread.interrupt(). - -In this demo, to interrupt a blocking proxy invocation on the client -press 'b' to run the invocation and 'i' to interrupt the invocation. -Only a single blocking invocation can be active at once. - -Pressing 't' in the client runs the task on the server using a -non-blocking AMI invocation. - diff --git a/java/demo/Ice/interrupt/Server.java b/java/demo/Ice/interrupt/Server.java deleted file mode 100644 index 9377defd4e3..00000000000 --- a/java/demo/Ice/interrupt/Server.java +++ /dev/null @@ -1,91 +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 java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - // - // If ^C is pressed we want to interrupt all running upcalls from the - // dispatcher and destroy the communicator. - // - setInterruptHook(new Thread() { - @Override - public void - run() - { - // - // Call shutdownNow on the executor. This interrupts all - // executor threads causing any running servant dispatch threads - // to terminate quickly. - // - _executor.shutdownNow(); - try - { - communicator().shutdown(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - }); - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TaskManager"); - adapter.add(new TaskManagerI(_executor), communicator().stringToIdentity("manager")); - adapter.activate(); - communicator().waitForShutdown(); - - return 0; - } - - public static void - main(String[] args) - { - final Server app = new Server(); - - Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = Ice.Util.createProperties(); - initData.properties.load("config.server"); - - // - // This demo uses a dispatcher to execute any invocations on the server. - // By using an executor it is straightforward to interrupt any servant - // dispatch threads by using ExecutorService.shutdownNow. - // - initData.dispatcher = new Ice.Dispatcher() { - @Override - public void dispatch(Runnable runnable, Ice.Connection con) - { - app.getExecutor().submit(runnable); - } - }; - - int status = app.main("Server", args, initData); - System.exit(status); - } - - ExecutorService getExecutor() - { - return _executor; - } - - private ExecutorService _executor = Executors.newFixedThreadPool(5); -} diff --git a/java/demo/Ice/interrupt/TaskManager.ice b/java/demo/Ice/interrupt/TaskManager.ice deleted file mode 100644 index adc807a242e..00000000000 --- a/java/demo/Ice/interrupt/TaskManager.ice +++ /dev/null @@ -1,21 +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 Demo -{ - -interface TaskManager -{ - void run(int id); - void shutdown(); -}; - -}; diff --git a/java/demo/Ice/interrupt/TaskManagerI.java b/java/demo/Ice/interrupt/TaskManagerI.java deleted file mode 100644 index ab642aeb63d..00000000000 --- a/java/demo/Ice/interrupt/TaskManagerI.java +++ /dev/null @@ -1,56 +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 java.util.concurrent.ExecutorService; - -import Demo.*; - -public class TaskManagerI extends _TaskManagerDisp -{ - public TaskManagerI(ExecutorService executor) - { - _executor = executor; - } - - @Override - public void - run(int id, Ice.Current current) - { - System.out.println("starting task " + id); - // Sleep for 10 seconds. - try - { - Thread.sleep(10000); - System.out.println("stopping task " + id); - } - catch(InterruptedException ex) - { - // - // We are done, the server is shutting down. - // - System.out.println("interrupted task " + id); - } - } - - @Override - public void - shutdown(Ice.Current current) - { - System.out.println("Shutting down..."); - // - // Call shutdownNow on the executor. This interrupts all - // executor threads causing any running upcalls to terminate - // quickly. - // - _executor.shutdownNow(); - current.adapter.getCommunicator().shutdown(); - } - - private ExecutorService _executor; -} diff --git a/java/demo/Ice/interrupt/config.client b/java/demo/Ice/interrupt/config.client deleted file mode 100644 index 93ba30b3ca7..00000000000 --- a/java/demo/Ice/interrupt/config.client +++ /dev/null @@ -1,46 +0,0 @@ -# -# The client reads this property to create the reference to the -# "task manager" object in the server. -# -TaskManager.Proxy=manager:tcp -p 10000 - -# -# ThreadInterruptSafe must be enabled to use interrupt. -# -Ice.ThreadInterruptSafe=1 - -# -# Only connect to the localhost interface by default. -# -Ice.Default.Host=localhost - -# -# 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 - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10003 -Ice.Admin.InstanceName=client -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/Ice/interrupt/config.server b/java/demo/Ice/interrupt/config.server deleted file mode 100644 index 9d950f604a5..00000000000 --- a/java/demo/Ice/interrupt/config.server +++ /dev/null @@ -1,47 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Hello". The following line sets the endpoints for this -# adapter. -# -TaskManager.Endpoints=tcp -p 10000 - -# -# ThreadInterruptSafe must be enabled to use interrupt. -# -Ice.ThreadInterruptSafe=1 - -# -# Only listen on the localhost interface by default. -# -Ice.Default.Host=localhost - -# -# 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 - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10002 -Ice.Admin.InstanceName=server -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/Ice/interrupt/expect.py b/java/demo/Ice/interrupt/expect.py deleted file mode 100755 index fdbc8ddeddf..00000000000 --- a/java/demo/Ice/interrupt/expect.py +++ /dev/null @@ -1,30 +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 - -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 -from demoscript.Ice import interrupt - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar --Ice.Warn.Connections=0') -client.expect('.*==>') - -interrupt.run(client, server) diff --git a/java/demo/Ice/invoke/.externalToolBuilders/demo.Ice.invoke.slice.launch b/java/demo/Ice/invoke/.externalToolBuilders/demo.Ice.invoke.slice.launch deleted file mode 100644 index 8ae21ad8fd4..00000000000 --- a/java/demo/Ice/invoke/.externalToolBuilders/demo.Ice.invoke.slice.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="${project}"/> -<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.Ice.invoke"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.invoke/Printer.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.invoke/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/Ice/invoke/Client.java b/java/demo/Ice/invoke/Client.java deleted file mode 100644 index 07426bee213..00000000000 --- a/java/demo/Ice/invoke/Client.java +++ /dev/null @@ -1,341 +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. -// -// ********************************************************************** - - - -public class Client extends Ice.Application -{ - private static void - menu() - { - System.out.println( - "usage:\n" + - "1: print string\n" + - "2: print string sequence\n" + - "3: print dictionary\n" + - "4: print enum\n" + - "5: print struct\n" + - "6: print struct sequence\n" + - "7: print class\n" + - "8: get values\n" + - "9: throw exception\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); - } - - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - @Override - 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()); - - Ice.ObjectPrx obj = communicator().propertyToProxy("Printer.Proxy"); - - menu(); - - java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - String line = null; - do - { - try - { - System.out.print("==> "); - System.out.flush(); - line = reader.readLine(); - if(line == null) - { - break; - } - if(line.equals("1")) - { - // - // Marshal the in parameter. - // - Ice.OutputStream out = Ice.Util.createOutputStream(communicator()); - out.startEncapsulation(); - out.writeString("The streaming API works!"); - out.endEncapsulation(); - - // - // Invoke operation. - // - if(!obj.ice_invoke("printString", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } - - out.destroy(); - } - else if(line.equals("2")) - { - // - // Marshal the in parameter. - // - Ice.OutputStream out = Ice.Util.createOutputStream(communicator()); - out.startEncapsulation(); - final String[] arr = { "The", "streaming", "API", "works!" }; - Demo.StringSeqHelper.write(out, arr); - out.endEncapsulation(); - - // - // Invoke operation. - // - if(!obj.ice_invoke("printStringSequence", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } - - out.destroy(); - } - else if(line.equals("3")) - { - // - // Marshal the in parameter. - // - Ice.OutputStream out = Ice.Util.createOutputStream(communicator()); - out.startEncapsulation(); - java.util.Map<String, String> dict = new java.util.HashMap<String, String>(); - dict.put("The", "streaming"); - dict.put("API", "works!"); - Demo.StringDictHelper.write(out, dict); - out.endEncapsulation(); - - // - // Invoke operation. - // - if(!obj.ice_invoke("printDictionary", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } - - out.destroy(); - } - else if(line.equals("4")) - { - // - // Marshal the in parameter. - // - Ice.OutputStream out = Ice.Util.createOutputStream(communicator()); - out.startEncapsulation(); - Demo.Color.green.ice_write(out); - out.endEncapsulation(); - - // - // Invoke operation. - // - if(!obj.ice_invoke("printEnum", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } - - out.destroy(); - } - else if(line.equals("5")) - { - // - // Marshal the in parameter. - // - Ice.OutputStream out = Ice.Util.createOutputStream(communicator()); - out.startEncapsulation(); - Demo.Structure s = new Demo.Structure(); - s.name = "red"; - s.value = Demo.Color.red; - s.ice_write(out); - out.endEncapsulation(); - - // - // Invoke operation. - // - if(!obj.ice_invoke("printStruct", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } - - out.destroy(); - } - else if(line.equals("6")) - { - // - // Marshal the in parameter. - // - Ice.OutputStream out = Ice.Util.createOutputStream(communicator()); - out.startEncapsulation(); - Demo.Structure[] arr = new Demo.Structure[3]; - arr[0] = new Demo.Structure(); - arr[0].name = "red"; - arr[0].value = Demo.Color.red; - arr[1] = new Demo.Structure(); - arr[1].name = "green"; - arr[1].value = Demo.Color.green; - arr[2] = new Demo.Structure(); - arr[2].name = "blue"; - arr[2].value = Demo.Color.blue; - Demo.StructureSeqHelper.write(out, arr); - out.endEncapsulation(); - - // - // Invoke operation. - // - if(!obj.ice_invoke("printStructSequence", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } - - out.destroy(); - } - else if(line.equals("7")) - { - // - // Marshal the in parameter. - // - Ice.OutputStream out = Ice.Util.createOutputStream(communicator()); - out.startEncapsulation(); - Demo.C c = new Demo.C(); - c.s = new Demo.Structure(); - c.s.name = "blue"; - c.s.value = Demo.Color.blue; - Demo.CHelper.write(out, c); - out.writePendingObjects(); - out.endEncapsulation(); - - // - // Invoke operation. - // - if(!obj.ice_invoke("printClass", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } - - out.destroy(); - } - else if(line.equals("8")) - { - // - // Invoke operation. - // - Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); - if(!obj.ice_invoke("getValues", Ice.OperationMode.Normal, null, outParams)) - { - System.out.println("Unknown user exception"); - continue; - } - - // - // Unmarshal the results. - // - Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams.value); - in.startEncapsulation(); - Demo.CHolder c = new Demo.CHolder(); - Demo.CHelper.read(in, c); - String str = in.readString(); - in.readPendingObjects(); - in.endEncapsulation(); - in.destroy(); - System.out.println("Got string `" + str + "' and class: s.name=" + c.value.s.name + - ", s.value=" + c.value.s.value); - } - else if(line.equals("9")) - { - // - // Invoke operation. - // - Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); - if(obj.ice_invoke("throwPrintFailure", Ice.OperationMode.Normal, null, outParams)) - { - System.out.println("Expected exception"); - continue; - } - - Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams.value); - in.startEncapsulation(); - try - { - in.throwException(); - } - catch(Demo.PrintFailure ex) - { - // Expected. - } - catch(Ice.UserException ex) - { - System.out.println("Unknown user exception"); - } - in.endEncapsulation(); - in.destroy(); - } - else if(line.equals("s")) - { - obj.ice_invoke("shutdown", Ice.OperationMode.Normal, null, null); - } - 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/invoke/Printer.ice b/java/demo/Ice/invoke/Printer.ice deleted file mode 100644 index a596f2595c8..00000000000 --- a/java/demo/Ice/invoke/Printer.ice +++ /dev/null @@ -1,51 +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 Demo -{ -exception PrintFailure -{ - string reason; -}; - -sequence<string> StringSeq; - -dictionary<string, string> StringDict; - -enum Color { red, green, blue }; - -struct Structure -{ - string name; - Color value; -}; - -sequence<Structure> StructureSeq; - -class C -{ - Structure s; -}; - -interface Printer -{ - void printString(string message); - void printStringSequence(StringSeq seq); - void printDictionary(StringDict dict); - void printEnum(Color c); - void printStruct(Structure st); - void printStructSequence(StructureSeq seq); - void printClass(C cls); - C getValues(out string str); - void throwPrintFailure() throws PrintFailure; - void shutdown(); -}; -}; diff --git a/java/demo/Ice/invoke/PrinterI.java b/java/demo/Ice/invoke/PrinterI.java deleted file mode 100644 index 0c63854035b..00000000000 --- a/java/demo/Ice/invoke/PrinterI.java +++ /dev/null @@ -1,150 +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. -// -// ********************************************************************** - -public class PrinterI extends Ice.Blobject -{ - @Override - public boolean - ice_invoke(byte[] inParams, Ice.ByteSeqHolder outParams, Ice.Current current) - { - Ice.Communicator communicator = current.adapter.getCommunicator(); - - Ice.InputStream in = Ice.Util.createInputStream(communicator, inParams); - in.startEncapsulation(); - - if(current.operation.equals("printString")) - { - String message = in.readString(); - System.out.println("Printing string `" + message + "'"); - in.endEncapsulation(); - in.destroy(); - return true; - } - else if(current.operation.equals("printStringSequence")) - { - String[] seq = Demo.StringSeqHelper.read(in); - in.endEncapsulation(); - in.destroy(); - System.out.print("Printing string sequence {"); - for(int i = 0; i < seq.length; ++i) - { - if(i > 0) - { - System.out.print(", "); - } - System.out.print("'" + seq[i] + "'"); - } - System.out.println("}"); - return true; - } - else if(current.operation.equals("printDictionary")) - { - java.util.Map<String, String> dict = Demo.StringDictHelper.read(in); - in.endEncapsulation(); - in.destroy(); - System.out.print("Printing dictionary {"); - boolean first = true; - for(java.util.Map.Entry<String, String> i : dict.entrySet()) - { - if(!first) - { - System.out.print(", "); - } - first = false; - System.out.print(i.getKey() + "=" + i.getValue()); - } - System.out.println("}"); - return true; - } - else if(current.operation.equals("printEnum")) - { - Demo.Color c = Demo.Color.ice_read(in); - in.endEncapsulation(); - in.destroy(); - System.out.println("Printing enum " + c); - return true; - } - else if(current.operation.equals("printStruct")) - { - Demo.Structure s = new Demo.Structure(); - s.ice_read(in); - in.endEncapsulation(); - in.destroy(); - System.out.println("Printing struct: name=" + s.name + ", value=" + s.value); - return true; - } - else if(current.operation.equals("printStructSequence")) - { - Demo.Structure[] seq = Demo.StructureSeqHelper.read(in); - in.endEncapsulation(); - in.destroy(); - System.out.print("Printing struct sequence: {"); - for(int i = 0; i < seq.length; ++i) - { - if(i > 0) - { - System.out.print(", "); - } - System.out.print(seq[i].name + "=" + seq[i].value); - } - System.out.println("}"); - return true; - } - else if(current.operation.equals("printClass")) - { - Demo.CHolder c = new Demo.CHolder(); - Demo.CHelper.read(in, c); - in.readPendingObjects(); - in.endEncapsulation(); - in.destroy(); - System.out.println("Printing class: s.name=" + c.value.s.name + ", s.value=" + c.value.s.value); - return true; - } - else if(current.operation.equals("getValues")) - { - Demo.C c = new Demo.C(); - c.s = new Demo.Structure(); - c.s.name = "green"; - c.s.value = Demo.Color.green; - Ice.OutputStream out = Ice.Util.createOutputStream(communicator); - out.startEncapsulation(); - Demo.CHelper.write(out, c); - out.writeString("hello"); - out.writePendingObjects(); - out.endEncapsulation(); - outParams.value = out.finished(); - return true; - } - else if(current.operation.equals("throwPrintFailure")) - { - System.out.println("Throwing PrintFailure"); - Demo.PrintFailure ex = new Demo.PrintFailure(); - ex.reason = "paper tray empty"; - Ice.OutputStream out = Ice.Util.createOutputStream(communicator); - out.startEncapsulation(); - out.writeException(ex); - out.endEncapsulation(); - outParams.value = out.finished(); - return false; - } - else if(current.operation.equals("shutdown")) - { - current.adapter.getCommunicator().shutdown(); - return true; - } - else - { - Ice.OperationNotExistException ex = new Ice.OperationNotExistException(); - ex.id = current.id; - ex.facet = current.facet; - ex.operation = current.operation; - throw ex; - } - } -} diff --git a/java/demo/Ice/invoke/README b/java/demo/Ice/invoke/README deleted file mode 100644 index 9b64c6c8777..00000000000 --- a/java/demo/Ice/invoke/README +++ /dev/null @@ -1,9 +0,0 @@ -This demo illustrates the use of the Ice streaming API. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/invoke/Server.java b/java/demo/Ice/invoke/Server.java deleted file mode 100644 index 933ad5aa0ad..00000000000 --- a/java/demo/Ice/invoke/Server.java +++ /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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Printer"); - adapter.add(new PrinterI(), communicator().stringToIdentity("printer")); - 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/invoke/config.client b/java/demo/Ice/invoke/config.client deleted file mode 100644 index 8e716199282..00000000000 --- a/java/demo/Ice/invoke/config.client +++ /dev/null @@ -1,44 +0,0 @@ -# -# The client reads this property to create the reference to the -# "Printer" object in the server. -# -Printer.Proxy=printer:default -h localhost -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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password diff --git a/java/demo/Ice/invoke/config.server b/java/demo/Ice/invoke/config.server deleted file mode 100644 index 77afc48dd21..00000000000 --- a/java/demo/Ice/invoke/config.server +++ /dev/null @@ -1,45 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Printer". The following line sets the endpoints for this -# adapter. -# -Printer.Endpoints=default -h localhost -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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password diff --git a/java/demo/Ice/invoke/expect.py b/java/demo/Ice/invoke/expect.py deleted file mode 100755 index d8b6d6477d2..00000000000 --- a/java/demo/Ice/invoke/expect.py +++ /dev/null @@ -1,28 +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 - -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 -from demoscript.Ice import invoke - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') - -invoke.run('java -jar build/libs/client.jar', server) diff --git a/java/demo/Ice/latency/.externalToolBuilders/demo.Ice.latency.slice.launch b/java/demo/Ice/latency/.externalToolBuilders/demo.Ice.latency.slice.launch deleted file mode 100644 index 70fa309dd00..00000000000 --- a/java/demo/Ice/latency/.externalToolBuilders/demo.Ice.latency.slice.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="${project}"/> -<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.Ice.latency"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.latency/Latency.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.latency/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/Ice/latency/Client.java b/java/demo/Ice/latency/Client.java deleted file mode 100644 index 266d2f859a8..00000000000 --- a/java/demo/Ice/latency/Client.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. -// -// ********************************************************************** - -import Demo.*; - -class Client extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - PingPrx ping = PingPrxHelper.checkedCast(communicator().propertyToProxy("Ping.Proxy")); - if(ping == null) - { - System.err.println("invalid proxy"); - return 1; - } - - // - // A method needs to be invoked thousands of times before the JIT compiler - // will convert it to native code. To ensure an accurate latency measurement, - // we need to "warm up" the JIT compiler. - // - { - final int repetitions = 20000; - System.out.print("warming up the JIT compiler..."); - System.out.flush(); - for(int i = 0; i < repetitions; i++) - { - ping.ice_ping(); - } - System.out.println(" ok"); - } - - long tv1 = System.currentTimeMillis(); - final int repetitions = 100000; - System.out.println("pinging server " + repetitions + " times (this may take a while)"); - for(int i = 0; i < repetitions; i++) - { - ping.ice_ping(); - } - - long tv2 = System.currentTimeMillis(); - double total = tv2 - tv1; - double perPing = total / repetitions; - - System.out.println("time for " + repetitions + " pings: " + total + "ms"); - System.out.println("time per ping: " + perPing + "ms"); - - 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/latency/Latency.ice b/java/demo/Ice/latency/Latency.ice deleted file mode 100644 index 510c032935a..00000000000 --- a/java/demo/Ice/latency/Latency.ice +++ /dev/null @@ -1,19 +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 Demo -{ - -class Ping -{ -}; - -}; diff --git a/java/demo/Ice/latency/README b/java/demo/Ice/latency/README deleted file mode 100644 index d44e63a2697..00000000000 --- a/java/demo/Ice/latency/README +++ /dev/null @@ -1,10 +0,0 @@ -A simple latency test that measures the basic call dispatch delay of -Ice. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/latency/Server.java b/java/demo/Ice/latency/Server.java deleted file mode 100644 index 0a17b7af66f..00000000000 --- a/java/demo/Ice/latency/Server.java +++ /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. -// -// ********************************************************************** - -import Demo.*; - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Latency"); - adapter.add(new Ping(), communicator().stringToIdentity("ping")); - 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/latency/config.client b/java/demo/Ice/latency/config.client deleted file mode 100644 index 3cf2a7e2aa3..00000000000 --- a/java/demo/Ice/latency/config.client +++ /dev/null @@ -1,38 +0,0 @@ -# -# The client reads this property to create the reference to the "Ping" -# object in the server. -# -Ping.Proxy=ping:tcp -p 10000 -#Ping.Proxy=ping:ssl -p 10001 - -# -# Uncomment to use the WebSocket transports instead. -# -#Ping.Proxy=ping:ws -p 10002 -#Ping.Proxy=ping:wss -p 10003 - -# -# Only connect to the localhost interface by default. -# -Ice.Default.Host=localhost - -# -# Disable client-side ACM. -# -Ice.ACM.Client.Timeout=0 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -p 10004 -Ice.Admin.InstanceName=client -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/Ice/latency/config.server b/java/demo/Ice/latency/config.server deleted file mode 100644 index c0a47046d69..00000000000 --- a/java/demo/Ice/latency/config.server +++ /dev/null @@ -1,38 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Latency". The following line sets the endpoints for this adapter. -# -Latency.Endpoints=tcp -p 10000:ssl -p 10001:ws -p 10002:wss -p 10003 - - -# Only listen on the localhost interface by default. -# -Ice.Default.Host=localhost - -# -# For secure WebSocket (WSS) clients and Windows Store App clients, -# you should disable this property. JavaScript browser clients and -# Windows Store App clients don't use client-side authentication. -# -#IceSSL.VerifyPeer=0 - -# -# Warn about connection exceptions -# -Ice.Warn.Connections=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10002 -Ice.Admin.InstanceName=server -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/Ice/latency/expect.py b/java/demo/Ice/latency/expect.py deleted file mode 100755 index df76bdb5c76..00000000000 --- a/java/demo/Ice/latency/expect.py +++ /dev/null @@ -1,36 +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 ping... ") -sys.stdout.flush() -client = Util.spawn('java -jar build/libs/client.jar') -client.waitTestSuccess(timeout=100) -print("ok") - -server.kill(signal.SIGINT) -server.waitTestSuccess() - -print(client.before) diff --git a/java/demo/Ice/minimal/.externalToolBuilders/demo.Ice.minimal.slice.launch b/java/demo/Ice/minimal/.externalToolBuilders/demo.Ice.minimal.slice.launch deleted file mode 100644 index 744e2fc6ce9..00000000000 --- a/java/demo/Ice/minimal/.externalToolBuilders/demo.Ice.minimal.slice.launch +++ /dev/null @@ -1,18 +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_AFTER_CLEAN_TARGETS" value="generate,"/> -<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="${project}"/> -<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.Ice.minimal"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.minimal/Hello.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.minimal/build.xml}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean"/> -<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> -</launchConfiguration> diff --git a/java/demo/Ice/minimal/Client.java b/java/demo/Ice/minimal/Client.java deleted file mode 100644 index 00dd7219021..00000000000 --- a/java/demo/Ice/minimal/Client.java +++ /dev/null @@ -1,31 +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 Demo.*; - -public class Client -{ - public static void - main(String[] args) - { - try - { - Ice.Communicator communicator = Ice.Util.initialize(args); - HelloPrx hello = HelloPrxHelper.checkedCast( - communicator.stringToProxy("hello:default -h localhost -p 10000")); - hello.sayHello(); - communicator.destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - System.exit(1); - } - } -} diff --git a/java/demo/Ice/minimal/Hello.ice b/java/demo/Ice/minimal/Hello.ice deleted file mode 100644 index f51170e8c0e..00000000000 --- a/java/demo/Ice/minimal/Hello.ice +++ /dev/null @@ -1,20 +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 Demo -{ - -interface Hello -{ - void sayHello(); -}; - -}; diff --git a/java/demo/Ice/minimal/HelloI.java b/java/demo/Ice/minimal/HelloI.java deleted file mode 100644 index fba7024dc8a..00000000000 --- a/java/demo/Ice/minimal/HelloI.java +++ /dev/null @@ -1,20 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - @Override - public void - sayHello(Ice.Current current) - { - System.out.println("Hello World!"); - } -} diff --git a/java/demo/Ice/minimal/README b/java/demo/Ice/minimal/README deleted file mode 100644 index d422dc39d34..00000000000 --- a/java/demo/Ice/minimal/README +++ /dev/null @@ -1,22 +0,0 @@ -This demo is a minimal Ice "hello world" application. Each time the -client is run a "sayHello" invocation is sent to the server. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar - -Note that this demo hardwires port 10000. If port 10000 is not -available on your machine, you need to edit both client and server -to use a free port. - -To run the server with WebSocket support: - -$ server --Ice.Default.Protocol=ws - -To run the client with WebSocket support: - -$ client --Ice.Default.Protocol=ws diff --git a/java/demo/Ice/minimal/Server.java b/java/demo/Ice/minimal/Server.java deleted file mode 100644 index 564f3cadffb..00000000000 --- a/java/demo/Ice/minimal/Server.java +++ /dev/null @@ -1,33 +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. -// -// ********************************************************************** - - - -public class Server -{ - public static void - main(String[] args) - { - try - { - Ice.Communicator communicator = Ice.Util.initialize(args); - Ice.ObjectAdapter adapter = - communicator.createObjectAdapterWithEndpoints("Hello", "default -h localhost -p 10000"); - adapter.add(new HelloI(), communicator.stringToIdentity("hello")); - adapter.activate(); - communicator.waitForShutdown(); - communicator.destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - System.exit(1); - } - } -} diff --git a/java/demo/Ice/minimal/expect.py b/java/demo/Ice/minimal/expect.py deleted file mode 100755 index 3620b67069b..00000000000 --- a/java/demo/Ice/minimal/expect.py +++ /dev/null @@ -1,35 +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.waitTestSuccess() -server.expect('Hello World!') -print("ok") - -server.kill(signal.SIGINT) -server.waitTestSuccess(-signal.SIGINT) diff --git a/java/demo/Ice/multicast/.externalToolBuilders/demo.Ice.multicast.slice.launch b/java/demo/Ice/multicast/.externalToolBuilders/demo.Ice.multicast.slice.launch deleted file mode 100644 index 6aae026a316..00000000000 --- a/java/demo/Ice/multicast/.externalToolBuilders/demo.Ice.multicast.slice.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="${project}"/> -<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.Ice.multicast"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.multicast/Discovery.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.multicast/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/Ice/multicast/Client.java b/java/demo/Ice/multicast/Client.java deleted file mode 100644 index 65fdc5d962b..00000000000 --- a/java/demo/Ice/multicast/Client.java +++ /dev/null @@ -1,54 +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 Demo.*; - -public class Client extends Ice.Application -{ - @Override - public int - run(String[] args) - { - args = communicator().getProperties().parseCommandLineOptions("Discover", args); - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("DiscoverReply"); - DiscoverReplyI replyI = new DiscoverReplyI(); - DiscoverReplyPrx reply = DiscoverReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)); - adapter.activate(); - - DiscoverPrx discover = DiscoverPrxHelper.uncheckedCast( - communicator().propertyToProxy("Discover.Proxy").ice_datagram()); - discover.lookup(reply); - Ice.ObjectPrx base = replyI.waitReply(2000); - - if(base == null) - { - System.err.println(appName() + ": no replies"); - return 1; - } - HelloPrx hello = HelloPrxHelper.checkedCast(base); - if(hello == null) - { - System.err.println(appName() + ": invalid reply"); - return 1; - } - - hello.sayHello(); - 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/multicast/DiscoverI.java b/java/demo/Ice/multicast/DiscoverI.java deleted file mode 100644 index bee50d60dfa..00000000000 --- a/java/demo/Ice/multicast/DiscoverI.java +++ /dev/null @@ -1,34 +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 Demo.*; - -public class DiscoverI extends _DiscoverDisp -{ - DiscoverI(Ice.ObjectPrx obj) - { - _obj = obj; - } - - @Override - public void - lookup(DiscoverReplyPrx reply, Ice.Current current) - { - try - { - reply.reply(_obj); - } - catch(Ice.LocalException ex) - { - // Ignore - } - } - - private Ice.ObjectPrx _obj; -} diff --git a/java/demo/Ice/multicast/DiscoverReplyI.java b/java/demo/Ice/multicast/DiscoverReplyI.java deleted file mode 100644 index 5d9aa9eb82b..00000000000 --- a/java/demo/Ice/multicast/DiscoverReplyI.java +++ /dev/null @@ -1,51 +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 Demo.*; - -public class DiscoverReplyI extends _DiscoverReplyDisp -{ - @Override - public synchronized void - reply(Ice.ObjectPrx obj, Ice.Current current) - { - if(_obj == null) - { - _obj = obj; - } - notify(); - } - - public synchronized Ice.ObjectPrx - waitReply(long timeout) - { - long end = System.currentTimeMillis() + timeout; - while(_obj == null) - { - long delay = end - System.currentTimeMillis(); - if(delay > 0) - { - try - { - wait(delay); - } - catch(java.lang.InterruptedException ex) - { - } - } - else - { - break; - } - } - return _obj; - } - - private Ice.ObjectPrx _obj; -} diff --git a/java/demo/Ice/multicast/Discovery.ice b/java/demo/Ice/multicast/Discovery.ice deleted file mode 100644 index b011888abda..00000000000 --- a/java/demo/Ice/multicast/Discovery.ice +++ /dev/null @@ -1,25 +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 Demo -{ - -interface DiscoverReply -{ - void reply(Object* obj); -}; - -interface Discover -{ - void lookup(DiscoverReply* replyHere); -}; - -}; diff --git a/java/demo/Ice/multicast/Hello.ice b/java/demo/Ice/multicast/Hello.ice deleted file mode 100644 index 0289edf4741..00000000000 --- a/java/demo/Ice/multicast/Hello.ice +++ /dev/null @@ -1,20 +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 Demo -{ - -interface Hello -{ - idempotent void sayHello(); -}; - -}; diff --git a/java/demo/Ice/multicast/HelloI.java b/java/demo/Ice/multicast/HelloI.java deleted file mode 100644 index fba7024dc8a..00000000000 --- a/java/demo/Ice/multicast/HelloI.java +++ /dev/null @@ -1,20 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - @Override - public void - sayHello(Ice.Current current) - { - System.out.println("Hello World!"); - } -} diff --git a/java/demo/Ice/multicast/README b/java/demo/Ice/multicast/README deleted file mode 100644 index 101dade71b3..00000000000 --- a/java/demo/Ice/multicast/README +++ /dev/null @@ -1,20 +0,0 @@ -This demo illustrates how to use UDP multicast to implement a -discovery service. - -To run the demo, first start multiple instances of the server: - -$ java -jar build/libs/server.jar - -In a separate window, start a client: - -$ java -jar build/libs/client.jar - -On startup the client will send out a broadcast message containing a -callback proxy and waits for a response. Any servers that are up and -listening on the broadcast port will then contact the client using the -callback saying they are available. The client selects a server and -proceeds. - -By default this demo uses IPv4. If you want to use IPv6 UDP multicast -instead, uncomment the alternative IPv6 configuration in config.client -and config.server. diff --git a/java/demo/Ice/multicast/Server.java b/java/demo/Ice/multicast/Server.java deleted file mode 100644 index 8b54e0a045d..00000000000 --- a/java/demo/Ice/multicast/Server.java +++ /dev/null @@ -1,40 +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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - args = communicator().getProperties().parseCommandLineOptions("Discover", args); - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); - Ice.ObjectAdapter discoverAdapter = communicator().createObjectAdapter("Discover"); - - Ice.ObjectPrx hello = adapter.addWithUUID(new HelloI()); - discoverAdapter.add(new DiscoverI(hello), communicator().stringToIdentity("discover")); - - discoverAdapter.activate(); - 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/multicast/config.client b/java/demo/Ice/multicast/config.client deleted file mode 100644 index d50eb45df44..00000000000 --- a/java/demo/Ice/multicast/config.client +++ /dev/null @@ -1,42 +0,0 @@ -# -# The client reads this property to create the reference to the -# "Discover" object in the server. -# -Discover.Proxy=discover:udp -h 239.255.1.1 -p 10000 - -# -# The client creates an object adapter with the name -# "DiscoverReply". The following line sets the endpoints for this -# adapter. -# -DiscoverReply.Endpoints=tcp - -# -# Alternative IPv6 configuration -# -#Ice.IPv6=1 -#Discover.Proxy=discover:udp -h "ff15::1:1" -p 10000 -#DiscoverReply.Endpoints=tcp -h "::1" - -# -# 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/multicast/config.server b/java/demo/Ice/multicast/config.server deleted file mode 100644 index 880ef9699cb..00000000000 --- a/java/demo/Ice/multicast/config.server +++ /dev/null @@ -1,41 +0,0 @@ -# -# The server creates a multi-cast object adapter with the name -# "Discover". The following line sets the endpoints for this adapter. -# -Discover.Endpoints=udp -h 239.255.1.1 -p 10000 - -# -# The server creates an object adapter with the name "Hello". The -# following line sets the endpoints for this adapter. -# -Hello.Endpoints=tcp - -# -# Alternative IPv6 configuration -# -#Ice.IPv6=1 -#Discover.Endpoints=udp -h "ff15::1:1" -p 10000 -#Hello.Endpoints=tcp -h "::1" - -# -# 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/multicast/expect.py b/java/demo/Ice/multicast/expect.py deleted file mode 100755 index 776b172cbba..00000000000 --- a/java/demo/Ice/multicast/expect.py +++ /dev/null @@ -1,25 +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 - -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 -from demoscript.Ice import multicast - -multicast.run('java -jar build/libs/client.jar', 'java -jar build/libs/server.jar') diff --git a/java/demo/Ice/nested/.externalToolBuilders/demo.Ice.nested.slice.launch b/java/demo/Ice/nested/.externalToolBuilders/demo.Ice.nested.slice.launch deleted file mode 100644 index fb17d0b31db..00000000000 --- a/java/demo/Ice/nested/.externalToolBuilders/demo.Ice.nested.slice.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="${project}"/> -<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.Ice.nested"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.nested/Nested.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.nested/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/Ice/nested/Client.java b/java/demo/Ice/nested/Client.java deleted file mode 100644 index e7ba716955b..00000000000 --- a/java/demo/Ice/nested/Client.java +++ /dev/null @@ -1,124 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - /* - * For this demo we won't destroy the communicator since it has to - * wait for any outstanding invocations to complete which may take - * some time if the nesting level is exceeded. - * - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - */ - } - } - - @Override - 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()); - - NestedPrx nested = NestedPrxHelper.checkedCast(communicator().propertyToProxy("Nested.Proxy")); - if(nested == null) - { - System.err.println("invalid proxy"); - return 1; - } - - // - // Ensure the invocation times out if the nesting level is too - // high and there are no more threads in the thread pool to - // dispatch the call. - // - nested = (NestedPrx)nested.ice_invocationTimeout(5000); - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Nested.Client"); - NestedPrx self = - NestedPrxHelper.uncheckedCast(adapter.createProxy(communicator().stringToIdentity("nestedClient"))); - adapter.add(new NestedI(self), communicator().stringToIdentity("nestedClient")); - adapter.activate(); - - System.out.println("Note: The maximum nesting level is sz * 2, with sz being"); - System.out.println("the maximum number of threads in the server thread pool. If"); - System.out.println("you specify a value higher than that, the application will"); - System.out.println("block or timeout."); - System.out.println(); - - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - String s = null; - do - { - try - { - System.out.print("enter nesting level or 'x' for exit: "); - System.out.flush(); - s = in.readLine(); - if(s == null) - { - break; - } - int level = Integer.parseInt(s); - if(level > 0) - { - nested.nestedCall(level, self); - } - } - catch(NumberFormatException ex) - { - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - while(!s.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/nested/Nested.ice b/java/demo/Ice/nested/Nested.ice deleted file mode 100644 index 430e9db0bf1..00000000000 --- a/java/demo/Ice/nested/Nested.ice +++ /dev/null @@ -1,20 +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 Demo -{ - -interface Nested -{ - void nestedCall(int level, Nested* proxy); -}; - -}; diff --git a/java/demo/Ice/nested/NestedI.java b/java/demo/Ice/nested/NestedI.java deleted file mode 100644 index 4756af60a74..00000000000 --- a/java/demo/Ice/nested/NestedI.java +++ /dev/null @@ -1,36 +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 Demo.*; - -class NestedI extends _NestedDisp -{ - NestedI(NestedPrx self) - { - _self = self; - } - - @Override - public void - nestedCall(int level, NestedPrx proxy, Ice.Current current) - { - System.out.println("" + level); - if(--level > 0) - { - // - // Ensure the invocation times out if the nesting level is too - // high and there are no more threads in the thread pool to - // dispatch the call. - // - ((NestedPrx)proxy.ice_invocationTimeout(5000)).nestedCall(level, _self); - } - } - - private NestedPrx _self; -} diff --git a/java/demo/Ice/nested/README b/java/demo/Ice/nested/README deleted file mode 100644 index 52e427c4db6..00000000000 --- a/java/demo/Ice/nested/README +++ /dev/null @@ -1,10 +0,0 @@ -A demo to illustrate how nested callbacks work, and how the size of -the thread pool affects the maximum nesting depth. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/nested/Server.java b/java/demo/Ice/nested/Server.java deleted file mode 100644 index 399005786b6..00000000000 --- a/java/demo/Ice/nested/Server.java +++ /dev/null @@ -1,40 +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 Demo.*; - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Nested.Server"); - NestedPrx self = - NestedPrxHelper.uncheckedCast(adapter.createProxy(communicator().stringToIdentity("nestedServer"))); - adapter.add(new NestedI(self), communicator().stringToIdentity("nestedServer")); - 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/nested/config.client b/java/demo/Ice/nested/config.client deleted file mode 100644 index 31c04dd2609..00000000000 --- a/java/demo/Ice/nested/config.client +++ /dev/null @@ -1,46 +0,0 @@ -# -# The client reads this property to create the reference to the -# "Nested" object in the server. -# -Nested.Proxy=nestedServer:default -h localhost -p 10000 - -# -# The client creates one single object adapter with the name -# "Nested.Client". The following line sets the endpoints for this -# adapter. -# -Nested.Client.Endpoints=default -h localhost - -# -# The following properties configure the server thread pool. The -# thread pool initially contains 5 threads, and the Ice run time -# starts emitting warnings once 5 threads are in use. The Ice run time -# creates more threads once all 5 are in use, up to a maximum of 10 -# threads. -# -Ice.ThreadPool.Server.Size=5 -Ice.ThreadPool.Server.SizeWarn=5 -Ice.ThreadPool.Server.SizeMax=10 - -# -# 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/nested/config.server b/java/demo/Ice/nested/config.server deleted file mode 100644 index 5b30db90cbc..00000000000 --- a/java/demo/Ice/nested/config.server +++ /dev/null @@ -1,41 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Nested.Server". The following line sets the endpoints for this -# adapter. -# -Nested.Server.Endpoints=default -h localhost -p 10000 - -# -# The following properties configure the server thread pool. The -# thread pool initially contains 5 threads, and the Ice run time -# starts emitting warnings once 5 threads are in use. The Ice run time -# creates more threads once all 5 are in use, up to a maximum of 10 -# threads. -# -Ice.ThreadPool.Server.Size=5 -Ice.ThreadPool.Server.SizeWarn=5 -Ice.ThreadPool.Server.SizeMax=10 - -# -# 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/nested/expect.py b/java/demo/Ice/nested/expect.py deleted file mode 100755 index 5cc1860e32c..00000000000 --- a/java/demo/Ice/nested/expect.py +++ /dev/null @@ -1,30 +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 - -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 -from demoscript.Ice import nested - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar --Ice.Override.Timeout=2000') -client.expect('.*for exit:') - -nested.run(client, server) diff --git a/java/demo/Ice/optional/.externalToolBuilders/demo.Ice.optional.slice.launch b/java/demo/Ice/optional/.externalToolBuilders/demo.Ice.optional.slice.launch deleted file mode 100644 index 468a437d47b..00000000000 --- a/java/demo/Ice/optional/.externalToolBuilders/demo.Ice.optional.slice.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="${project}"/> -<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.Ice.optional"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.optional/Contact.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.optional/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/Ice/optional/Client.java b/java/demo/Ice/optional/Client.java deleted file mode 100644 index 3a57a5c6f9d..00000000000 --- a/java/demo/Ice/optional/Client.java +++ /dev/null @@ -1,247 +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 Demo.*; -import Ice.Optional; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - ContactDBPrx contactdb = ContactDBPrxHelper.checkedCast(communicator().propertyToProxy("ContactDB.Proxy")); - if(contactdb == null) - { - System.err.println(appName() + ": invalid proxy"); - return 1; - } - - // - // Add a contact for "john". In this case since all parameters are provided it isn't - // necessary to construct an Optional. - // - String johnNumber = "123-456-7890"; - contactdb.addContact("john", NumberType.HOME, johnNumber, 0); - - System.out.print("Checking john... "); - - // - // Find the phone number for "john". Note the use of the Ice.Optional - // for non-generic types. - // - Ice.Optional<String> number = contactdb.queryNumber("john"); - - // - // isSet() tests if an optional value is set. - // - if(!number.isSet()) - { - System.out.print("number is incorrect "); - } - - // - // Call get() to retrieve the optional value. - // - if(!number.get().equals(johnNumber)) - { - System.out.print("number is incorrect "); - } - - // Optional can also be used in an out parameter. Note that - // primitive types don't use Ice.Optional. - Ice.IntOptional dialgroup = new Ice.IntOptional(); - contactdb.queryDialgroup("john", dialgroup); - if(!dialgroup.isSet() || dialgroup.get() != 0) - { - System.out.print("dialgroup is incorrect "); - } - - Contact info = contactdb.query("john"); - - // - // All of the info parameters should be set. On a class call - // has<name> to find out whether the value is set. - // - if(!info.hasType() || !info.hasNumber() || !info.hasDialGroup()) - { - System.out.print("info is incorrect "); - } - // Call get<name> to retrieve the value. - if(info.getType() != NumberType.HOME || !info.getNumber().equals(johnNumber) || info.getDialGroup() != 0) - { - System.out.print("info is incorrect "); - } - System.out.println("ok"); - - // - // Add a contact for "steve". Here we have to construct Optional parameters - // since we are not passing the NumberType parameter. - // - // The behavior of the server is to default construct the - // Contact, and then assign all set parameters. Since the - // default value of NumberType in the slice definition is - // NumberType.HOME and in this case the NumberType is unset - // it will take the default value. - // - // The java mapping permits null to be passed to unset optional values. - // - String steveNumber = "234-567-8901"; - contactdb.addContact("steve", null, Optional.O(steveNumber), Optional.O(1)); - - System.out.print("Checking steve... "); - number = contactdb.queryNumber("steve"); - if(!number.get().equals(steveNumber)) - { - System.out.print("number is incorrect "); - } - - info = contactdb.query("steve"); - // - // Check the value for the NumberType. - // - if(!info.hasType() || info.getType() != NumberType.HOME) - { - System.out.print("info is incorrect "); - } - - if(!info.getNumber().equals(steveNumber) || info.getDialGroup() != 1) - { - System.out.print("info is incorrect "); - } - - contactdb.queryDialgroup("steve", dialgroup); - if(!dialgroup.isSet() || dialgroup.get() != 1) - { - System.out.print("dialgroup is incorrect "); - } - - System.out.println("ok"); - - // - // Add a contact from "frank". Here the dialGroup field isn't set. - // - String frankNumber = "345-678-9012"; - contactdb.addContact("frank", Optional.O(NumberType.CELL), Optional.O(frankNumber), null); - - System.out.print("Checking frank... "); - - number = contactdb.queryNumber("frank"); - if(!number.get().equals(frankNumber)) - { - System.out.print("number is incorrect "); - } - - info = contactdb.query("frank"); - // - // The dial group field should be unset. - // - if(info.hasDialGroup()) - { - System.out.print("info is incorrect "); - } - if(info.getType() != NumberType.CELL || !info.getNumber().equals(frankNumber)) - { - System.out.print("info is incorrect "); - } - - contactdb.queryDialgroup("frank", dialgroup); - if(dialgroup.isSet()) - { - System.out.print("dialgroup is incorrect "); - } - System.out.println("ok"); - - // - // Add a contact from "anne". The number field isn't set. - // - contactdb.addContact("anne", Optional.O(NumberType.OFFICE), null, Optional.O(2)); - - System.out.print("Checking anne... "); - number = contactdb.queryNumber("anne"); - if(number.isSet()) - { - System.out.print("number is incorrect "); - } - - info = contactdb.query("anne"); - // - // The number field should be unset. - // - if(info.hasNumber()) - { - System.out.print("info is incorrect "); - } - if(info.getType() != NumberType.OFFICE || info.getDialGroup() != 2) - { - System.out.print("info is incorrect "); - } - - contactdb.queryDialgroup("anne", dialgroup); - if(!dialgroup.isSet() || dialgroup.get() != 2) - { - System.out.print("dialgroup is incorrect "); - } - - // - // The optional fields can be used to determine what fields to - // update on the contact. Here we update only the number for anne, - // the remainder of the fields are unchanged. - // - String anneNumber = "456-789-0123"; - contactdb.updateContact("anne", null, Optional.O(anneNumber), null); - number = contactdb.queryNumber("anne"); - if(!number.get().equals(anneNumber)) - { - System.out.print("number is incorrect "); - } - info = contactdb.query("anne"); - if(!info.getNumber().equals(anneNumber) || info.getType() != NumberType.OFFICE || info.getDialGroup() != 2) - { - System.out.print("info is incorrect "); - } - System.out.println("ok"); - - contactdb.shutdown(); - - 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/optional/Contact.ice b/java/demo/Ice/optional/Contact.ice deleted file mode 100644 index a7e45b79359..00000000000 --- a/java/demo/Ice/optional/Contact.ice +++ /dev/null @@ -1,43 +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 Demo -{ - -enum NumberType -{ - HOME, - OFFICE, - CELL -}; - -class Contact -{ - string name; - optional(1) NumberType type = HOME; - optional(2) string number; - optional(3) int dialGroup; -}; - -interface ContactDB -{ - void addContact(string name, optional(1) NumberType type, optional(2) string number, optional(3) int dialGroup); - void updateContact(string name, optional(1) NumberType type, optional(2) string number, optional(3) int dialGroup); - - Contact query(string name); - ["java:optional"] optional(1) string queryNumber(string name); - ["java:optional"] void queryDialgroup(string name, out optional(1) int dialGroup); - - void shutdown(); -}; - -}; - diff --git a/java/demo/Ice/optional/ContactDBI.java b/java/demo/Ice/optional/ContactDBI.java deleted file mode 100644 index 94e8f7c278f..00000000000 --- a/java/demo/Ice/optional/ContactDBI.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 Demo.*; - -public class ContactDBI extends _ContactDBDisp -{ - private java.util.Map<String, Contact> _contacts = new java.util.HashMap<String, Contact>(); - - @Override - public final void - addContact(String name, Ice.Optional<NumberType> type, Ice.Optional<String> number, Ice.IntOptional dialGroup, - Ice.Current current) - { - Contact contact = new Contact(); - contact.name = name; - if(type.isSet()) - { - contact.setType(type.get()); - } - if(number.isSet()) - { - contact.setNumber(number.get()); - } - if(dialGroup.isSet()) - { - contact.setDialGroup(dialGroup.get()); - } - _contacts.put(name, contact); - } - - @Override - public final void - updateContact(String name, Ice.Optional<NumberType> type, Ice.Optional<String> number, Ice.IntOptional dialGroup, - Ice.Current current) - { - Contact c = _contacts.get(name); - if(c != null) - { - if(type.isSet()) - { - c.setType(type.get()); - } - if(number.isSet()) - { - c.setNumber(number.get()); - } - if(dialGroup.isSet()) - { - c.setDialGroup(dialGroup.get()); - } - } - } - - @Override - public final Contact - query(String name, Ice.Current current) - { - return _contacts.get(name); - } - - @Override - public final void - queryDialgroup(String name, Ice.IntOptional dialGroup, Ice.Current current) - { - Contact c = _contacts.get(name); - if(c != null) - { - dialGroup.set(c.optionalDialGroup()); - } - } - - @Override - public final Ice.Optional<String> - queryNumber(String name, Ice.Current current) - { - Ice.Optional<String> ret = null; - Contact c = _contacts.get(name); - if(c != null) - { - ret = c.optionalNumber(); - } - return ret; - } - - @Override - public void - shutdown(Ice.Current current) - { - System.out.println("Shutting down..."); - current.adapter.getCommunicator().shutdown(); - } -} diff --git a/java/demo/Ice/optional/README b/java/demo/Ice/optional/README deleted file mode 100644 index 15175383693..00000000000 --- a/java/demo/Ice/optional/README +++ /dev/null @@ -1,10 +0,0 @@ -This demo illustrates the use of optional class members and -parameters. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/optional/Server.java b/java/demo/Ice/optional/Server.java deleted file mode 100644 index 1dbb4e64b03..00000000000 --- a/java/demo/Ice/optional/Server.java +++ /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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("ContactDB"); - adapter.add(new ContactDBI(), communicator().stringToIdentity("contactdb")); - 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/optional/config.client b/java/demo/Ice/optional/config.client deleted file mode 100644 index 596855e5e00..00000000000 --- a/java/demo/Ice/optional/config.client +++ /dev/null @@ -1,10 +0,0 @@ -# -# The client reads this property to create the reference to the -# "ContactDB" object in the server. -# -ContactDB.Proxy=contactdb:default -p 10000 -h localhost - -# -# Warn about connection exceptions -# -Ice.Warn.Connections=1 diff --git a/java/demo/Ice/optional/config.server b/java/demo/Ice/optional/config.server deleted file mode 100644 index 28294ccd18e..00000000000 --- a/java/demo/Ice/optional/config.server +++ /dev/null @@ -1,11 +0,0 @@ -# -# The server creates one single object adapter with the name -# "ContactDB". The following line sets the endpoints for this -# adapter. -# -ContactDB.Endpoints=default -p 10000 -h localhost - -# -# Warn about connection exceptions -# -Ice.Warn.Connections=1 diff --git a/java/demo/Ice/optional/expect.py b/java/demo/Ice/optional/expect.py deleted file mode 100755 index 2d5ba5977f2..00000000000 --- a/java/demo/Ice/optional/expect.py +++ /dev/null @@ -1,29 +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 - -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 -from demoscript.Ice import optional - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar --Ice.Warn.Connections=0') - -optional.run(client, server) diff --git a/java/demo/Ice/plugin/.externalToolBuilders/demo.Ice.plugin.slice.launch b/java/demo/Ice/plugin/.externalToolBuilders/demo.Ice.plugin.slice.launch deleted file mode 100644 index e5949d00646..00000000000 --- a/java/demo/Ice/plugin/.externalToolBuilders/demo.Ice.plugin.slice.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="${project}"/> -<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.Ice.plugin"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.plugin/Hello.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.plugin/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/Ice/plugin/Client.java b/java/demo/Ice/plugin/Client.java deleted file mode 100644 index 23c7028cd8d..00000000000 --- a/java/demo/Ice/plugin/Client.java +++ /dev/null @@ -1,125 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - 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"); - } - - @Override - 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; - } - 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(); - } - 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/plugin/Hello.ice b/java/demo/Ice/plugin/Hello.ice deleted file mode 100644 index 9612791a1e9..00000000000 --- a/java/demo/Ice/plugin/Hello.ice +++ /dev/null @@ -1,21 +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 Demo -{ - -interface Hello -{ - idempotent void sayHello(); - void shutdown(); -}; - -}; diff --git a/java/demo/Ice/plugin/HelloI.java b/java/demo/Ice/plugin/HelloI.java deleted file mode 100644 index 20c37cd920d..00000000000 --- a/java/demo/Ice/plugin/HelloI.java +++ /dev/null @@ -1,28 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - @Override - public void - sayHello(Ice.Current current) - { - current.adapter.getCommunicator().getLogger().print("Hello World!"); - } - - @Override - public void - shutdown(Ice.Current current) - { - current.adapter.getCommunicator().getLogger().print("Shutting down..."); - current.adapter.getCommunicator().shutdown(); - } -} diff --git a/java/demo/Ice/plugin/HelloPluginFactoryI.java b/java/demo/Ice/plugin/HelloPluginFactoryI.java deleted file mode 100644 index 9d27416831f..00000000000 --- a/java/demo/Ice/plugin/HelloPluginFactoryI.java +++ /dev/null @@ -1,20 +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. -// -// ********************************************************************** - - - -public class HelloPluginFactoryI implements Ice.PluginFactory -{ - @Override - public Ice.Plugin - create(Ice.Communicator communicator, String name, String[] args) - { - return new HelloPluginI(communicator); - } -} diff --git a/java/demo/Ice/plugin/HelloPluginI.java b/java/demo/Ice/plugin/HelloPluginI.java deleted file mode 100644 index 7a3f0081d7f..00000000000 --- a/java/demo/Ice/plugin/HelloPluginI.java +++ /dev/null @@ -1,36 +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. -// -// ********************************************************************** - - - -public class HelloPluginI implements Ice.Plugin -{ - public - HelloPluginI(Ice.Communicator communicator) - { - _communicator = communicator; - } - - @Override - public void - initialize() - { - Ice.ObjectAdapter adapter = _communicator.createObjectAdapter("Hello"); - adapter.add(new HelloI(), _communicator.stringToIdentity("hello")); - adapter.activate(); - } - - @Override - public void - destroy() - { - } - - private Ice.Communicator _communicator; -} diff --git a/java/demo/Ice/plugin/LoggerI.java b/java/demo/Ice/plugin/LoggerI.java deleted file mode 100644 index 0126b3cc2fd..00000000000 --- a/java/demo/Ice/plugin/LoggerI.java +++ /dev/null @@ -1,55 +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. -// -// ********************************************************************** - - - -public class LoggerI implements Ice.Logger -{ - @Override - public void - print(String message) - { - System.out.println("PRINT: " + message); - } - - @Override - public void - trace(String category, String message) - { - System.out.println("TRACE(" + category + "): " + message); - } - - @Override - public void - warning(String message) - { - System.out.println("WARNING: " + message); - } - - @Override - public void - error(String message) - { - System.out.println("ERROR: " + message); - } - - @Override - public String - getPrefix() - { - return ""; - } - - @Override - public Ice.Logger - cloneWithPrefix(String prefix) - { - return new LoggerI(); - } -} diff --git a/java/demo/Ice/plugin/LoggerPluginFactoryI.java b/java/demo/Ice/plugin/LoggerPluginFactoryI.java deleted file mode 100644 index 78c431d8221..00000000000 --- a/java/demo/Ice/plugin/LoggerPluginFactoryI.java +++ /dev/null @@ -1,20 +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. -// -// ********************************************************************** - - - -public class LoggerPluginFactoryI implements Ice.PluginFactory -{ - @Override - public Ice.Plugin - create(Ice.Communicator communicator, String name, String[] args) - { - return new Ice.LoggerPlugin(communicator, new LoggerI()); - } -} diff --git a/java/demo/Ice/plugin/README b/java/demo/Ice/plugin/README deleted file mode 100644 index 7e087c3c6ab..00000000000 --- a/java/demo/Ice/plugin/README +++ /dev/null @@ -1,17 +0,0 @@ -This demo illustrates how to write and configure a simple Ice plugin -as well as a Ice Logger plugin. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar - -Both the client and server use a custom logger which is loaded as -a logger plugin. The server also uses a plugin to implement the -servant for this demo. - -Please Look in the client and sever configuration files to see the -plugin configuration. diff --git a/java/demo/Ice/plugin/Server.java b/java/demo/Ice/plugin/Server.java deleted file mode 100644 index 088fff50b00..00000000000 --- a/java/demo/Ice/plugin/Server.java +++ /dev/null @@ -1,33 +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. -// -// ********************************************************************** - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - 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/plugin/config.client b/java/demo/Ice/plugin/config.client deleted file mode 100644 index 41fbaf2d1ce..00000000000 --- a/java/demo/Ice/plugin/config.client +++ /dev/null @@ -1,33 +0,0 @@ -# -# The client reads this property to create the reference to the -# "hello" object in the server. -# -Hello.Proxy=hello:tcp -h localhost -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 - -# -# Logger Plugin Configuration -# -Ice.Plugin.Logger=LoggerPluginFactoryI diff --git a/java/demo/Ice/plugin/config.server b/java/demo/Ice/plugin/config.server deleted file mode 100644 index e95038be334..00000000000 --- a/java/demo/Ice/plugin/config.server +++ /dev/null @@ -1,33 +0,0 @@ -# -# 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 - -# -# Logger Plugin Configuration -# -Ice.Plugin.Logger=LoggerPluginFactoryI - -# -# Tracing Plugin Configuration -# -Ice.Plugin.Hello=HelloPluginFactoryI -Hello.Endpoints=tcp -h localhost -p 10000 diff --git a/java/demo/Ice/plugin/expect.py b/java/demo/Ice/plugin/expect.py deleted file mode 100755 index 1c79b66337d..00000000000 --- a/java/demo/Ice/plugin/expect.py +++ /dev/null @@ -1,30 +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 - -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 -from demoscript.Ice import plugin - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar --Ice.Warn.Connections=0') -client.expect('.*==>') - -plugin.run(client, server) diff --git a/java/demo/Ice/properties/.externalToolBuilders/demo.Ice.properties.slice.launch b/java/demo/Ice/properties/.externalToolBuilders/demo.Ice.properties.slice.launch deleted file mode 100644 index 3ad0379875c..00000000000 --- a/java/demo/Ice/properties/.externalToolBuilders/demo.Ice.properties.slice.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="${project}"/> -<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.Ice.properties"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.properties/Props.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.properties/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/Ice/properties/Client.java b/java/demo/Ice/properties/Client.java deleted file mode 100644 index 1160bc8f016..00000000000 --- a/java/demo/Ice/properties/Client.java +++ /dev/null @@ -1,194 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private static void - menu() - { - System.out.println( - "\n" + - "usage:\n" + - "1: set properties (batch 1)\n" + - "2: set properties (batch 2)\n" + - "c: show current properties\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); - } - - private static void - show(Ice.PropertiesAdminPrx admin) - { - java.util.Map<String, String> props = admin.getPropertiesForPrefix("Demo"); - System.out.println("Server's current settings:"); - for(java.util.Map.Entry<String, String> e : props.entrySet()) - { - System.out.println(" " + e.getKey() + "=" + e.getValue()); - } - } - - @Override - 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()); - - PropsPrx props = PropsPrxHelper.checkedCast(communicator().propertyToProxy("Props.Proxy")); - if(props == null) - { - System.err.println("invalid proxy"); - return 1; - } - - Ice.PropertiesAdminPrx admin = - Ice.PropertiesAdminPrxHelper.checkedCast(communicator().propertyToProxy("Admin.Proxy")); - - java.util.List<String> keys = java.util.Arrays.asList("Demo.Prop1", "Demo.Prop2", "Demo.Prop3"); - - java.util.Map<String, String> batch1 = new java.util.HashMap<String, String>(); - batch1.put("Demo.Prop1", "1"); - batch1.put("Demo.Prop2", "2"); - batch1.put("Demo.Prop3", "3"); - - java.util.Map<String, String> batch2 = new java.util.HashMap<String, String>(); - batch2.put("Demo.Prop1", "10"); - batch2.put("Demo.Prop2", ""); // An empty value removes this property - batch2.put("Demo.Prop3", "30"); - - show(admin); - 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("1") || line.equals("2")) - { - java.util.Map<String, String> dict = line.equals("1") ? batch1 : batch2; - System.out.println("Sending:"); - for(String key : keys) - { - String value = dict.get(key); - if(value != null) - { - System.out.println(" " + key + "=" + value); - } - } - System.out.println(); - - admin.setProperties(dict); - - System.out.println("Changes:"); - java.util.Map<String, String> changes = props.getChanges(); - if(changes.isEmpty()) - { - System.out.println(" None."); - } - else - { - for(String key : keys) - { - System.out.print(" " + key); - String value = dict.get(key); - if(value == null || value.length() == 0) - { - System.out.println(" was removed"); - } - else - { - System.out.println(" is now " + value); - } - } - } - } - else if(line.equals("c")) - { - show(admin); - } - else if(line.equals("s")) - { - props.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/properties/Props.ice b/java/demo/Ice/properties/Props.ice deleted file mode 100644 index dc0c23f5105..00000000000 --- a/java/demo/Ice/properties/Props.ice +++ /dev/null @@ -1,26 +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. -// -// ********************************************************************** - -#ifndef DEMO_ICE -#define DEMO_ICE - -#include <Ice/Properties.ice> - -module Demo -{ - -interface Props -{ - idempotent Ice::PropertyDict getChanges(); - void shutdown(); -}; - -}; - -#endif diff --git a/java/demo/Ice/properties/README b/java/demo/Ice/properties/README deleted file mode 100644 index 57cf196e283..00000000000 --- a/java/demo/Ice/properties/README +++ /dev/null @@ -1,12 +0,0 @@ -This demo illustrates how to access a server's PropertiesAdmin facet -in order to retrieve and modify its configuration properties. This -demo also shows how the server can receive notifications whenever its -properties are changed. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/properties/Server.java b/java/demo/Ice/properties/Server.java deleted file mode 100644 index edc97c01573..00000000000 --- a/java/demo/Ice/properties/Server.java +++ /dev/null @@ -1,98 +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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - // - // The servant implements the Slice interface Demo::Props as well as the - // native callback interface Ice.PropertiesAdminUpdateCallback. - // - static class PropsI extends Demo._PropsDisp implements Ice.PropertiesAdminUpdateCallback - { - PropsI() - { - _called = false; - } - - @Override - public synchronized java.util.Map<String, String> getChanges(Ice.Current current) - { - // - // Make sure that we have received the property updates before we - // return the results. - // - while(!_called) - { - try - { - wait(); - } - catch(InterruptedException ex) - { - } - } - - _called = false; - return _changes; - } - - @Override - public void shutdown(Ice.Current current) - { - current.adapter.getCommunicator().shutdown(); - } - - @Override - public synchronized void updated(java.util.Map<String, String> changes) - { - _changes = changes; - _called = true; - notify(); - } - - java.util.Map<String, String> _changes; - private boolean _called; - } - - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - PropsI props = new PropsI(); - - // - // Retrieve the PropertiesAdmin facet and register the servant as the update callback. - // - Ice.Object obj = communicator().findAdminFacet("Properties"); - Ice.NativePropertiesAdmin admin = (Ice.NativePropertiesAdmin)obj; - admin.addUpdateCallback(props); - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Props"); - adapter.add(props, communicator().stringToIdentity("props")); - 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/properties/config.client b/java/demo/Ice/properties/config.client deleted file mode 100644 index 682523bb1c8..00000000000 --- a/java/demo/Ice/properties/config.client +++ /dev/null @@ -1,51 +0,0 @@ -# -# The client reads this property to create the reference to the -# "props" object in the server. -# -Props.Proxy=props:default -p 10000 - -# -# This proxy allows the client to communicate with the -# PropertiesAdmin facet of the Ice administrative facility. -# -Admin.Proxy=Demo/admin -f Properties:default -p 10001 - -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password -IceSSL.Truststore=certs.jks diff --git a/java/demo/Ice/properties/config.server b/java/demo/Ice/properties/config.server deleted file mode 100644 index 81cd91d8b44..00000000000 --- a/java/demo/Ice/properties/config.server +++ /dev/null @@ -1,61 +0,0 @@ -# -# The server creates an object adapter with the name -# "Props". The following line sets the endpoints for this -# adapter. -# -Props.Endpoints=default -p 10000 - -# -# Enable the Ice administrative facility by setting the -# following properties. -# -Ice.Admin.Endpoints=default -p 10001 -Ice.Admin.InstanceName=Demo -Ice.Trace.Admin.Properties=2 - -# -# Initial values for the demo properties. -# -Demo.Prop1=0 -Demo.Prop2=0 -Demo.Prop3=0 - -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password -IceSSL.Truststore=certs.jks diff --git a/java/demo/Ice/properties/expect.py b/java/demo/Ice/properties/expect.py deleted file mode 100755 index 3df6c8bb61e..00000000000 --- a/java/demo/Ice/properties/expect.py +++ /dev/null @@ -1,30 +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 - -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 * -from demoscript.Ice import properties - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar --Ice.Warn.Connections=0') -client.expect('.*==>') - -properties.run(client, server) diff --git a/java/demo/Ice/serialize/.externalToolBuilders/demo.Ice.serialize.slice.launch b/java/demo/Ice/serialize/.externalToolBuilders/demo.Ice.serialize.slice.launch deleted file mode 100644 index 110b506f425..00000000000 --- a/java/demo/Ice/serialize/.externalToolBuilders/demo.Ice.serialize.slice.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="${project}"/> -<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.Ice.serialize"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.serialize/Greet.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.serialize/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/Ice/serialize/Client.java b/java/demo/Ice/serialize/Client.java deleted file mode 100644 index b598fd8142b..00000000000 --- a/java/demo/Ice/serialize/Client.java +++ /dev/null @@ -1,144 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - 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"); - } - - @Override - 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 deleted file mode 100644 index 96513f89434..00000000000 --- a/java/demo/Ice/serialize/Demo/MyGreeting.java +++ /dev/null @@ -1,15 +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 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 deleted file mode 100644 index 183be3237d4..00000000000 --- a/java/demo/Ice/serialize/Greet.ice +++ /dev/null @@ -1,23 +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 Demo -{ - -["java:serializable:Demo.MyGreeting"] sequence<byte> Greeting; - -interface Greet -{ - idempotent void sendGreeting(Greeting g); - void shutdown(); -}; - -}; diff --git a/java/demo/Ice/serialize/GreetI.java b/java/demo/Ice/serialize/GreetI.java deleted file mode 100644 index 0b793bcb359..00000000000 --- a/java/demo/Ice/serialize/GreetI.java +++ /dev/null @@ -1,35 +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 Demo.*; - -public class GreetI extends _GreetDisp -{ - @Override - public void - sendGreeting(MyGreeting greeting, Ice.Current current) - { - if(greeting != null) - { - System.out.println(greeting.text); - } - else - { - System.out.println("Received null greeting"); - } - } - - @Override - 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 deleted file mode 100644 index d48fec090c0..00000000000 --- a/java/demo/Ice/serialize/README +++ /dev/null @@ -1,37 +0,0 @@ -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 -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar - -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 deleted file mode 100644 index 449c24e221d..00000000000 --- a/java/demo/Ice/serialize/Server.java +++ /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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - 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/config.client b/java/demo/Ice/serialize/config.client deleted file mode 100644 index 26de1dc0423..00000000000 --- a/java/demo/Ice/serialize/config.client +++ /dev/null @@ -1,28 +0,0 @@ -# -# The client reads this property to create the reference to the -# "greet" object in the server. -# -Greet.Proxy=greet:tcp -h localhost -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 deleted file mode 100644 index 079d4e62a5e..00000000000 --- a/java/demo/Ice/serialize/config.server +++ /dev/null @@ -1,29 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Greet". The following line sets the endpoints for this -# adapter. -# -Greet.Endpoints=tcp -h localhost -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 deleted file mode 100755 index 5ac2c24426f..00000000000 --- a/java/demo/Ice/serialize/expect.py +++ /dev/null @@ -1,30 +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 - -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 -from demoscript.Ice import serialize - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar --Ice.Warn.Connections=0') -client.expect('.*==>') - -serialize.run(client, server) diff --git a/java/demo/Ice/session/.externalToolBuilders/demo.Ice.session.slice.launch b/java/demo/Ice/session/.externalToolBuilders/demo.Ice.session.slice.launch deleted file mode 100644 index 7faed75d805..00000000000 --- a/java/demo/Ice/session/.externalToolBuilders/demo.Ice.session.slice.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="${project}"/> -<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.Ice.session"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.session/Session.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.session/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/Ice/session/Client.java b/java/demo/Ice/session/Client.java deleted file mode 100644 index adcd14a2750..00000000000 --- a/java/demo/Ice/session/Client.java +++ /dev/null @@ -1,229 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - cleanup(true); - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private static void - menu() - { - System.out.println( - "usage:\n" + - "c: create a new per-client hello object\n" + - "0-9: send a greeting to a hello object\n" + - "s: shutdown the server and exit\n" + - "x: exit\n" + - "t: exit without destroying the session\n" + - "?: help\n"); - } - - @Override - 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()); - - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - String name; - try - { - do - { - System.out.print("Please enter your name ==> "); - System.out.flush(); - name = in.readLine().trim(); - } - while(name.length() == 0); - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - return 0; - } - - Ice.ObjectPrx base = communicator().propertyToProxy("SessionFactory.Proxy"); - SessionFactoryPrx factory = SessionFactoryPrxHelper.checkedCast(base); - if(factory == null) - { - System.err.println("invalid proxy"); - return 1; - } - - synchronized(this) - { - _session = factory.create(name); - _executor.scheduleAtFixedRate(new Runnable() - { - @Override - public void - run() - { - try - { - _session.refresh(); - } - catch(Ice.LocalException ex) - { - communicator().getLogger().warning("SessionRefreshThread: " + ex); - // Exceptions thrown from the executor task supress subsequent execution - // of the task. - throw ex; - } - } - }, 5, 5, java.util.concurrent.TimeUnit.SECONDS); - } - - java.util.ArrayList<HelloPrx> hellos = new java.util.ArrayList<HelloPrx>(); - - menu(); - - try - { - boolean destroy = true; - boolean shutdown = false; - while(true) - { - System.out.print("==> "); - System.out.flush(); - String line = in.readLine(); - if(line == null) - { - break; - } - if(line.length() > 0 && Character.isDigit(line.charAt(0))) - { - int index; - try - { - index = Integer.parseInt(line); - } - catch(NumberFormatException e) - { - menu(); - continue; - } - if(index < hellos.size()) - { - HelloPrx hello = hellos.get(index); - hello.sayHello(); - } - else - { - System.out.println("Index is too high. " + hellos.size() + " exist so far. " + - "Use 'c' to create a new hello object."); - } - } - else if(line.equals("c")) - { - hellos.add(_session.createHello()); - System.out.println("created hello object " + (hellos.size() - 1)); - } - else if(line.equals("s")) - { - destroy = false; - shutdown = true; - break; - } - else if(line.equals("x")) - { - break; - } - else if(line.equals("t")) - { - destroy = false; - break; - } - else if(line.equals("?")) - { - menu(); - } - else - { - System.out.println("unknown command `" + line + "'"); - menu(); - } - } - - cleanup(destroy); - if(shutdown) - { - factory.shutdown(); - } - } - catch(Exception ex) - { - try - { - cleanup(true); - } - catch(Ice.LocalException e) - { - } - ex.printStackTrace(); - } - - return 0; - } - - synchronized private void - cleanup(boolean destroy) - { - // - // The refresher task must be terminated before destroy is - // called, otherwise it might get ObjectNotExistException. - // - _executor.shutdown(); - if(destroy && _session != null) - { - _session.destroy(); - } - _session = null; - } - - public static void - main(String[] args) - { - Client app = new Client(); - int status = app.main("Client", args, "config.client"); - System.exit(status); - } - - private java.util.concurrent.ScheduledExecutorService _executor = java.util.concurrent.Executors.newScheduledThreadPool(1); - private SessionPrx _session = null; -} diff --git a/java/demo/Ice/session/HelloI.java b/java/demo/Ice/session/HelloI.java deleted file mode 100644 index 5eabf7d6929..00000000000 --- a/java/demo/Ice/session/HelloI.java +++ /dev/null @@ -1,31 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - public - HelloI(String name, int id) - { - _name = name; - _id = id; - } - - @Override - public void - sayHello(Ice.Current current) - { - System.out.println("Hello object #" + _id + " for session `" + _name + "' says:\n" + - "Hello " + _name + "!"); - } - - final private String _name; - final private int _id; -} diff --git a/java/demo/Ice/session/README b/java/demo/Ice/session/README deleted file mode 100644 index b6c06f54a2b..00000000000 --- a/java/demo/Ice/session/README +++ /dev/null @@ -1,17 +0,0 @@ -This example demonstrates how to clean up per-client objects through -the use of sessions. - -When the client starts, a session object is created through which all -per-client objects are created. The session object's timestamp must be -refreshed by the client on a periodic basis otherwise it will be -destroyed. Once the session is destroyed, whether by the client -destroying the session upon termination or due to a timeout, all -per-client objects are automatically cleaned up by the session object. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/session/ReapTask.java b/java/demo/Ice/session/ReapTask.java deleted file mode 100644 index 6ce234f6d76..00000000000 --- a/java/demo/Ice/session/ReapTask.java +++ /dev/null @@ -1,70 +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 Demo.*; - -class ReapTask implements Runnable -{ - static class SessionProxyPair - { - SessionProxyPair(Demo.SessionPrx p, SessionI s) - { - proxy = p; - session = s; - } - - Demo.SessionPrx proxy; - SessionI session; - } - - @Override - synchronized public void - run() - { - java.util.Iterator<SessionProxyPair> p = _sessions.iterator(); - while(p.hasNext()) - { - SessionProxyPair s = p.next(); - try - { - // - // Session destruction may take time in a - // real-world example. Therefore the current time - // is computed for each iteration. - // - if((System.currentTimeMillis() - s.session.timestamp()) > _timeout) - { - String name = s.proxy.getName(); - s.proxy.destroy(); - System.out.println("The session " + name + " has timed out."); - p.remove(); - } - } - catch(Ice.ObjectNotExistException e) - { - p.remove(); - } - } - } - - synchronized public void - terminate() - { - _sessions.clear(); - } - - synchronized public void - add(SessionPrx proxy, SessionI session) - { - _sessions.add(new SessionProxyPair(proxy, session)); - } - - private final long _timeout = 10 * 1000; // 10 seconds. - private java.util.List<SessionProxyPair> _sessions = new java.util.LinkedList<SessionProxyPair>(); -} diff --git a/java/demo/Ice/session/Server.java b/java/demo/Ice/session/Server.java deleted file mode 100644 index fbd54d2e4b7..00000000000 --- a/java/demo/Ice/session/Server.java +++ /dev/null @@ -1,47 +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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("SessionFactory"); - - java.util.concurrent.ScheduledExecutorService executor = java.util.concurrent.Executors.newScheduledThreadPool(1); - ReapTask reaper = new ReapTask(); - executor.scheduleAtFixedRate(reaper, 1, 1, java.util.concurrent.TimeUnit.SECONDS); - - adapter.add(new SessionFactoryI(reaper), communicator().stringToIdentity("SessionFactory")); - adapter.activate(); - communicator().waitForShutdown(); - - executor.shutdown(); - reaper.terminate(); - - 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/session/Session.ice b/java/demo/Ice/session/Session.ice deleted file mode 100644 index b1de47b0f6f..00000000000 --- a/java/demo/Ice/session/Session.ice +++ /dev/null @@ -1,59 +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 Demo -{ - -interface Hello -{ - idempotent void sayHello(); -}; - -// -// The session object. This is used to create per-session objects on -// behalf of the client. If the session is not refreshed on a periodic -// basis, it will be automatically destroyed. -// -interface Session -{ - // - // Create a new per-session hello object. The created object will - // be automatically destroyed when the session is destroyed. - // - Hello* createHello(); - - // - // Refresh a session. If a session is not refreshed on a regular - // basis by the client, it will be automatically destroyed. - // - idempotent void refresh(); - - idempotent string getName(); - - // - // Destroy the session explicitly. - // - void destroy(); -}; - -interface SessionFactory -{ - // - // Create a session with the given name. Note that the name is - // only used for diagnostic purposes. It is not used as unique - // session id. - // - Session* create(string name); - - void shutdown(); -}; - -}; diff --git a/java/demo/Ice/session/SessionFactoryI.java b/java/demo/Ice/session/SessionFactoryI.java deleted file mode 100644 index b4dacf044f1..00000000000 --- a/java/demo/Ice/session/SessionFactoryI.java +++ /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. -// -// ********************************************************************** - -import Demo.*; - -class SessionFactoryI extends _SessionFactoryDisp -{ - SessionFactoryI(ReapTask reaper) - { - _reaper = reaper; - } - - @Override - public synchronized SessionPrx - create(String name, Ice.Current c) - { - SessionI session = new SessionI(name); - SessionPrx proxy = SessionPrxHelper.uncheckedCast(c.adapter.addWithUUID(session)); - _reaper.add(proxy, session); - return proxy; - } - - @Override - public void - shutdown(Ice.Current c) - { - System.out.println("Shutting down..."); - c.adapter.getCommunicator().shutdown(); - } - - private ReapTask _reaper; -} diff --git a/java/demo/Ice/session/SessionI.java b/java/demo/Ice/session/SessionI.java deleted file mode 100644 index dcb7adf68ef..00000000000 --- a/java/demo/Ice/session/SessionI.java +++ /dev/null @@ -1,100 +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 Demo.*; - -class SessionI extends _SessionDisp -{ - public - SessionI(String name) - { - _name = name; - _timestamp = System.currentTimeMillis(); - System.out.println("The session " + _name + " is now created."); - } - - @Override - synchronized public HelloPrx - createHello(Ice.Current c) - { - if(_destroy) - { - throw new Ice.ObjectNotExistException(); - } - HelloPrx hello = HelloPrxHelper.uncheckedCast(c.adapter.addWithUUID(new HelloI(_name, _nextId++))); - _objs.add(hello); - return hello; - } - - @Override - synchronized public void - refresh(Ice.Current c) - { - if(_destroy) - { - throw new Ice.ObjectNotExistException(); - } - _timestamp = System.currentTimeMillis(); - } - - @Override - synchronized public String - getName(Ice.Current c) - { - if(_destroy) - { - throw new Ice.ObjectNotExistException(); - } - return _name; - } - - @Override - synchronized public void - destroy(Ice.Current c) - { - if(_destroy) - { - throw new Ice.ObjectNotExistException(); - } - - _destroy = true; - System.out.println("The session " + _name + " is now destroyed."); - try - { - c.adapter.remove(c.id); - for(HelloPrx p : _objs) - { - c.adapter.remove(p.ice_getIdentity()); - } - } - catch(Ice.ObjectAdapterDeactivatedException e) - { - // This method is called on shutdown of the server, in - // which case this exception is expected. - } - _objs.clear(); - } - - synchronized public long - timestamp() - { - if(_destroy) - { - throw new Ice.ObjectNotExistException(); - } - return _timestamp; - } - - private String _name; - private boolean _destroy = false; // true if destroy() was called, false otherwise. - private long _timestamp; // The last time the session was refreshed. - private int _nextId = 0; // The id of the next hello object. This is used for tracing purposes. - private java.util.List<HelloPrx> _objs = - new java.util.LinkedList<HelloPrx>(); // List of per-client allocated Hello objects. -} diff --git a/java/demo/Ice/session/config.client b/java/demo/Ice/session/config.client deleted file mode 100644 index 20e58a0a02d..00000000000 --- a/java/demo/Ice/session/config.client +++ /dev/null @@ -1,10 +0,0 @@ -# -# The client reads this property to create the reference to the -# "SessionFactory" object in the server. -# -SessionFactory.Proxy=SessionFactory:default -h localhost -p 10000 - -# -# Warn about connection exceptions -# -Ice.Warn.Connections=1 diff --git a/java/demo/Ice/session/config.server b/java/demo/Ice/session/config.server deleted file mode 100644 index b7f0b313ba4..00000000000 --- a/java/demo/Ice/session/config.server +++ /dev/null @@ -1,11 +0,0 @@ -# -# The server creates one single object adapter with the name -# "SessionFactory". The following line sets the endpoints for this -# adapter. -# -SessionFactory.Endpoints=default -h localhost -p 10000 - -# -# Warn about connection exceptions -# -Ice.Warn.Connections=1 diff --git a/java/demo/Ice/session/expect.py b/java/demo/Ice/session/expect.py deleted file mode 100755 index 4901220ac4e..00000000000 --- a/java/demo/Ice/session/expect.py +++ /dev/null @@ -1,28 +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 - -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 -from demoscript.Ice import session - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') - -session.run('java -jar build/libs/client.jar', server) diff --git a/java/demo/Ice/swing/.externalToolBuilders/demo.Ice.swing.slice.launch b/java/demo/Ice/swing/.externalToolBuilders/demo.Ice.swing.slice.launch deleted file mode 100644 index e5880692a2b..00000000000 --- a/java/demo/Ice/swing/.externalToolBuilders/demo.Ice.swing.slice.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="${project}"/> -<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.Ice.swing"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.swing/Hello.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.swing/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/Ice/swing/Client.java b/java/demo/Ice/swing/Client.java deleted file mode 100644 index e7bb118f04d..00000000000 --- a/java/demo/Ice/swing/Client.java +++ /dev/null @@ -1,673 +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 java.awt.*; -import java.awt.event.*; - -import javax.swing.*; -import javax.swing.event.*; - -public class Client extends JFrame -{ - public static void main(final String[] args) - { - SwingUtilities.invokeLater(new Runnable() - { - @Override - public void run() - { - try - { - // - // Create and set up the window. - // - new Client(args); - } - catch(Ice.LocalException e) - { - JOptionPane.showMessageDialog(null, e.toString(), "Initialization failed", - JOptionPane.ERROR_MESSAGE); - } - } - }); - } - - private void destroyCommunicator() - { - if(_communicator == null) - { - return; - } - - // - // Destroy the Ice communicator. - // - try - { - _communicator.destroy(); - } - catch(Throwable ex) - { - ex.printStackTrace(); - } - finally - { - _communicator = null; - } - } - - Client(String[] args) - { - // - // Initialize an Ice communicator. - // - try - { - Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = Ice.Util.createProperties(); - initData.properties.load("config.client"); - initData.dispatcher = new Ice.Dispatcher() - { - @Override - public void - dispatch(Runnable runnable, Ice.Connection connection) - { - SwingUtilities.invokeLater(runnable); - } - }; - _communicator = Ice.Util.initialize(args, initData); - } - catch(Throwable ex) - { - handleException(ex); - } - - Container cp = this; - - JLabel l1 = new JLabel("Hostname"); - _hostname = new JTextField(); - JLabel l2 = new JLabel("Mode"); - _mode = new JComboBox<String>(); - JLabel l3 = new JLabel("Timeout"); - _timeoutSlider = new JSlider(0, MAX_TIME); - _timeoutLabel = new JLabel("0.0"); - JLabel l4 = new JLabel("Delay"); - _delaySlider = new JSlider(0, MAX_TIME); - _delayLabel = new JLabel("0.0"); - JPanel buttonPanel = new JPanel(); - _hello = new JButton("Hello World!"); - _shutdown = new JButton("Shutdown"); - _flush = new JButton("Flush"); - _flush.setEnabled(false); - JSeparator statusPanelSeparator = new JSeparator(); - _status = new JLabel(); - _status.setText("Ready"); - - // - // Default to localhost. - // - _hostname.setText("127.0.0.1"); - _hostname.getDocument().addDocumentListener(new DocumentListener() - { - @Override - public void changedUpdate(DocumentEvent e) - { - updateProxy(); - } - - @Override - public void insertUpdate(DocumentEvent e) - { - if(e.getDocument().getLength() > 0) - { - _hello.setEnabled(true); - _shutdown.setEnabled(true); - } - updateProxy(); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - if(e.getDocument().getLength() == 0) - { - _hello.setEnabled(false); - _shutdown.setEnabled(false); - _flush.setEnabled(false); - } - updateProxy(); - } - }); - - _mode.setModel(new DefaultComboBoxModel<String>(DELIVERY_MODE_DESC)); - - _hello.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - sayHello(); - } - }); - _shutdown.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - shutdown(); - } - }); - _flush.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - flush(); - } - }); - _mode.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - changeDeliveryMode(_mode.getSelectedIndex()); - } - }); - changeDeliveryMode(_mode.getSelectedIndex()); - - _timeoutSlider.addChangeListener(new SliderListener(_timeoutSlider, _timeoutLabel)); - _timeoutSlider.addChangeListener(new ChangeListener() - { - @Override - public void stateChanged(ChangeEvent ce) - { - updateProxy(); - } - }); - _timeoutSlider.setValue(0); - _delaySlider.addChangeListener(new SliderListener(_delaySlider, _delayLabel)); - _delaySlider.setValue(0); - - GridBagConstraints gridBagConstraints; - - cp.setMaximumSize(null); - cp.setPreferredSize(null); - cp.setLayout(new GridBagLayout()); - - l1.setText("Hostname"); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 0; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 5, 5); - cp.add(l1, gridBagConstraints); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 0; - gridBagConstraints.gridwidth = 2; - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints.insets = new Insets(5, 0, 5, 5); - cp.add(_hostname, gridBagConstraints); - - l2.setText("Mode"); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 1; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(0, 5, 5, 0); - cp.add(l2, gridBagConstraints); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 1; - gridBagConstraints.gridwidth = 2; - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints.insets = new Insets(0, 0, 5, 5); - cp.add(_mode, gridBagConstraints); - - l3.setText("Timeout"); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 2; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(0, 5, 5, 0); - cp.add(l3, gridBagConstraints); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 2; - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints.anchor = GridBagConstraints.WEST; - cp.add(_timeoutSlider, gridBagConstraints); - - _timeoutLabel.setMinimumSize(new Dimension(20, 17)); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 2; - gridBagConstraints.gridy = 2; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(0, 5, 5, 5); - cp.add(_timeoutLabel, gridBagConstraints); - - l4.setText("Delay"); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 3; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(0, 5, 5, 0); - cp.add(l4, gridBagConstraints); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 3; - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints.anchor = GridBagConstraints.WEST; - cp.add(_delaySlider, gridBagConstraints); - - _delayLabel.setMinimumSize(new Dimension(20, 17)); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 2; - gridBagConstraints.gridy = 3; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(0, 5, 5, 5); - cp.add(_delayLabel, gridBagConstraints); - - _hello.setText("Hello World!"); - buttonPanel.add(_hello); - - _shutdown.setText("Shutdown"); - buttonPanel.add(_shutdown); - - _flush.setText("Flush"); - buttonPanel.add(_flush); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 4; - gridBagConstraints.gridwidth = 3; - gridBagConstraints.ipady = 5; - cp.add(buttonPanel, gridBagConstraints); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 5; - gridBagConstraints.gridwidth = 3; - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints.insets = new Insets(0, 5, 5, 5); - cp.add(statusPanelSeparator, gridBagConstraints); - - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 6; - gridBagConstraints.gridwidth = 3; - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints.insets = new Insets(0, 5, 5, 5); - cp.add(_status, gridBagConstraints); - - setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); - - _shutdownHook = new Thread("Shutdown hook") - { - @Override - public void run() - { - destroyCommunicator(); - } - }; - - try - { - Runtime.getRuntime().addShutdownHook(_shutdownHook); - } - catch(IllegalStateException e) - { - // - // Shutdown in progress, ignored - // - } - - addWindowListener(new WindowAdapter() - { - @Override - public void windowClosing(WindowEvent e) - { - destroyCommunicator(); - Runtime.getRuntime().removeShutdownHook(_shutdownHook); - dispose(); - Runtime.getRuntime().exit(0); - } - }); - - - setTitle("Ice - Hello World!"); - pack(); - locateOnScreen(this); - setVisible(true); - } - - // These two arrays match and match the order of the delivery mode enumeration. - private final static DeliveryMode DELIVERY_MODES[] = { - DeliveryMode.TWOWAY, - DeliveryMode.TWOWAY_SECURE, - DeliveryMode.ONEWAY, - DeliveryMode.ONEWAY_BATCH, - DeliveryMode.ONEWAY_SECURE, - DeliveryMode.ONEWAY_SECURE_BATCH, - DeliveryMode.DATAGRAM, - DeliveryMode.DATAGRAM_BATCH, - }; - private final static String DELIVERY_MODE_DESC[] = new String[] { - "Twoway", - "Twoway Secure", - "Oneway", - "Oneway Batch", - "Oneway Secure", - "Oneway Secure Batch", - "Datagram", - "Datagram Batch" - }; - private enum DeliveryMode - { - TWOWAY, - TWOWAY_SECURE, - ONEWAY, - ONEWAY_BATCH, - ONEWAY_SECURE, - ONEWAY_SECURE_BATCH, - DATAGRAM, - DATAGRAM_BATCH; - - Ice.ObjectPrx apply(Ice.ObjectPrx prx) - { - switch (this) - { - case TWOWAY: - { - prx = prx.ice_twoway(); - break; - } - case TWOWAY_SECURE: - { - prx = prx.ice_twoway().ice_secure(true); - break; - } - case ONEWAY: - { - prx = prx.ice_oneway(); - break; - } - case ONEWAY_BATCH: - { - prx = prx.ice_batchOneway(); - break; - } - case ONEWAY_SECURE: - { - prx = prx.ice_oneway().ice_secure(true); - break; - } - case ONEWAY_SECURE_BATCH: - { - prx = prx.ice_batchOneway().ice_secure(true); - break; - } - case DATAGRAM: - { - prx = prx.ice_datagram(); - break; - } - case DATAGRAM_BATCH: - { - prx = prx.ice_batchDatagram(); - break; - } - } - return prx; - } - - public boolean isOneway() - { - return this == ONEWAY || this == ONEWAY_SECURE || this == DATAGRAM; - } - - public boolean isBatch() - { - return this == ONEWAY_BATCH || this == DATAGRAM_BATCH || this == ONEWAY_SECURE_BATCH; - } - } - - private void updateProxy() - { - String host = _hostname.getText().toString().trim(); - if(host.length() == 0) - { - _status.setText("No hostname"); - return; - } - - String s = "hello:tcp -h " + host + " -p 10000:ssl -h " + host + " -p 10001:udp -h " + host + " -p 10000"; - Ice.ObjectPrx prx = _communicator.stringToProxy(s); - prx = _deliveryMode.apply(prx); - int timeout = _timeoutSlider.getValue(); - if(timeout != 0) - { - prx = prx.ice_invocationTimeout(timeout); - } - _helloPrx = Demo.HelloPrxHelper.uncheckedCast(prx); - - // - // The batch requests associated to the proxy are lost when we - // update the proxy. - // - _flush.setEnabled(false); - - _status.setText("Ready"); - } - - private void sayHello() - { - if(_helloPrx == null) - { - return; - } - - int delay = _delaySlider.getValue(); - try - { - if(!_deliveryMode.isBatch()) - { - _status.setText("Sending request"); - final DeliveryMode mode = _deliveryMode; - _helloPrx.begin_sayHello(delay, new Demo.Callback_Hello_sayHello() { - @Override - public void response() - { - assert (!_response); - _response = true; - _status.setText("Ready"); - } - - @Override - public void exception(final Ice.LocalException ex) - { - assert (!_response); - _response = true; - handleException(ex); - } - - @Override - public void sent(boolean ss) - { - if(mode.isOneway()) - { - _status.setText("Ready"); - } - else if(!_response) - { - _status.setText("Waiting for response"); - } - } - - private boolean _response = false; - }); - } - else - { - _flush.setEnabled(true); - _helloPrx.sayHello(delay); - _status.setText("Queued sayHello request"); - } - } - catch(Ice.LocalException ex) - { - handleException(ex); - } - } - - private void shutdown() - { - if(_helloPrx == null) - { - return; - } - - try - { - if(!_deliveryMode.isBatch()) - { - _status.setText("Sending request"); - final DeliveryMode mode = _deliveryMode; - _helloPrx.begin_shutdown(new Demo.Callback_Hello_shutdown() - { - @Override - public void response() - { - _response = true; - _status.setText("Ready"); - } - - @Override - public void exception(final Ice.LocalException ex) - { - _response = true; - handleException(ex); - } - - @Override - public void sent(boolean ss) - { - if(mode.isOneway()) - { - _status.setText("Ready"); - } - else if(!_response) - { - _status.setText("Waiting for response"); - } - } - - private boolean _response = false; - }); - } - else - { - _flush.setEnabled(true); - _helloPrx.shutdown(); - _status.setText("Queued shutdown request"); - } - } - catch(Ice.LocalException ex) - { - handleException(ex); - } - } - - private void flush() - { - if(_helloPrx == null) - { - return; - } - - _helloPrx.begin_ice_flushBatchRequests(new Ice.Callback_Object_ice_flushBatchRequests() - { - @Override - public void exception(final Ice.LocalException ex) - { - handleException(ex); - } - }); - - _flush.setEnabled(false); - _status.setText("Flushed batch requests"); - } - - private void changeDeliveryMode(long id) - { - _deliveryMode = DELIVERY_MODES[(int)id]; - updateProxy(); - } - - private void handleException(final Throwable ex) - { - // Ignore CommunicatorDestroyedException which could occur on - // shutdown. - if(ex instanceof Ice.CommunicatorDestroyedException) - { - return; - } - ex.printStackTrace(); - _status.setText(ex.getClass().getName()); - } - - private static class SliderListener implements ChangeListener - { - SliderListener(JSlider slider, JLabel label) - { - _slider = slider; - _label = label; - } - - @Override - public void stateChanged(ChangeEvent ce) - { - float value = (float)(_slider.getValue() / 1000.0); - _label.setText(String.format("%.1f", value)); - } - - private JSlider _slider; - private JLabel _label; - } - - private static void locateOnScreen(Component component) - { - Dimension paneSize = component.getSize(); - Dimension screenSize = component.getToolkit().getScreenSize(); - component.setLocation((screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2); - } - - private static final int MAX_TIME = 5000; // 5 seconds - - private JTextField _hostname; - private JComboBox<String> _mode; - private JSlider _timeoutSlider; - private JLabel _timeoutLabel; - private JSlider _delaySlider; - private JLabel _delayLabel; - private JButton _hello; - private JButton _shutdown; - private JButton _flush; - private JLabel _status; - - private Ice.Communicator _communicator; - private DeliveryMode _deliveryMode; - private Thread _shutdownHook; - - private Demo.HelloPrx _helloPrx = null; -} diff --git a/java/demo/Ice/swing/Hello.ice b/java/demo/Ice/swing/Hello.ice deleted file mode 100644 index e33b79c0798..00000000000 --- a/java/demo/Ice/swing/Hello.ice +++ /dev/null @@ -1,21 +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 Demo -{ - -interface Hello -{ - idempotent void sayHello(int delay); - void shutdown(); -}; - -}; diff --git a/java/demo/Ice/swing/README b/java/demo/Ice/swing/README deleted file mode 100644 index a275c8312b9..00000000000 --- a/java/demo/Ice/swing/README +++ /dev/null @@ -1,12 +0,0 @@ -This demo illustrates how to write a swing application which invokes -ordinary (twoway) operations, as well as how to make oneway, datagram, -secure, and batched invocations. - -To run the demo, first start the hello server: - -$ cd ../hello -$ java -jar build/libs/server.jar - -In a separate window, start the swing client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/swing/build.gradle b/java/demo/Ice/swing/build.gradle deleted file mode 100644 index 8df263ba568..00000000000 --- a/java/demo/Ice/swing/build.gradle +++ /dev/null @@ -1,35 +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. -// -// ********************************************************************** - -slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - compile localDependency("ice") - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } -} - -// Don't create the default jar. -jar.enabled = false - -demoJar("client") diff --git a/java/demo/Ice/swing/config.client b/java/demo/Ice/swing/config.client deleted file mode 100644 index eff6cc7fa50..00000000000 --- a/java/demo/Ice/swing/config.client +++ /dev/null @@ -1,25 +0,0 @@ -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Password=password -IceSSL.Keystore=client.jks diff --git a/java/demo/Ice/throughput/.externalToolBuilders/demo.Ice.throughput.slice.launch b/java/demo/Ice/throughput/.externalToolBuilders/demo.Ice.throughput.slice.launch deleted file mode 100644 index 353bfb283ff..00000000000 --- a/java/demo/Ice/throughput/.externalToolBuilders/demo.Ice.throughput.slice.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.Ice.throughput"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.throughput/Throughput.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.throughput/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/Ice/throughput/Client.java b/java/demo/Ice/throughput/Client.java deleted file mode 100644 index a9c18f39242..00000000000 --- a/java/demo/Ice/throughput/Client.java +++ /dev/null @@ -1,476 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private static void - menu() - { - System.out.println( - "usage:\n" + - "\n" + - "toggle type of data to send:\n" + - "1: sequence of bytes (default)\n" + - "2: sequence of strings (\"hello\")\n" + - "3: sequence of structs with a string (\"hello\") and a double\n" + - "4: sequence of structs with two ints and a double\n" + - "\n" + - "select test to run:\n" + - "t: Send sequence as twoway\n" + - "o: Send sequence as oneway\n" + - "r: Receive sequence\n" + - "e: Echo (send and receive) sequence\n" + - "\n" + - "other commands:\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); - } - - @Override - 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()); - - ThroughputPrx throughput = ThroughputPrxHelper.checkedCast(communicator().propertyToProxy("Throughput.Proxy")); - if(throughput == null) - { - System.err.println("invalid proxy"); - return 1; - } - ThroughputPrx throughputOneway = ThroughputPrxHelper.uncheckedCast(throughput.ice_oneway()); - - byte[] byteSeq = new byte[ByteSeqSize.value]; - - String[] stringSeq = new String[StringSeqSize.value]; - for(int i = 0; i < StringSeqSize.value; ++i) - { - stringSeq[i] = "hello"; - } - - StringDouble[] structSeq = new StringDouble[StringDoubleSeqSize.value]; - for(int i = 0; i < StringDoubleSeqSize.value; ++i) - { - structSeq[i] = new StringDouble(); - structSeq[i].s = "hello"; - structSeq[i].d = 3.14; - } - - Fixed[] fixedSeq = new Fixed[FixedSeqSize.value]; - for(int i = 0; i < FixedSeqSize.value; ++i) - { - fixedSeq[i] = new Fixed(); - fixedSeq[i].i = 0; - fixedSeq[i].j = 0; - fixedSeq[i].d = 0; - } - - // - // A method needs to be invoked thousands of times before the - // JIT compiler will convert it to native code. To ensure an - // accurate throughput measurement, we need to "warm up" the - // JIT compiler. - // - { - byte[] emptyBytes= new byte[1]; - String[] emptyStrings = new String[1]; - StringDouble[] emptyStructs = new StringDouble[1]; - emptyStructs[0] = new StringDouble(); - Fixed[] emptyFixed = new Fixed[1]; - emptyFixed[0] = new Fixed(); - - throughput.startWarmup(); - - System.out.print("warming up the client/server..."); - System.out.flush(); - for(int i = 0; i < 10000; i++) - { - throughput.sendByteSeq(emptyBytes); - throughput.sendStringSeq(emptyStrings); - throughput.sendStructSeq(emptyStructs); - throughput.sendFixedSeq(emptyFixed); - - throughput.recvByteSeq(); - throughput.recvStringSeq(); - throughput.recvStructSeq(); - throughput.recvFixedSeq(); - - throughput.echoByteSeq(emptyBytes); - throughput.echoStringSeq(emptyStrings); - throughput.echoStructSeq(emptyStructs); - throughput.echoFixedSeq(emptyFixed); - } - throughput.endWarmup(); - - System.out.println(" ok"); - } - - menu(); - - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - char currentType = '1'; - int seqSize = ByteSeqSize.value; - - // Initial ping to setup the connection. - throughput.ice_ping(); - - String line = null; - do - { - try - { - System.out.print("==> "); - System.out.flush(); - line = in.readLine(); - if(line == null) - { - break; - } - - long tmsec = System.currentTimeMillis(); - final int repetitions = 100; - - if(line.equals("1") || line.equals("2") || line.equals("3") || line.equals("4")) - { - currentType = line.charAt(0); - - switch(currentType) - { - case '1': - { - System.out.println("using byte sequences"); - seqSize = ByteSeqSize.value; - break; - } - - case '2': - { - System.out.println("using string sequences"); - seqSize = StringSeqSize.value; - break; - } - - case '3': - { - System.out.println("using variable-length struct sequences"); - seqSize = StringDoubleSeqSize.value; - break; - } - - case '4': - { - System.out.println("using fixed-length struct sequences"); - seqSize = FixedSeqSize.value; - break; - } - } - } - else if(line.equals("t") || line.equals("o") || line.equals("r") || line.equals("e")) - { - char c = line.charAt(0); - - switch(c) - { - case 't': - case 'o': - { - System.out.print("sending"); - break; - } - - case 'r': - { - System.out.print("receiving"); - break; - } - - case 'e': - { - System.out.print("sending and receiving"); - break; - } - } - - System.out.print(" " + repetitions); - switch(currentType) - { - case '1': - { - System.out.print(" byte"); - break; - } - - case '2': - { - System.out.print(" string"); - break; - } - - case '3': - { - System.out.print(" variable-length struct"); - break; - } - - case '4': - { - System.out.print(" fixed-length struct"); - break; - } - } - - System.out.print(" sequences of size " + seqSize); - - if(c == 'o') - { - System.out.print(" as oneway"); - } - - System.out.println("..."); - - for(int i = 0; i < repetitions; ++i) - { - switch(currentType) - { - case '1': - { - switch(c) - { - case 't': - { - throughput.sendByteSeq(byteSeq); - break; - } - - case 'o': - { - throughputOneway.sendByteSeq(byteSeq); - break; - } - - case 'r': - { - throughput.recvByteSeq(); - break; - } - - case 'e': - { - throughput.echoByteSeq(byteSeq); - break; - } - } - break; - } - - case '2': - { - switch(c) - { - case 't': - { - throughput.sendStringSeq(stringSeq); - break; - } - - case 'o': - { - throughputOneway.sendStringSeq(stringSeq); - break; - } - - case 'r': - { - throughput.recvStringSeq(); - break; - } - - case 'e': - { - throughput.echoStringSeq(stringSeq); - break; - } - } - break; - } - - case '3': - { - switch(c) - { - case 't': - { - throughput.sendStructSeq(structSeq); - break; - } - - case 'o': - { - throughputOneway.sendStructSeq(structSeq); - break; - } - - case 'r': - { - throughput.recvStructSeq(); - break; - } - - case 'e': - { - throughput.echoStructSeq(structSeq); - break; - } - } - break; - } - - case '4': - { - switch(c) - { - case 't': - { - throughput.sendFixedSeq(fixedSeq); - break; - } - - case 'o': - { - throughputOneway.sendFixedSeq(fixedSeq); - break; - } - - case 'r': - { - throughput.recvFixedSeq(); - break; - } - - case 'e': - { - throughput.echoFixedSeq(fixedSeq); - break; - } - } - break; - } - } - } - - double dmsec = System.currentTimeMillis() - tmsec; - System.out.println("time for " + repetitions + " sequences: " + dmsec + "ms"); - System.out.println("time per sequence: " + dmsec / repetitions + "ms"); - int wireSize = 0; - switch(currentType) - { - case '1': - { - wireSize = 1; - break; - } - - case '2': - { - wireSize = stringSeq[0].length(); - break; - } - - case '3': - { - wireSize = structSeq[0].s.length(); - wireSize += 8; // Size of double on the wire. - break; - } - - case '4': - { - wireSize = 16; // Size of two ints and a double on the wire. - break; - } - } - double mbit = repetitions * seqSize * wireSize * 8.0 / dmsec / 1000.0; - if(c == 'e') - { - mbit *= 2; - } - System.out.println("throughput: " + new java.text.DecimalFormat("#.##").format(mbit) + "Mbps"); - } - else if(line.equals("s")) - { - throughput.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/throughput/README b/java/demo/Ice/throughput/README deleted file mode 100644 index 318e877d575..00000000000 --- a/java/demo/Ice/throughput/README +++ /dev/null @@ -1,16 +0,0 @@ -A simple throughput demo that allows you to send sequences of various -types between client and server and to measure the maximum bandwidth -that can be achieved using serialized synchronous requests. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar - -The performance for byte sequences is expected to be greater than -for other types because the cost of marshaling and unmarshaling is -lower than for more complex types. With byte sequences there is no -need to allocate and deallocate objects, which adds overhead. diff --git a/java/demo/Ice/throughput/Server.java b/java/demo/Ice/throughput/Server.java deleted file mode 100644 index a6a26a5847a..00000000000 --- a/java/demo/Ice/throughput/Server.java +++ /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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Throughput"); - adapter.add(new ThroughputI(), communicator().stringToIdentity("throughput")); - 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/throughput/Throughput.ice b/java/demo/Ice/throughput/Throughput.ice deleted file mode 100644 index 45d2ec4c40b..00000000000 --- a/java/demo/Ice/throughput/Throughput.ice +++ /dev/null @@ -1,63 +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 Demo -{ - -sequence<byte> ByteSeq; -const int ByteSeqSize = 500000; - -sequence<string> StringSeq; -const int StringSeqSize = 50000; - -struct StringDouble -{ - string s; - double d; -}; -sequence<StringDouble> StringDoubleSeq; -const int StringDoubleSeqSize = 50000; - -struct Fixed -{ - int i; - int j; - double d; -}; -sequence<Fixed> FixedSeq; -const int FixedSeqSize = 50000; - -interface Throughput -{ - bool needsWarmup(); - void startWarmup(); - void endWarmup(); - - void sendByteSeq(ByteSeq seq); - ByteSeq recvByteSeq(); - ByteSeq echoByteSeq(ByteSeq seq); - - void sendStringSeq(StringSeq seq); - StringSeq recvStringSeq(); - StringSeq echoStringSeq(StringSeq seq); - - void sendStructSeq(StringDoubleSeq seq); - StringDoubleSeq recvStructSeq(); - StringDoubleSeq echoStructSeq(StringDoubleSeq seq); - - void sendFixedSeq(FixedSeq seq); - FixedSeq recvFixedSeq(); - FixedSeq echoFixedSeq(FixedSeq seq); - - void shutdown(); -}; - -}; diff --git a/java/demo/Ice/throughput/ThroughputI.java b/java/demo/Ice/throughput/ThroughputI.java deleted file mode 100644 index f4c26477d4c..00000000000 --- a/java/demo/Ice/throughput/ThroughputI.java +++ /dev/null @@ -1,193 +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 Demo.*; - -public final class ThroughputI extends _ThroughputDisp -{ - public - ThroughputI() - { - _byteSeq = new byte[ByteSeqSize.value]; - - _stringSeq = new String[StringSeqSize.value]; - for(int i = 0; i < StringSeqSize.value; ++i) - { - _stringSeq[i] = "hello"; - } - - _structSeq = new StringDouble[StringDoubleSeqSize.value]; - for(int i = 0; i < StringDoubleSeqSize.value; ++i) - { - _structSeq[i] = new StringDouble(); - _structSeq[i].s = "hello"; - _structSeq[i].d = 3.14; - } - - _fixedSeq = new Fixed[FixedSeqSize.value]; - for(int i = 0; i < FixedSeqSize.value; ++i) - { - _fixedSeq[i] = new Fixed(); - _fixedSeq[i].i = 0; - _fixedSeq[i].j = 0; - _fixedSeq[i].d = 0; - } - } - - @Override - public boolean - needsWarmup(Ice.Current current) - { - _warmup = false; - return _needsWarmup; - } - - @Override - public void - startWarmup(Ice.Current current) - { - _warmup = true; - } - - @Override - public void - endWarmup(Ice.Current current) - { - _warmup = false; - _needsWarmup = false; - } - - @Override - public void - sendByteSeq(byte[] seq, Ice.Current current) - { - } - - @Override - public byte[] - recvByteSeq(Ice.Current current) - { - if(_warmup) - { - return _emptyByteSeq; - } - else - { - return _byteSeq; - } - } - - @Override - public byte[] - echoByteSeq(byte[] seq, Ice.Current current) - { - return seq; - } - - @Override - public void - sendStringSeq(String[] seq, Ice.Current current) - { - } - - @Override - public String[] - recvStringSeq(Ice.Current current) - { - if(_warmup) - { - return _emptyStringSeq; - } - else - { - return _stringSeq; - } - } - - @Override - public String[] - echoStringSeq(String[] seq, Ice.Current current) - { - return seq; - } - - @Override - public void - sendStructSeq(StringDouble[] seq, Ice.Current current) - { - } - - @Override - public StringDouble[] - recvStructSeq(Ice.Current current) - { - if(_warmup) - { - return _emptyStructSeq; - } - else - { - return _structSeq; - } - } - - @Override - public StringDouble[] - echoStructSeq(StringDouble[] seq, Ice.Current current) - { - return seq; - } - - @Override - public void - sendFixedSeq(Fixed[] seq, Ice.Current current) - { - } - - @Override - public Fixed[] - recvFixedSeq(Ice.Current current) - { - if(_warmup) - { - return _emptyFixedSeq; - } - else - { - return _fixedSeq; - } - } - - @Override - public Fixed[] - echoFixedSeq(Fixed[] seq, Ice.Current current) - { - return seq; - } - - @Override - public void - shutdown(Ice.Current current) - { - current.adapter.getCommunicator().shutdown(); - } - - private byte[] _byteSeq; - private String[] _stringSeq; - private StringDouble[] _structSeq; - private Fixed[] _fixedSeq; - - private byte[] _emptyByteSeq = new byte[0]; - private String[] _emptyStringSeq = new String[0]; - private StringDouble[] _emptyStructSeq = new StringDouble[0]; - private Fixed[] _emptyFixedSeq = new Fixed[0]; - - private boolean _needsWarmup = true; - private boolean _warmup = false; -} diff --git a/java/demo/Ice/throughput/config.client b/java/demo/Ice/throughput/config.client deleted file mode 100644 index 1097feb8518..00000000000 --- a/java/demo/Ice/throughput/config.client +++ /dev/null @@ -1,38 +0,0 @@ -# -# The client reads this property to create the reference to the -# "Throughput" object in the server. -# -Throughput.Proxy=throughput:tcp -p 10000 -#Throughput.Proxy=throughput:ssl -p 10001 - -# -# Uncomment to use the WebSocket transports instead. -# -#Throughput.Proxy=throughput:ws -p 10002 -#Throughput.Proxy=throughput:wss -p 10003 - -# -# Only connect to the localhost interface by default. -# -Ice.Default.Host=localhost - -# -# Disable client-side ACM. -# -Ice.ACM.Client.Timeout=0 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -p 10004 -Ice.Admin.InstanceName=client -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/Ice/throughput/config.server b/java/demo/Ice/throughput/config.server deleted file mode 100644 index 83a40fcc61b..00000000000 --- a/java/demo/Ice/throughput/config.server +++ /dev/null @@ -1,38 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Throughput". The following line sets the endpoints for this adapter. -# -Throughput.Endpoints=tcp -p 10000:ssl -p 10001:ws -p 10002:wss -p 10003 - - -# Only listen on the localhost interface by default. -# -Ice.Default.Host=localhost - -# -# For secure WebSocket (WSS) clients and Windows Store App clients, -# you should disable this property. JavaScript browser clients and -# Windows Store App clients don't use client-side authentication. -# -#IceSSL.VerifyPeer=0 - -# -# Warn about connection exceptions -# -Ice.Warn.Connections=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10002 -Ice.Admin.InstanceName=server -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/Ice/throughput/expect.py b/java/demo/Ice/throughput/expect.py deleted file mode 100755 index 6880e3c12ea..00000000000 --- a/java/demo/Ice/throughput/expect.py +++ /dev/null @@ -1,29 +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 - -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 -from demoscript.Ice import throughput - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar') - -throughput.run(client, server) diff --git a/java/demo/Ice/value/.externalToolBuilders/demo.Ice.value.slice.launch b/java/demo/Ice/value/.externalToolBuilders/demo.Ice.value.slice.launch deleted file mode 100644 index 32704b5b7e4..00000000000 --- a/java/demo/Ice/value/.externalToolBuilders/demo.Ice.value.slice.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="${project}"/> -<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.Ice.value"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.Ice.value/Value.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.Ice.value/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/Ice/value/Client.java b/java/demo/Ice/value/Client.java deleted file mode 100644 index 683fcc10a5f..00000000000 --- a/java/demo/Ice/value/Client.java +++ /dev/null @@ -1,221 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private static void - readline(java.io.BufferedReader in) - { - try - { - in.readLine(); - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - } - } - - @Override - 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()); - - InitialPrx initial = InitialPrxHelper.checkedCast(communicator().propertyToProxy("Initial.Proxy")); - if(initial == null) - { - System.err.println("invalid object reference"); - return 1; - } - - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - System.out.println(); - System.out.println("Let's first transfer a simple object, for a class without"); - System.out.println("operations, and print its contents. No factory is required"); - System.out.println("for this."); - System.out.println("[press enter]"); - readline(in); - - Simple simple = initial.getSimple(); - System.out.println("==> " + simple.message); - - System.out.println(); - System.out.println("Yes, this worked. Now let's try to transfer an object for a class"); - System.out.println("with operations as type Demo.Printer, without installing a factory first."); - System.out.println("This should give us a `no factory' exception."); - System.out.println("[press enter]"); - readline(in); - - PrinterHolder printer = new PrinterHolder(); - PrinterPrxHolder printerProxy = new PrinterPrxHolder(); - try - { - initial.getPrinter(printer, printerProxy); - System.err.println("Did not get the expected NoObjectFactoryException!"); - System.exit(1); - } - catch(Ice.NoObjectFactoryException ex) - { - System.out.println("==> " + ex); - } - - System.out.println(); - System.out.println("Yep, that's what we expected. Now let's try again, but with"); - System.out.println("installing an appropriate factory first. If successful, we print"); - System.out.println("the object's content."); - System.out.println("[press enter]"); - readline(in); - - Ice.ObjectFactory factory = new ObjectFactory(); - communicator().addObjectFactory(factory, Demo.Printer.ice_staticId()); - - initial.getPrinter(printer, printerProxy); - System.out.println("==> " + printer.value.message); - - System.out.println(); - System.out.println("Cool, it worked! Let's try calling the printBackwards() method"); - System.out.println("on the object we just received locally."); - System.out.println("[press enter]"); - readline(in); - - System.out.print("==> "); - printer.value.printBackwards(); - - System.out.println(); - System.out.println("Now we call the same method, but on the remote object. Watch the"); - System.out.println("server's output."); - System.out.println("[press enter]"); - readline(in); - - printerProxy.value.printBackwards(); - - System.out.println(); - System.out.println("Next, we transfer a derived object from the server as a base"); - System.out.println("object. Since we haven't yet installed a factory for the derived"); - System.out.println("class, the derived class (Demo.DerivedPrinter) is sliced"); - System.out.println("to its base class (Demo.Printer)."); - System.out.println("[press enter]"); - readline(in); - - 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.ice_staticId())); - - System.out.println(); - System.out.println("Now we install a factory for the derived class, and try again."); - System.out.println("Because we receive the derived object as a base object,"); - System.out.println("we need to do a class cast to get from the base to the derived object."); - System.out.println("[press enter]"); - readline(in); - - communicator().addObjectFactory(factory, Demo.DerivedPrinter.ice_staticId()); - - derivedAsBase = initial.getDerivedPrinter(); - DerivedPrinter derived = (Demo.DerivedPrinter)derivedAsBase; - - System.out.println("==> class cast to derived object succeeded"); - System.out.println("==> The type ID of the received object is \"" + derived.ice_id() + "\""); - - System.out.println(); - System.out.println("Let's print the message contained in the derived object, and"); - System.out.println("call the operation printUppercase() on the derived object"); - System.out.println("locally."); - System.out.println("[press enter]"); - readline(in); - - System.out.println("==> " + derived.derivedMessage); - System.out.print("==> "); - derived.printUppercase(); - - System.out.println(); - System.out.println("Now let's make sure that slice is preserved with [\"preserve-slice\"]"); - System.out.println("metadata. We create a derived type on the client and pass it to the"); - System.out.println("server, which does not have a factory for the derived type. We do a"); - System.out.println("class cast to make sure we can still access the derived type when"); - System.out.println("it has been returned from the server."); - System.out.println("[press enter]"); - readline(in); - - ClientPrinter clientp = new ClientPrinterI(); - clientp.message = "a message 4 u"; - communicator().addObjectFactory(factory, Demo.ClientPrinter.ice_staticId()); - - derivedAsBase = initial.updatePrinterMessage(clientp); - clientp = (Demo.ClientPrinter)derivedAsBase; - System.out.println("==> " + clientp.message); - - System.out.println(); - System.out.println("Finally, we try the same again, but instead of returning the"); - System.out.println("derived object, we throw an exception containing the derived"); - System.out.println("object."); - System.out.println("[press enter]"); - readline(in); - - try - { - initial.throwDerivedPrinter(); - } - catch(DerivedPrinterException ex) - { - derived = ex.derived; - assert(derived != null); - } - - System.out.println("==> " + derived.derivedMessage); - System.out.print("==> "); - derived.printUppercase(); - - System.out.println(); - System.out.println("That's it for this demo. Have fun with Ice!"); - - initial.shutdown(); - - 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/value/ClientPrinterI.java b/java/demo/Ice/value/ClientPrinterI.java deleted file mode 100644 index 677a8d1782a..00000000000 --- a/java/demo/Ice/value/ClientPrinterI.java +++ /dev/null @@ -1,27 +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 Demo.*; - -class ClientPrinterI extends ClientPrinter -{ - @Override - public void - printBackwards(Ice.Current current) - { - char[] arr = message.toCharArray(); - for(int i = 0; i < arr.length / 2; i++) - { - char tmp = arr[arr.length - i - 1]; - arr[arr.length - i - 1] = arr[i]; - arr[i] = tmp; - } - System.out.println(new String(arr)); - } -} diff --git a/java/demo/Ice/value/DerivedPrinterI.java b/java/demo/Ice/value/DerivedPrinterI.java deleted file mode 100644 index 632f5d92f16..00000000000 --- a/java/demo/Ice/value/DerivedPrinterI.java +++ /dev/null @@ -1,34 +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 Demo.*; - -class DerivedPrinterI extends DerivedPrinter -{ - @Override - public void - printBackwards(Ice.Current current) - { - char[] arr = message.toCharArray(); - for(int i = 0; i < arr.length / 2; i++) - { - char tmp = arr[arr.length - i - 1]; - arr[arr.length - i - 1] = arr[i]; - arr[i] = tmp; - } - System.out.println(new String(arr)); - } - - @Override - public void - printUppercase(Ice.Current current) - { - System.out.println(derivedMessage.toUpperCase()); - } -} diff --git a/java/demo/Ice/value/InitialI.java b/java/demo/Ice/value/InitialI.java deleted file mode 100644 index f273ce6be80..00000000000 --- a/java/demo/Ice/value/InitialI.java +++ /dev/null @@ -1,77 +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 Demo.*; - -class InitialI extends _InitialDisp -{ - InitialI(Ice.ObjectAdapter adapter) - { - _simple.message = "a message 4 u"; - - _printer.message = "Ice rulez!"; - _printerProxy = PrinterPrxHelper.uncheckedCast(adapter.addWithUUID(_printer)); - - _derivedPrinter.message = _printer.message; - _derivedPrinter.derivedMessage = "a derived message 4 u"; - adapter.addWithUUID(_derivedPrinter); - } - - @Override - public Simple - getSimple(Ice.Current current) - { - return _simple; - } - - @Override - public void - getPrinter(PrinterHolder impl, PrinterPrxHolder proxy, Ice.Current current) - { - impl.value = _printer; - proxy.value = _printerProxy; - } - - @Override - public Printer - getDerivedPrinter(Ice.Current current) - { - return _derivedPrinter; - } - - @Override - public Printer - updatePrinterMessage(Printer printer, Ice.Current current) - { - printer.message = "a modified message 4 u"; - return printer; - } - - @Override - public void - throwDerivedPrinter(Ice.Current current) - throws DerivedPrinterException - { - DerivedPrinterException ex = new DerivedPrinterException(); - ex.derived = _derivedPrinter; - throw ex; - } - - @Override - public void - shutdown(Ice.Current current) - { - current.adapter.getCommunicator().shutdown(); - } - - private Simple _simple = new Simple(); - private Printer _printer = new PrinterI(); - private PrinterPrx _printerProxy; - private DerivedPrinter _derivedPrinter = new DerivedPrinterI(); -} diff --git a/java/demo/Ice/value/ObjectFactory.java b/java/demo/Ice/value/ObjectFactory.java deleted file mode 100644 index 02182af54bf..00000000000 --- a/java/demo/Ice/value/ObjectFactory.java +++ /dev/null @@ -1,41 +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. -// -// ********************************************************************** - -class ObjectFactory implements Ice.ObjectFactory -{ - @Override - public Ice.Object - create(String type) - { - if(type.equals("::Demo::Printer")) - { - return new PrinterI(); - } - - if(type.equals("::Demo::DerivedPrinter")) - { - return new DerivedPrinterI(); - } - - if(type.equals("::Demo::ClientPrinter")) - { - return new ClientPrinterI(); - } - - assert(false); - return null; - } - - @Override - public void - destroy() - { - // Nothing to do - } -} diff --git a/java/demo/Ice/value/PrinterI.java b/java/demo/Ice/value/PrinterI.java deleted file mode 100644 index 7a64920ec14..00000000000 --- a/java/demo/Ice/value/PrinterI.java +++ /dev/null @@ -1,27 +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 Demo.*; - -class PrinterI extends Printer -{ - @Override - public void - printBackwards(Ice.Current current) - { - char[] arr = message.toCharArray(); - for(int i = 0; i < arr.length / 2; i++) - { - char tmp = arr[arr.length - i - 1]; - arr[arr.length - i - 1] = arr[i]; - arr[i] = tmp; - } - System.out.println(new String(arr)); - } -} diff --git a/java/demo/Ice/value/README b/java/demo/Ice/value/README deleted file mode 100644 index 83843fe4902..00000000000 --- a/java/demo/Ice/value/README +++ /dev/null @@ -1,10 +0,0 @@ -This demo shows how to use classes, class factories, and the -difference between local and remote invocations of class operations. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Ice/value/Server.java b/java/demo/Ice/value/Server.java deleted file mode 100644 index a35cfa49664..00000000000 --- a/java/demo/Ice/value/Server.java +++ /dev/null @@ -1,40 +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. -// -// ********************************************************************** - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectFactory factory = new ObjectFactory(); - communicator().addObjectFactory(factory, Demo.Printer.ice_staticId()); - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Value"); - Ice.Object object = new InitialI(adapter); - adapter.add(object, communicator().stringToIdentity("initial")); - 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/value/Value.ice b/java/demo/Ice/value/Value.ice deleted file mode 100644 index 022c9c4ccc6..00000000000 --- a/java/demo/Ice/value/Value.ice +++ /dev/null @@ -1,53 +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 Demo -{ - -class Simple -{ - string message; -}; - -["preserve-slice"] -class Printer -{ - string message; - void printBackwards(); -}; - -["cpp:virtual"]class DerivedPrinter extends Printer -{ - string derivedMessage; - void printUppercase(); -}; - -["cpp:virtual"]class ClientPrinter extends Printer -{ -}; - -exception DerivedPrinterException -{ - DerivedPrinter derived; -}; - -interface Initial -{ - Simple getSimple(); - void getPrinter(out Printer impl, out Printer* proxy); - ["format:sliced"] Printer getDerivedPrinter(); - ["format:sliced"] Printer updatePrinterMessage(Printer impl); - void throwDerivedPrinter() throws DerivedPrinterException; - void shutdown(); -}; - -}; - diff --git a/java/demo/Ice/value/config.client b/java/demo/Ice/value/config.client deleted file mode 100644 index 5fa5e29c58b..00000000000 --- a/java/demo/Ice/value/config.client +++ /dev/null @@ -1,18 +0,0 @@ -# -# The client reads this property to create the reference to the -# "Initial" object in the server. -# -Initial.Proxy=initial:default -h localhost -p 10000 - -# -# Warn about connection exceptions -# -Ice.Warn.Connections=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password diff --git a/java/demo/Ice/value/config.server b/java/demo/Ice/value/config.server deleted file mode 100644 index 43287b0ce85..00000000000 --- a/java/demo/Ice/value/config.server +++ /dev/null @@ -1,19 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Value". The following line sets the endpoints for this -# adapter. -# -Value.Endpoints=default -h localhost -p 10000 - -# -# Warn about connection exceptions -# -Ice.Warn.Connections=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password diff --git a/java/demo/Ice/value/expect.py b/java/demo/Ice/value/expect.py deleted file mode 100755 index 69c48dae4fe..00000000000 --- a/java/demo/Ice/value/expect.py +++ /dev/null @@ -1,29 +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 - -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 -from demoscript.Ice import value - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar') - -value.run(client, server) diff --git a/java/demo/IceBox/README b/java/demo/IceBox/README deleted file mode 100644 index 41f1417ede6..00000000000 --- a/java/demo/IceBox/README +++ /dev/null @@ -1,5 +0,0 @@ -Demos in this directory: - -- hello - - Illustrates how to create an IceBox service. diff --git a/java/demo/IceBox/hello/.externalToolBuilders/demo.IceBox.hello.slice.launch b/java/demo/IceBox/hello/.externalToolBuilders/demo.IceBox.hello.slice.launch deleted file mode 100644 index 9863613c312..00000000000 --- a/java/demo/IceBox/hello/.externalToolBuilders/demo.IceBox.hello.slice.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="${project}"/> -<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.IceBox.hello"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.IceBox.hello/Hello.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.IceBox.hello/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/IceBox/hello/Client.java b/java/demo/IceBox/hello/Client.java deleted file mode 100644 index f941c513f23..00000000000 --- a/java/demo/IceBox/hello/Client.java +++ /dev/null @@ -1,151 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private void - menu() - { - System.out.println( - "usage:\n" + - "t: send greeting as twoway\n" + - "o: send greeting as oneway\n" + - "O: send greeting as batch oneway\n" + - "d: send greeting as datagram\n" + - "D: send greeting as batch datagram\n" + - "f: flush all batch requests\n" + - "x: exit\n" + - "?: help\n"); - } - - @Override - 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 twoway = HelloPrxHelper.checkedCast( - communicator().propertyToProxy("Hello.Proxy").ice_twoway().ice_timeout(-1).ice_secure(false)); - if(twoway == null) - { - System.err.println("invalid object reference"); - return 1; - } - HelloPrx oneway = HelloPrxHelper.uncheckedCast(twoway.ice_oneway()); - HelloPrx batchOneway = HelloPrxHelper.uncheckedCast(twoway.ice_batchOneway()); - HelloPrx datagram = HelloPrxHelper.uncheckedCast(twoway.ice_datagram()); - HelloPrx batchDatagram = HelloPrxHelper.uncheckedCast(twoway.ice_batchDatagram()); - - 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")) - { - twoway.sayHello(); - } - else if(line.equals("o")) - { - oneway.sayHello(); - } - else if(line.equals("O")) - { - batchOneway.sayHello(); - } - else if(line.equals("d")) - { - datagram.sayHello(); - } - else if(line.equals("D")) - { - batchDatagram.sayHello(); - } - else if(line.equals("f")) - { - batchOneway.ice_flushBatchRequests(); - batchDatagram.ice_flushBatchRequests(); - } - 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/IceBox/hello/Hello.ice b/java/demo/IceBox/hello/Hello.ice deleted file mode 100644 index 0289edf4741..00000000000 --- a/java/demo/IceBox/hello/Hello.ice +++ /dev/null @@ -1,20 +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 Demo -{ - -interface Hello -{ - idempotent void sayHello(); -}; - -}; diff --git a/java/demo/IceBox/hello/HelloI.java b/java/demo/IceBox/hello/HelloI.java deleted file mode 100644 index fba7024dc8a..00000000000 --- a/java/demo/IceBox/hello/HelloI.java +++ /dev/null @@ -1,20 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - @Override - public void - sayHello(Ice.Current current) - { - System.out.println("Hello World!"); - } -} diff --git a/java/demo/IceBox/hello/HelloServiceI.java b/java/demo/IceBox/hello/HelloServiceI.java deleted file mode 100644 index 909735baf7e..00000000000 --- a/java/demo/IceBox/hello/HelloServiceI.java +++ /dev/null @@ -1,29 +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. -// -// ********************************************************************** - -public class HelloServiceI implements IceBox.Service -{ - @Override - public void - start(String name, Ice.Communicator communicator, String[] args) - { - _adapter = communicator.createObjectAdapter(name); - _adapter.add(new HelloI(), communicator.stringToIdentity("hello")); - _adapter.activate(); - } - - @Override - public void - stop() - { - _adapter.destroy(); - } - - private Ice.ObjectAdapter _adapter; -} diff --git a/java/demo/IceBox/hello/README b/java/demo/IceBox/hello/README deleted file mode 100644 index e6f7bef9c04..00000000000 --- a/java/demo/IceBox/hello/README +++ /dev/null @@ -1,12 +0,0 @@ -To run this demo, open two terminal windows. In the first window, -start the IceBox server: - -$ java IceBox.Server --Ice.Config=config.icebox - -In the second window, run the client: - -$ java -jar build/libs/client.jar - -To shut down IceBox, use IceBox.Admin: - -$ java IceBox.Admin --Ice.Config=config.admin shutdown diff --git a/java/demo/IceBox/hello/build.gradle b/java/demo/IceBox/hello/build.gradle deleted file mode 100644 index 35af1f20fcc..00000000000 --- a/java/demo/IceBox/hello/build.gradle +++ /dev/null @@ -1,54 +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. -// -// ********************************************************************** - -slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - compile localDependency("ice") - compile localDependency("icebox") - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } -} - -// Don't create the default jar. -jar.enabled = false - -demoJar("client") - -task serverJar(type: Jar) { - version = "" - baseName = "server" - from(sourceSets.main.output) { - include "**" - } -} - -serverJar { - manifest { - attributes("Class-Path": configurations.compile.resolve().collect { it.toURI() }.join(' ')) - } -} - -artifacts { - archives serverJar; -} diff --git a/java/demo/IceBox/hello/config.admin b/java/demo/IceBox/hello/config.admin deleted file mode 100644 index a52736106f4..00000000000 --- a/java/demo/IceBox/hello/config.admin +++ /dev/null @@ -1,6 +0,0 @@ -# -# Proxy to the IceBox ServiceManager: -# - -IceBoxAdmin.ServiceManager.Proxy=DemoIceBox/admin -f IceBox.ServiceManager:tcp -p 9996 -h localhost - diff --git a/java/demo/IceBox/hello/config.client b/java/demo/IceBox/hello/config.client deleted file mode 100644 index 559a915067e..00000000000 --- a/java/demo/IceBox/hello/config.client +++ /dev/null @@ -1,28 +0,0 @@ -# -# The client reads this property to create the reference to the -# "hello" object in the server. -# -Hello.Proxy=hello:tcp -h localhost -p 10000:udp -h localhost -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/IceBox/hello/config.icebox b/java/demo/IceBox/hello/config.icebox deleted file mode 100644 index 4be302dba65..00000000000 --- a/java/demo/IceBox/hello/config.icebox +++ /dev/null @@ -1,37 +0,0 @@ -# -# The IceBox ServiceManager is provided as a facet of the Ice.Admin object. -# - -# -# Enable Ice.Admin object: -# -Ice.Admin.Endpoints=tcp -p 9996 -h localhost -Ice.Admin.InstanceName=DemoIceBox - -# -# The hello service -# -IceBox.Service.Hello=build/libs/server.jar:HelloServiceI --Ice.Config=config.service - -# -# 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/IceBox/hello/config.service b/java/demo/IceBox/hello/config.service deleted file mode 100644 index dbb53125115..00000000000 --- a/java/demo/IceBox/hello/config.service +++ /dev/null @@ -1,29 +0,0 @@ -# -# The server creates one single object adapter with the name of -# the service. The following line sets the endpoints for this -# adapter. -# -Hello.Endpoints=tcp -h localhost -p 10000:udp -h localhost -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/IceBox/hello/expect.py b/java/demo/IceBox/hello/expect.py deleted file mode 100755 index 9952777526a..00000000000 --- a/java/demo/IceBox/hello/expect.py +++ /dev/null @@ -1,36 +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 - -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 -from demoscript.IceBox import hello - -# Override the service load line. -if Util.defaultHost: - args = ' --IceBox.Service.Hello="build/libs/server.jar:HelloServiceI --Ice.Config=config.service %s"' % Util.defaultHost -else: - args = '' - -server = Util.spawn('java -cp \"%s\" IceBox.Server --Ice.Config=config.icebox --Ice.PrintAdapterReady %s' % (Util.getIceBoxClassPath(), args)) -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar') -client.expect('.*==>') - -hello.run(client, server) diff --git a/java/demo/IceDiscovery/README b/java/demo/IceDiscovery/README deleted file mode 100644 index 1baa94c1914..00000000000 --- a/java/demo/IceDiscovery/README +++ /dev/null @@ -1,9 +0,0 @@ -Demos in this directory: - -- hello - - The Ice hello world demo configured to use IceDiscovery - -- replication - - A demo to illustrate how replication is setup with IceDiscovery diff --git a/java/demo/IceDiscovery/build.gradle b/java/demo/IceDiscovery/build.gradle deleted file mode 100644 index 4ff6e786b59..00000000000 --- a/java/demo/IceDiscovery/build.gradle +++ /dev/null @@ -1,42 +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. -// -// ********************************************************************** - -['hello', 'replication'].each { - def name = it - project(":demoIceDiscovery${it.capitalize()}") { - slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } - } - - sourceSets { - main { - java { - srcDir '.' - } - } - } - - dependencies { - compile localDependency("ice") - compile localDependency("icediscovery") - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } - } - - // Don't create the default jar. - jar.enabled = false - - demoJar("client") - demoJar("server") - } -} diff --git a/java/demo/IceDiscovery/hello/.externalToolBuilders/demo.IceDiscovery.hello.slice.launch b/java/demo/IceDiscovery/hello/.externalToolBuilders/demo.IceDiscovery.hello.slice.launch deleted file mode 100644 index 4171cc66ca2..00000000000 --- a/java/demo/IceDiscovery/hello/.externalToolBuilders/demo.IceDiscovery.hello.slice.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="${project}"/> -<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.IceDiscovery.hello"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.IceDiscovery.hello/Hello.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.IceDiscovery.hello/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/IceDiscovery/hello/Client.java b/java/demo/IceDiscovery/hello/Client.java deleted file mode 100644 index 02997b9c854..00000000000 --- a/java/demo/IceDiscovery/hello/Client.java +++ /dev/null @@ -1,239 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private static void - menu() - { - System.out.println( - "usage:\n" + - "t: send greeting as twoway\n" + - "o: send greeting as oneway\n" + - "O: send greeting as batch oneway\n" + - "d: send greeting as datagram\n" + - "D: send greeting as batch datagram\n" + - "f: flush all batch requests\n" + - "T: set a timeout\n" + - "P: set a server delay\n" + - "S: switch secure mode on/off\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); - } - - @Override - 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 twoway = HelloPrxHelper.checkedCast(communicator().stringToProxy("hello")); - if(twoway == null) - { - System.err.println("invalid proxy"); - return 1; - } - HelloPrx oneway = (HelloPrx)twoway.ice_oneway(); - HelloPrx batchOneway = (HelloPrx)twoway.ice_batchOneway(); - HelloPrx datagram = (HelloPrx)twoway.ice_datagram(); - HelloPrx batchDatagram = (HelloPrx)twoway.ice_batchDatagram(); - - boolean secure = false; - int timeout = -1; - int delay = 0; - - 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")) - { - twoway.sayHello(delay); - } - else if(line.equals("o")) - { - oneway.sayHello(delay); - } - else if(line.equals("O")) - { - batchOneway.sayHello(delay); - } - else if(line.equals("d")) - { - if(secure) - { - System.out.println("secure datagrams are not supported"); - } - else - { - datagram.sayHello(delay); - } - } - else if(line.equals("D")) - { - if(secure) - { - System.out.println("secure datagrams are not supported"); - } - else - { - batchDatagram.sayHello(delay); - } - } - else if(line.equals("f")) - { - batchOneway.ice_flushBatchRequests(); - batchDatagram.ice_flushBatchRequests(); - } - else if(line.equals("T")) - { - if(timeout == -1) - { - timeout = 2000; - } - else - { - timeout = -1; - } - - twoway = (HelloPrx)twoway.ice_invocationTimeout(timeout); - oneway = (HelloPrx)oneway.ice_invocationTimeout(timeout); - batchOneway = (HelloPrx)batchOneway.ice_invocationTimeout(timeout); - - if(timeout == -1) - { - System.out.println("timeout is now switched off"); - } - else - { - System.out.println("timeout is now set to 2000ms"); - } - } - else if(line.equals("P")) - { - if(delay == 0) - { - delay = 2500; - } - else - { - delay = 0; - } - - if(delay == 0) - { - System.out.println("server delay is now deactivated"); - } - else - { - System.out.println("server delay is now set to 2500ms"); - } - } - else if(line.equals("S")) - { - secure = !secure; - - twoway = (HelloPrx)twoway.ice_secure(secure); - oneway = (HelloPrx)oneway.ice_secure(secure); - batchOneway = (HelloPrx)batchOneway.ice_secure(secure); - datagram = (HelloPrx)datagram.ice_secure(secure); - batchDatagram = (HelloPrx)batchDatagram.ice_secure(secure); - - if(secure) - { - System.out.println("secure mode is now on"); - } - else - { - System.out.println("secure mode is now off"); - } - } - else if(line.equals("s")) - { - twoway.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/IceDiscovery/hello/Hello.ice b/java/demo/IceDiscovery/hello/Hello.ice deleted file mode 100644 index e33b79c0798..00000000000 --- a/java/demo/IceDiscovery/hello/Hello.ice +++ /dev/null @@ -1,21 +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 Demo -{ - -interface Hello -{ - idempotent void sayHello(int delay); - void shutdown(); -}; - -}; diff --git a/java/demo/IceDiscovery/hello/HelloI.java b/java/demo/IceDiscovery/hello/HelloI.java deleted file mode 100644 index c5afa79d2bc..00000000000 --- a/java/demo/IceDiscovery/hello/HelloI.java +++ /dev/null @@ -1,39 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - @Override - public void - sayHello(int delay, Ice.Current current) - { - if(delay > 0) - { - try - { - Thread.currentThread(); - Thread.sleep(delay); - } - catch(InterruptedException ex1) - { - } - } - System.out.println("Hello World!"); - } - - @Override - public void - shutdown(Ice.Current current) - { - System.out.println("Shutting down..."); - current.adapter.getCommunicator().shutdown(); - } -} diff --git a/java/demo/IceDiscovery/hello/README b/java/demo/IceDiscovery/hello/README deleted file mode 100644 index 2cd4b6d5794..00000000000 --- a/java/demo/IceDiscovery/hello/README +++ /dev/null @@ -1,13 +0,0 @@ -This demo is the Ice hello world demo. - -To run the demo, first start the server: - -$ java -jar build/libs/server.jar - -In a separate window, start the client: - -$ java -jar build/libs/client.jar - -The client and server use IceDiscovery to enable the location of the -Ice hello object. See the config.server and config.client files for -details on the IceDiscovery configuration.
\ No newline at end of file diff --git a/java/demo/IceDiscovery/hello/Server.java b/java/demo/IceDiscovery/hello/Server.java deleted file mode 100644 index 07da1902f02..00000000000 --- a/java/demo/IceDiscovery/hello/Server.java +++ /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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - 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/IceDiscovery/hello/config.client b/java/demo/IceDiscovery/hello/config.client deleted file mode 100644 index d773aa2ad87..00000000000 --- a/java/demo/IceDiscovery/hello/config.client +++ /dev/null @@ -1,57 +0,0 @@ -# -# Enable the Ice discovery plugin -# -Ice.Plugin.IceDiscovery=IceDiscovery:IceDiscovery.PluginFactory - -# -# Warn about connection exceptions -# -Ice.Warn.Connections=1 - -# -# Locator tracing -# -Ice.Trace.Locator=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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL:IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=client.jks -IceSSL.Password=password - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10003 -Ice.Admin.InstanceName=client -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent - diff --git a/java/demo/IceDiscovery/hello/config.server b/java/demo/IceDiscovery/hello/config.server deleted file mode 100644 index a07b2f70497..00000000000 --- a/java/demo/IceDiscovery/hello/config.server +++ /dev/null @@ -1,69 +0,0 @@ -# -# The server creates one single object adapter with the name -# "Hello". The following sets the endpoints and the adapter ID for -# this adapter. -# -Hello.Endpoints=tcp:udp:ssl -Hello.AdapterId=HelloAdapter - -# -# Only listen on the localhost interface by default. -# -Ice.Default.Host=localhost - -# -# Warn about connection exceptions -# -Ice.Warn.Connections=1 - -# -# Locator tracing -# -Ice.Trace.Locator=0 - -# -# Enable the Ice discovery plugin -# -Ice.Plugin.IceDiscovery=IceDiscovery:IceDiscovery.PluginFactory - -# -# 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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL:IceSSL.PluginFactory -IceSSL.DefaultDir=../../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10003 -Ice.Admin.InstanceName=client -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/IceDiscovery/hello/expect.py b/java/demo/IceDiscovery/hello/expect.py deleted file mode 100755 index fd547079e2e..00000000000 --- a/java/demo/IceDiscovery/hello/expect.py +++ /dev/null @@ -1,30 +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 - -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 -from demoscript.IceDiscovery import hello - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar --Ice.Warn.Connections=0') -client.expect('.*==>') - -hello.run(client, server) diff --git a/java/demo/IceDiscovery/replication/.externalToolBuilders/demo.IceDiscovery.replication.slice.launch b/java/demo/IceDiscovery/replication/.externalToolBuilders/demo.IceDiscovery.replication.slice.launch deleted file mode 100644 index 2b8efb68da2..00000000000 --- a/java/demo/IceDiscovery/replication/.externalToolBuilders/demo.IceDiscovery.replication.slice.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="${project}"/> -<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.IceDiscovery.replication"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.IceDiscovery.replication/Hello.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.IceDiscovery.replication/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/IceDiscovery/replication/Client.java b/java/demo/IceDiscovery/replication/Client.java deleted file mode 100644 index f71b8e7d841..00000000000 --- a/java/demo/IceDiscovery/replication/Client.java +++ /dev/null @@ -1,134 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - @Override - 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()); - - // - // Get the hello proxy. We configure the proxy to not cache the - // server connection with the proxy and to disable the locator - // cache. With this configuration, the IceGrid locator will be - // queried for each invocation on the proxy and the invocation - // will be sent over the server connection matching the returned - // endpoints. - // - Ice.ObjectPrx obj = communicator().stringToProxy("hello"); - obj = obj.ice_connectionCached(false); - obj = obj.ice_locatorCacheTimeout(0); - - HelloPrx hello = HelloPrxHelper.checkedCast(obj); - if(hello == null) - { - System.err.println("invalid proxy"); - return 1; - } - - while(true) - { - System.out.print("enter the number of iterations: "); - System.out.flush(); - - try - { - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - String line = in.readLine(); - if(line == null || line.equals("x")) - { - break; - } - - int count = Integer.parseInt(line); - - System.out.print("enter the delay between each greetings (in ms): "); - System.out.flush(); - line = in.readLine(); - if(line == null || line.equals("x")) - { - break; - } - int delay = Integer.parseInt(line); - - if(delay < 0) - { - delay = 500; // 500 milli-seconds - } - - for(int i = 0; i < count; i++) - { - System.out.println(hello.getGreeting()); - try - { - Thread.currentThread(); - Thread.sleep(delay); - } - catch(InterruptedException ex1) - { - } - } - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - catch(NumberFormatException ex) - { - System.out.println("please specify a valid integer value"); - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - } - } - - 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/IceDiscovery/replication/Hello.ice b/java/demo/IceDiscovery/replication/Hello.ice deleted file mode 100644 index d672af087e3..00000000000 --- a/java/demo/IceDiscovery/replication/Hello.ice +++ /dev/null @@ -1,21 +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 Demo -{ - -interface Hello -{ - idempotent string getGreeting(); - void shutdown(); -}; - -}; diff --git a/java/demo/IceDiscovery/replication/HelloI.java b/java/demo/IceDiscovery/replication/HelloI.java deleted file mode 100644 index 0b3839e6c17..00000000000 --- a/java/demo/IceDiscovery/replication/HelloI.java +++ /dev/null @@ -1,35 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - public HelloI(String name) - { - _name = name; - } - - @Override - public String - getGreeting(Ice.Current current) - { - return _name + " says Hello World!"; - } - - @Override - public void - shutdown(Ice.Current current) - { - System.out.println("Shutting down..."); - current.adapter.getCommunicator().shutdown(); - } - - final private String _name; -}; diff --git a/java/demo/IceDiscovery/replication/README b/java/demo/IceDiscovery/replication/README deleted file mode 100644 index 8685f978764..00000000000 --- a/java/demo/IceDiscovery/replication/README +++ /dev/null @@ -1,18 +0,0 @@ -To run the demo, start the 3 servers: - -$ server.exe --Ice.Config=config.server1 -$ server.exe --Ice.Config=config.server2 -$ server.exe --Ice.Config=config.server3 - -In a separate window: - -$ java -jar build/libs/client.jar - -The client invokes the number of specified iterations with a given -delay on a well-known proxy configured to use per-request load -balancing. Each invocation on the proxy queries the Ice locator -implemented by the IceDiscovery plugin. - -While the client is running and invoking on the server, you can try to -stop some of the servers. As long as one server is still running, the -client will continue to work. diff --git a/java/demo/IceDiscovery/replication/Server.java b/java/demo/IceDiscovery/replication/Server.java deleted file mode 100644 index 7e268d7efe0..00000000000 --- a/java/demo/IceDiscovery/replication/Server.java +++ /dev/null @@ -1,39 +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. -// -// ********************************************************************** - - - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); - HelloI hello = new HelloI(communicator().getProperties().getProperty("Ice.ProgramName")); - adapter.add(hello, 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); - System.exit(status); - } -} diff --git a/java/demo/IceDiscovery/replication/config.client b/java/demo/IceDiscovery/replication/config.client deleted file mode 100644 index 92ba5e5ccdb..00000000000 --- a/java/demo/IceDiscovery/replication/config.client +++ /dev/null @@ -1,9 +0,0 @@ -# -# Enable the Ice discovery plugin -# -Ice.Plugin.IceDiscovery=IceDiscovery:IceDiscovery.PluginFactory - -# -# Ensure connection establishment doesn't take too long. -# -Ice.Override.ConnectTimeout=1000 diff --git a/java/demo/IceDiscovery/replication/config.server1 b/java/demo/IceDiscovery/replication/config.server1 deleted file mode 100755 index ec49e0b279b..00000000000 --- a/java/demo/IceDiscovery/replication/config.server1 +++ /dev/null @@ -1,31 +0,0 @@ -# -# The server creates one single object adapter with the name "Hello". -# -# The following configures the object adapter. We set endpoints with -# no fixed port and we assign it a unique adapter ID that will be -# embedded in indirect proxies. -# -# We also configure the replica group ID, object adapters sharing the -# same replica group ID are part of the same replica group. When the -# client resolves an indirect proxy refering to this replica group, -# the locator implementation will return the endpoints of all the -# object adapters part of the replica group. -# -Hello.Endpoints=tcp -Hello.AdapterId=HelloAdapter1 -Hello.ReplicaGroupId=ReplicatedHelloAdapter - -# -# Identify the server -# -Ice.ProgramName=Server1 - -# -# Enable the Ice discovery plugin -# -Ice.Plugin.IceDiscovery=IceDiscovery:IceDiscovery.PluginFactory - -# -# Ensure connection establishment doesn't take too long. -# -Ice.Override.ConnectTimeout=1000 diff --git a/java/demo/IceDiscovery/replication/config.server2 b/java/demo/IceDiscovery/replication/config.server2 deleted file mode 100755 index 5eabd1f91cf..00000000000 --- a/java/demo/IceDiscovery/replication/config.server2 +++ /dev/null @@ -1,31 +0,0 @@ -# -# The server creates one single object adapter with the name "Hello". -# -# The following configures the object adapter. We set endpoints with -# no fixed port and we assign it a unique adapter ID that will be -# embedded in indirect proxies. -# -# We also configure the replica group ID, object adapters sharing the -# same replica group ID are part of the same replica group. When the -# client resolves an indirect proxy refering to this replica group, -# the locator implementation will return the endpoints of all the -# object adapters part of the replica group. -# -Hello.Endpoints=tcp -Hello.AdapterId=HelloAdapter2 -Hello.ReplicaGroupId=ReplicatedHelloAdapter - -# -# Identify the server -# -Ice.ProgramName=Server2 - -# -# Enable the Ice discovery plugin -# -Ice.Plugin.IceDiscovery=IceDiscovery:IceDiscovery.PluginFactory - -# -# Ensure connection establishment doesn't take too long. -# -Ice.Override.ConnectTimeout=1000 diff --git a/java/demo/IceDiscovery/replication/config.server3 b/java/demo/IceDiscovery/replication/config.server3 deleted file mode 100755 index 12362e47722..00000000000 --- a/java/demo/IceDiscovery/replication/config.server3 +++ /dev/null @@ -1,31 +0,0 @@ -# -# The server creates one single object adapter with the name "Hello". -# -# The following configures the object adapter. We set endpoints with -# no fixed port and we assign it a unique adapter ID that will be -# embedded in indirect proxies. -# -# We also configure the replica group ID, object adapters sharing the -# same replica group ID are part of the same replica group. When the -# client resolves an indirect proxy refering to this replica group, -# the locator implementation will return the endpoints of all the -# object adapters part of the replica group. -# -Hello.Endpoints=tcp -Hello.AdapterId=HelloAdapter3 -Hello.ReplicaGroupId=ReplicatedHelloAdapter - -# -# Identify the server -# -Ice.ProgramName=Server3 - -# -# Enable the Ice discovery plugin -# -Ice.Plugin.IceDiscovery=IceDiscovery:IceDiscovery.PluginFactory - -# -# Ensure connection establishment doesn't take too long. -# -Ice.Override.ConnectTimeout=1000 diff --git a/java/demo/IceDiscovery/replication/expect.py b/java/demo/IceDiscovery/replication/expect.py deleted file mode 100755 index 742af39b896..00000000000 --- a/java/demo/IceDiscovery/replication/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 - -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 -from demoscript.IceDiscovery import replication - -server1 = Util.spawn('java -jar build/libs/server.jar --Ice.Config=config.server1 --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server1.expect('.* ready') -server2 = Util.spawn('java -jar build/libs/server.jar --Ice.Config=config.server2 --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server2.expect('.* ready') -server3 = Util.spawn('java -jar build/libs/server.jar --Ice.Config=config.server3 --Ice.PrintAdapterReady --Ice.Warn.Connections=0') -server3.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar --Ice.Warn.Connections=0') -client.expect('enter the number of iterations:') - -replication.run(client, server1, server2, server3) diff --git a/java/demo/IceGrid/README b/java/demo/IceGrid/README deleted file mode 100644 index 904deef7881..00000000000 --- a/java/demo/IceGrid/README +++ /dev/null @@ -1,10 +0,0 @@ -Demos in this directory: - -- icebox - - This demo shows a simple IceGrid deployment with an IceBox server. - -- simple - - This demo illustrates the basics of using IceGrid, including the - use of templates and object adapter replication. diff --git a/java/demo/IceGrid/build.gradle b/java/demo/IceGrid/build.gradle deleted file mode 100644 index 057b8d81816..00000000000 --- a/java/demo/IceGrid/build.gradle +++ /dev/null @@ -1,54 +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. -// -// ********************************************************************** - -['icebox', 'simple'].each { - def name = it - project(":demoIceGrid${it.capitalize()}") { - slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } - } - - sourceSets { - main { - java { - srcDir '.' - } - } - } - - dependencies { - compile localDependency("ice") - compile localDependency("icebox") - compile localDependency("icegrid") - compile localDependency("icelocatordiscovery") - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } - } - - task makeDbDirs << { - file('db/registry').mkdirs() - file('db/node').mkdirs() - } - compileJava.dependsOn(makeDbDirs) - - clean { - delete 'db' - } - - // Don't create the default jar. - jar.enabled = false - - demoJar("client") - demoJar("server") - } -} diff --git a/java/demo/IceGrid/icebox/.externalToolBuilders/demo.IceGrid.icebox.slice.launch b/java/demo/IceGrid/icebox/.externalToolBuilders/demo.IceGrid.icebox.slice.launch deleted file mode 100644 index 37f84b15c38..00000000000 --- a/java/demo/IceGrid/icebox/.externalToolBuilders/demo.IceGrid.icebox.slice.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="${project}"/> -<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.IceGrid.icebox"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.IceGrid.icebox/Hello.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.IceGrid.icebox/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/IceGrid/icebox/.gitignore b/java/demo/IceGrid/icebox/.gitignore deleted file mode 100644 index 9c39416c539..00000000000 --- a/java/demo/IceGrid/icebox/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db/* diff --git a/java/demo/IceGrid/icebox/Client.java b/java/demo/IceGrid/icebox/Client.java deleted file mode 100644 index d643bb6bf27..00000000000 --- a/java/demo/IceGrid/icebox/Client.java +++ /dev/null @@ -1,44 +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 Demo.*; - -public class Client extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - HelloPrx hello = HelloPrxHelper.uncheckedCast(communicator().propertyToProxy("Hello.Proxy")); - - if(hello == null) - { - System.err.println(appName() + ": Hello.Proxy not set"); - return 1; - } - - hello.sayHello(); - - 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/IceGrid/icebox/Hello.ice b/java/demo/IceGrid/icebox/Hello.ice deleted file mode 100644 index 0289edf4741..00000000000 --- a/java/demo/IceGrid/icebox/Hello.ice +++ /dev/null @@ -1,20 +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 Demo -{ - -interface Hello -{ - idempotent void sayHello(); -}; - -}; diff --git a/java/demo/IceGrid/icebox/HelloI.java b/java/demo/IceGrid/icebox/HelloI.java deleted file mode 100644 index e0f4eb222e5..00000000000 --- a/java/demo/IceGrid/icebox/HelloI.java +++ /dev/null @@ -1,46 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - HelloI(String serviceName) - { - _serviceName = serviceName; - } - - @Override - public void - sayHello(Ice.Current current) - { - java.util.Map<String,String> env = System.getenv(); - String lang = env.containsKey("LANG") ? env.get("LANG") : "en"; - String greeting = "Hello, "; - if(lang.equals("fr")) - { - greeting = "Bonjour, "; - } - else if(lang.equals("de")) - { - greeting = "Hallo, "; - } - else if(lang.equals("es")) - { - greeting = "Hola, "; - } - else if(lang.equals("it")) - { - greeting = "Ciao, "; - } - System.out.println(greeting + _serviceName); - } - - private String _serviceName; -} diff --git a/java/demo/IceGrid/icebox/HelloServiceI.java b/java/demo/IceGrid/icebox/HelloServiceI.java deleted file mode 100644 index 9aef873961f..00000000000 --- a/java/demo/IceGrid/icebox/HelloServiceI.java +++ /dev/null @@ -1,31 +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. -// -// ********************************************************************** - -public class HelloServiceI implements IceBox.Service -{ - @Override - public void - start(String name, Ice.Communicator communicator, String[] args) - { - _adapter = communicator.createObjectAdapter("Hello-" + name); - - String helloIdentity = communicator.getProperties().getProperty("Hello.Identity"); - _adapter.add(new HelloI(name), communicator.stringToIdentity(helloIdentity)); - _adapter.activate(); - } - - @Override - public void - stop() - { - _adapter.destroy(); - } - - private Ice.ObjectAdapter _adapter; -} diff --git a/java/demo/IceGrid/icebox/README b/java/demo/IceGrid/icebox/README deleted file mode 100644 index 2752c62fe3a..00000000000 --- a/java/demo/IceGrid/icebox/README +++ /dev/null @@ -1,119 +0,0 @@ -This demo shows a very simple IceGrid deployment, with a single IceBox -server hosting a number of IceBox services. - -The demo also shows how to use an environment variable in a server -descriptor. - -In application.xml, <env>LANG=en</env> defines an environment variable -named "LANG" with value "en". The Hello object implementation HelloI -reads the value of "LANG" and shows the message in the corresponding -language; you can try changing the value to fr, de, es or it. - - -Setup ------ - -Start the IceGrid registry and node: - - $ icegridnode --Ice.Config=config.grid - -Deploy the 'HelloSimpsons' application (in file application.xml) with -the IceGrid Admin graphical tool. If you prefer to use the command- -line utility, use: - - $ icegridadmin --Ice.Config=config.grid -e \ - "application add application.xml" - - -Using the IceGrid Admin GUI ---------------------------- - -We suggest using the graphical IceGrid Admin tool with this demo. -Follow these steps to log into the IceGrid registry and view the -application you deployed above: - - - Launch the application. Windows users can double-click on the - file icegridgui.jar located in <Ice installation directory>\bin. - Users with a Linux RPM installation can use a script to start the - program: - - $ icegridgui - - On other platforms, start it from a command window as follows: - - $ java -jar icegridgui.jar - - The location of the JAR file varies by platform; for a Linux RPM - installation, the file resides in /usr/share/java. On other - platforms it can be found in <Ice installation directory>/lib. - - - Select Login... from the File menu. - - - In the "Saved Connections" dialog, click "New Connection" to open - the "New Connection" wizard. - - - Select "Direct Connection" and click Next. - - - Enter "DemoIceGrid" for the IceGrid instance name and click next. - - - In "Endpoint Configuration", select "A hostname and port number?" - and click Next. - - - Enter "localhost" for the Hostname. You can leave the port empty - as the demo uses the default port. Click Next. - - - Enter any username and password combination and click Finish - to log in. - - - Next time you want to connect, the connection will appear in the - "Saved Connections" dialog, just select it and click Connect. - - -Running the Client ------------------- - -$ java -jar build/libs/client.jar - -The client simply calls 'sayHello' on the replicated 'hello' object. - - -Stopping and restarting IceBox services ---------------------------------------- - -You can use the IceGrid Admin GUI or the command-line utility to stop -and restart IceBox services. The commands below show how to manipulate -the 'Lisa' service: - - $ icegridadmin --Ice.Config=config.grid - >>> service stop IceBox Lisa - >>> service start IceBox Lisa - - -Administration through Glacier2 -------------------------------- - -This demo also includes the configuration for a Glacier2 router -(DemoGlacier2), to show how you could administer IceGrid from -"the other side" of a firewall. (In this demo, however, all the -components run on the same system.) - -Follow these steps: - - - Connect to the IceGrid registry with icegridadmin or the IceGrid - Admin graphical utility - - - Start the DemoGlacier2 server - - - Reconnect to the IceGrid registry, this time using a Glacier2 - session. For example, using the command-line utility you must - supply a proxy for the router: - - $ icegridadmin --Ice.Default.Router="DemoGlacier2/router:tcp -h localhost -p 4063" - - In the IceGrid Admin GUI, use the Routed tab of the Login dialog. - Change the Glacier2 instance name to "DemoGlacier2" and the endpoints - to "tcp -h localhost -p 4063". - - DemoGlacier2 is configured to use a built-in permissions verifier - that does not validate passwords, so you can log in using any - username/password combination. diff --git a/java/demo/IceGrid/icebox/application.xml b/java/demo/IceGrid/icebox/application.xml deleted file mode 100644 index da4c1535a54..00000000000 --- a/java/demo/IceGrid/icebox/application.xml +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- This file was written by IceGrid Admin --> -<icegrid> - <application name="HelloSimpsons"> - - <properties id="mx"> - <property name="IceMX.Metrics.Debug.GroupBy" value="id"/> - <property name="IceMX.Metrics.Debug.Disabled" value="1"/> - <property name="IceMX.Metrics.ByParent.GroupBy" value="parent"/> - <property name="IceMX.Metrics.ByParent.Disabled" value="1"/> - </properties> - - <service-template id="HelloService"> - <parameter name="name"/> - <service name="${name}" entry="build/libs/server.jar:HelloServiceI"> - <description>A very simple service named after ${name}</description> - <properties> - <properties refid="mx"/> - <property name="Hello.Identity" value="hello"/> - </properties> - <adapter name="Hello-${name}" endpoints="default -h localhost" id="Hello-${name}" - replica-group="HelloGroup" server-lifetime="false"/> - </service> - </service-template> - - <server-template id="Glacier2"> - <parameter name="instance-name" default="${application}.Glacier2"/> - <parameter name="client-endpoints"/> - <parameter name="server-endpoints"/> - <parameter name="session-timeout" default="0"/> - <server id="${instance-name}" activation="manual" exe="glacier2router"> - <properties> - <properties refid="mx"/> - <property name="Glacier2.Client.Endpoints" value="${client-endpoints}"/> - <property name="Glacier2.Server.Endpoints" value="${server-endpoints}"/> - <property name="Glacier2.InstanceName" value="${instance-name}"/> - <property name="Glacier2.SessionTimeout" value="${session-timeout}"/> - </properties> - </server> - </server-template> - - <replica-group id="HelloGroup"> - <load-balancing type="round-robin" n-replicas="1"/> - <object identity="hello" type="::Demo::Hello"/> - </replica-group> - - <node name="node1"> - <server-instance template="Glacier2" - instance-name="DemoGlacier2" - client-endpoints="tcp -h localhost -p 4063" - server-endpoints="tcp -h localhost"> - <properties> - <property name="Glacier2.SessionManager" value="DemoIceGrid/AdminSessionManager"/> - <property name="Glacier2.PermissionsVerifier" value="DemoGlacier2/NullPermissionsVerifier"/> - </properties> - </server-instance> - <icebox id="IceBox" activation="on-demand" exe="java"> - <description>A sample IceBox server</description> - <option>IceBox.Server</option> - <properties> - <properties refid="mx"/> - <property name="IceBox.Trace.ServiceObserver" value="1"/> - </properties> - <service-instance template="HelloService" name="Homer"/> - <service-instance template="HelloService" name="Marge"/> - <service-instance template="HelloService" name="Bart"/> - <service-instance template="HelloService" name="Lisa"/> - <service-instance template="HelloService" name="Maggie"/> - <env>LANG=en</env> - </icebox> - </node> - </application> -</icegrid> diff --git a/java/demo/IceGrid/icebox/config.client b/java/demo/IceGrid/icebox/config.client deleted file mode 100644 index 7d9839fb221..00000000000 --- a/java/demo/IceGrid/icebox/config.client +++ /dev/null @@ -1,10 +0,0 @@ -# -# The client reads this property to create the reference to the -# "hello" object in the server. -# -Hello.Proxy=hello - -# -# The IceGrid locator proxy. -# -Ice.Default.Locator=DemoIceGrid/Locator:default -h localhost -p 4061 diff --git a/java/demo/IceGrid/icebox/config.grid b/java/demo/IceGrid/icebox/config.grid deleted file mode 100644 index c70615b2b9e..00000000000 --- a/java/demo/IceGrid/icebox/config.grid +++ /dev/null @@ -1,50 +0,0 @@ -# -# The IceGrid instance name. -# -IceGrid.InstanceName=DemoIceGrid - -# -# The IceGrid locator proxy. -# -Ice.Default.Locator=DemoIceGrid/Locator:default -h localhost -p 4061 - -# -# IceGrid registry configuration. -# -IceGrid.Registry.Client.Endpoints=default -h localhost -p 4061 -IceGrid.Registry.Server.Endpoints=default -h localhost -IceGrid.Registry.Internal.Endpoints=default -h localhost - -# -# Enable the admin session manager for use with Glacier2. -# -IceGrid.Registry.AdminSessionManager.Endpoints=default - -IceGrid.Registry.Data=db/registry -IceGrid.Registry.PermissionsVerifier=DemoIceGrid/NullPermissionsVerifier -IceGrid.Registry.AdminPermissionsVerifier=DemoIceGrid/NullPermissionsVerifier -IceGrid.Registry.SSLPermissionsVerifier=DemoIceGrid/NullSSLPermissionsVerifier -IceGrid.Registry.AdminSSLPermissionsVerifier=DemoIceGrid/NullSSLPermissionsVerifier - -# -# IceGrid node configuration. -# -IceGrid.Node.Name=node1 -IceGrid.Node.Endpoints=default -h localhost -IceGrid.Node.Data=db/node -IceGrid.Node.CollocateRegistry=1 -#IceGrid.Node.Output=db -#IceGrid.Node.RedirectErrToOut=1 - -# -# Trace properties. -# -IceGrid.Node.Trace.Activator=1 -#IceGrid.Node.Trace.Adapter=2 -#IceGrid.Node.Trace.Server=3 - -# -# Dummy username and password for icegridadmin. -# -IceGridAdmin.Username=foo -IceGridAdmin.Password=bar diff --git a/java/demo/IceGrid/icebox/expect.py b/java/demo/IceGrid/icebox/expect.py deleted file mode 100755 index a0bbd2f23a2..00000000000 --- a/java/demo/IceGrid/icebox/expect.py +++ /dev/null @@ -1,25 +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 - -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 -from demoscript.IceGrid import icebox - -icebox.run('java -jar build/libs/client.jar') diff --git a/java/demo/IceGrid/simple/.externalToolBuilders/demo.IceGrid.simple.slice.launch b/java/demo/IceGrid/simple/.externalToolBuilders/demo.IceGrid.simple.slice.launch deleted file mode 100644 index b7eadae983c..00000000000 --- a/java/demo/IceGrid/simple/.externalToolBuilders/demo.IceGrid.simple.slice.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="${project}"/> -<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.IceGrid.simple"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.IceGrid.simple/Hello.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.IceGrid.simple/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/IceGrid/simple/.gitignore b/java/demo/IceGrid/simple/.gitignore deleted file mode 100644 index 3e9f78f05d8..00000000000 --- a/java/demo/IceGrid/simple/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -db/registry/* -db/node/* diff --git a/java/demo/IceGrid/simple/Client.java b/java/demo/IceGrid/simple/Client.java deleted file mode 100644 index 7c60b89dec0..00000000000 --- a/java/demo/IceGrid/simple/Client.java +++ /dev/null @@ -1,140 +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 Demo.*; - -public class Client extends Ice.Application -{ - class ShutdownHook extends Thread - { - @Override - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private void - menu() - { - System.out.println( - "usage:\n" + - "t: send greeting\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); - } - - @Override - 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()); - - // - // First we try to connect to the object with the `hello' - // identity. If it's not registered with the registry, we - // search for an object with the ::Demo::Hello type. - // - HelloPrx hello = null; - try - { - hello = HelloPrxHelper.checkedCast(communicator().stringToProxy("hello")); - } - catch(Ice.NotRegisteredException ex) - { - IceGrid.QueryPrx query = - IceGrid.QueryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Query")); - hello = HelloPrxHelper.checkedCast(query.findObjectByType("::Demo::Hello")); - } - if(hello == null) - { - System.err.println("couldn't find a `::Demo::Hello' object"); - return 1; - } - - 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(); - } - 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/IceGrid/simple/Hello.ice b/java/demo/IceGrid/simple/Hello.ice deleted file mode 100644 index 9612791a1e9..00000000000 --- a/java/demo/IceGrid/simple/Hello.ice +++ /dev/null @@ -1,21 +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 Demo -{ - -interface Hello -{ - idempotent void sayHello(); - void shutdown(); -}; - -}; diff --git a/java/demo/IceGrid/simple/HelloI.java b/java/demo/IceGrid/simple/HelloI.java deleted file mode 100644 index 9eea8bbcec2..00000000000 --- a/java/demo/IceGrid/simple/HelloI.java +++ /dev/null @@ -1,35 +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 Demo.*; - -public class HelloI extends _HelloDisp -{ - public HelloI(String name) - { - _name = name; - } - - @Override - public void - sayHello(Ice.Current current) - { - System.out.println(_name + " says Hello World!"); - } - - @Override - public void - shutdown(Ice.Current current) - { - System.out.println(_name + " shutting down..."); - current.adapter.getCommunicator().shutdown(); - } - - private final String _name; -} diff --git a/java/demo/IceGrid/simple/README b/java/demo/IceGrid/simple/README deleted file mode 100644 index fae21ebc9fa..00000000000 --- a/java/demo/IceGrid/simple/README +++ /dev/null @@ -1,42 +0,0 @@ -To run the demo, first start the IceGrid service: - -$ icegridnode --Ice.Config=config.grid - -Note that for debug Windows builds you will need to use icegridnoded -rather than icegridnode as the executable name. - -In a separate window: - -$ icegridadmin --Ice.Config=config.grid -e \ - "application add 'application.xml'" -$ java -jar build/libs/client.jar - -This will deploy the application described in the file -"application.xml" and start the client. - -Messages will be displayed in the IceGrid service window. - -You can also use the descriptors in the following files to deploy the -application: - -- application_with_template.xml: These descriptors demonstrate the use - of templates for the server definition. Templates make it easy to - deploy multiple instances of the same server. - -- application_with_replication.xml: These descriptors demonstrate the - use of replication to balance the load of the application over - several servers. - -If you have already deployed the application, you can update it to try -a new set of descriptors, for example: - -$ icegridadmin --Ice.Config=config.grid -e \ - "application update 'application_with_template.xml'" - -When using the descriptors from 'application_with_template.xml' or -'application_with_replication.xml', you can easily deploy more servers -based on the `SimpleServer' template. For example, you can use the -following command to deploy a new server: - -$ icegridadmin --Ice.Config=config.grid -e \ - "server template instantiate Simple node1 SimpleServer index=4" diff --git a/java/demo/IceGrid/simple/Server.java b/java/demo/IceGrid/simple/Server.java deleted file mode 100644 index 7a90bc9d62c..00000000000 --- a/java/demo/IceGrid/simple/Server.java +++ /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. -// -// ********************************************************************** - -public class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - if(args.length > 0) - { - System.err.println(appName() + ": too many arguments"); - return 1; - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); - Ice.Properties properties = communicator().getProperties(); - Ice.Identity id = communicator().stringToIdentity(properties.getProperty("Identity")); - adapter.add(new HelloI(properties.getProperty("Ice.ProgramName")), id); - adapter.activate(); - communicator().waitForShutdown(); - return 0; - } - - static public void - main(String[] args) - { - Server app = new Server(); - int status = app.main("Server", args); - System.exit(status); - } -} diff --git a/java/demo/IceGrid/simple/application.xml b/java/demo/IceGrid/simple/application.xml deleted file mode 100644 index 60f950cf454..00000000000 --- a/java/demo/IceGrid/simple/application.xml +++ /dev/null @@ -1,33 +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. - - ********************************************************************** ---> - -<icegrid> - - <application name="Simple"> - - <node name="node1"> - <server id="SimpleServer" exe="java" activation="on-demand"> - <option>-jar</option> - <option>build/libs/server.jar</option> - <adapter name="Hello" endpoints="tcp -h localhost"> - <object identity="hello" type="::Demo::Hello" property="Identity"/> - </adapter> - - <property name="IceMX.Metrics.Debug.GroupBy" value="id"/> - <property name="IceMX.Metrics.Debug.Disabled" value="1"/> - <property name="IceMX.Metrics.ByParent.GroupBy" value="parent"/> - <property name="IceMX.Metrics.ByParent.Disabled" value="1"/> - </server> - </node> - - </application> - -</icegrid> diff --git a/java/demo/IceGrid/simple/application_with_replication.xml b/java/demo/IceGrid/simple/application_with_replication.xml deleted file mode 100644 index 094d8c6453e..00000000000 --- a/java/demo/IceGrid/simple/application_with_replication.xml +++ /dev/null @@ -1,44 +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. - - ********************************************************************** ---> - -<icegrid> - - <application name="Simple"> - - <server-template id="SimpleServer"> - <parameter name="index"/> - <server id="SimpleServer-${index}" exe="java" activation="on-demand"> - <option>-jar</option> - <option>build/libs/server.jar</option> - <adapter name="Hello" endpoints="tcp -h localhost" replica-group="ReplicatedHelloAdapter"/> - <property name="Identity" value="hello"/> - - <property name="IceMX.Metrics.Debug.GroupBy" value="id"/> - <property name="IceMX.Metrics.Debug.Disabled" value="1"/> - <property name="IceMX.Metrics.ByParent.GroupBy" value="parent"/> - <property name="IceMX.Metrics.ByParent.Disabled" value="1"/> - </server> - </server-template> - - <replica-group id="ReplicatedHelloAdapter"> - <load-balancing type="round-robin"/> - <object identity="hello" type="::Demo::Hello"/> - </replica-group> - - <node name="node1"> - <server-instance template="SimpleServer" index="1"/> - <server-instance template="SimpleServer" index="2"/> - <server-instance template="SimpleServer" index="3"/> - </node> - - </application> - -</icegrid> diff --git a/java/demo/IceGrid/simple/application_with_template.xml b/java/demo/IceGrid/simple/application_with_template.xml deleted file mode 100644 index 960482de7af..00000000000 --- a/java/demo/IceGrid/simple/application_with_template.xml +++ /dev/null @@ -1,40 +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. - - ********************************************************************** ---> - -<icegrid> - - <application name="Simple"> - - <server-template id="SimpleServer"> - <parameter name="index"/> - <server id="SimpleServer-${index}" exe="java" activation="on-demand"> - <option>-jar</option> - <option>build/libs/server.jar</option> - <adapter name="Hello" endpoints="tcp -h localhost"> - <object identity="hello-${index}" type="::Demo::Hello" property="Identity"/> - </adapter> - - <property name="IceMX.Metrics.Debug.GroupBy" value="id"/> - <property name="IceMX.Metrics.Debug.Disabled" value="1"/> - <property name="IceMX.Metrics.ByParent.GroupBy" value="parent"/> - <property name="IceMX.Metrics.ByParent.Disabled" value="1"/> - </server> - </server-template> - - <node name="node1"> - <server-instance template="SimpleServer" index="1"/> - <server-instance template="SimpleServer" index="2"/> - <server-instance template="SimpleServer" index="3"/> - </node> - - </application> - -</icegrid> diff --git a/java/demo/IceGrid/simple/config.client b/java/demo/IceGrid/simple/config.client deleted file mode 100644 index 6b587ce515a..00000000000 --- a/java/demo/IceGrid/simple/config.client +++ /dev/null @@ -1,12 +0,0 @@ -# -# The IceGrid locator proxy. -# -Ice.Default.Locator=DemoIceGrid/Locator:default -h localhost -p 4061 - -# -# To use the IceGrid discovery plugin comment out the default locator -# property above and un-comment the two properties below. The discovery -# plugin uses multicast to discover IceGrid. -# -#Ice.Plugin.IceLocatorDiscovery=IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory -#IceLocatorDiscovery.InstanceName=DemoIceGrid diff --git a/java/demo/IceGrid/simple/config.grid b/java/demo/IceGrid/simple/config.grid deleted file mode 100644 index a608c1d429a..00000000000 --- a/java/demo/IceGrid/simple/config.grid +++ /dev/null @@ -1,44 +0,0 @@ -# -# The IceGrid instance name. -# -IceGrid.InstanceName=DemoIceGrid - -# -# The IceGrid locator proxy. -# -Ice.Default.Locator=DemoIceGrid/Locator:default -h localhost -p 4061 - -# -# IceGrid registry configuration. -# -IceGrid.Registry.Client.Endpoints=default -h localhost -p 4061 -IceGrid.Registry.Server.Endpoints=default -h localhost -IceGrid.Registry.Internal.Endpoints=default -h localhost -IceGrid.Registry.Data=db/registry -IceGrid.Registry.PermissionsVerifier=DemoIceGrid/NullPermissionsVerifier -IceGrid.Registry.AdminPermissionsVerifier=DemoIceGrid/NullPermissionsVerifier -IceGrid.Registry.SSLPermissionsVerifier=DemoIceGrid/NullSSLPermissionsVerifier -IceGrid.Registry.AdminSSLPermissionsVerifier=DemoIceGrid/NullSSLPermissionsVerifier - -# -# IceGrid node configuration. -# -IceGrid.Node.Name=node1 -IceGrid.Node.Endpoints=default -h localhost -IceGrid.Node.Data=db/node -IceGrid.Node.CollocateRegistry=1 -#IceGrid.Node.Output=db -#IceGrid.Node.RedirectErrToOut=1 - -# -# Trace properties. -# -IceGrid.Node.Trace.Activator=1 -#IceGrid.Node.Trace.Adapter=2 -#IceGrid.Node.Trace.Server=3 - -# -# Dummy username and password for icegridadmin. -# -IceGridAdmin.Username=foo -IceGridAdmin.Password=bar diff --git a/java/demo/IceGrid/simple/expect.py b/java/demo/IceGrid/simple/expect.py deleted file mode 100755 index 3b56ea1af38..00000000000 --- a/java/demo/IceGrid/simple/expect.py +++ /dev/null @@ -1,51 +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 - -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 -from demoscript.IceGrid import simple - -def rewrite(fi, fo, javaCmd): - for l in fi: - if l.find('exe="java"') != -1: - l = l.replace('exe="java"', 'exe=%s' % javaCmd) - fo.write(l) - fi.close() - fo.close() - -desc = 'application.xml' -if Util.javaCmd != "java": - desc = 'tmp_application.xml' - fi = open("application.xml", "r") - fo = open("tmp_application.xml", "w") - rewrite(fi, fo, Util.javaCmd) - fi = open("application_with_template.xml", "r") - fo = open("tmp_application_with_template.xml", "w") - rewrite(fi, fo, Util.javaCmd) - fi = open("application_with_replication.xml", "r") - fo = open("tmp_application_with_replication.xml", "w") - rewrite(fi, fo, Util.javaCmd) - -simple.run('java -jar build/libs/client.jar', desc[0:len(desc)-4]) - -if Util.javaCmd != "java": - os.remove("tmp_application.xml") - os.remove("tmp_application_with_template.xml") - os.remove("tmp_application_with_replication.xml") diff --git a/java/demo/IceStorm/README b/java/demo/IceStorm/README deleted file mode 100644 index 8e7c57b451b..00000000000 --- a/java/demo/IceStorm/README +++ /dev/null @@ -1,5 +0,0 @@ -Demos in this directory: - -- clock - - A simple publisher/subscriber application for IceStorm. diff --git a/java/demo/IceStorm/clock/.externalToolBuilders/demo.IceStorm.clock.slice.launch b/java/demo/IceStorm/clock/.externalToolBuilders/demo.IceStorm.clock.slice.launch deleted file mode 100644 index 7851f3a58d9..00000000000 --- a/java/demo/IceStorm/clock/.externalToolBuilders/demo.IceStorm.clock.slice.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="${project}"/> -<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.IceStorm.clock"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.IceStorm.clock/Clock.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.IceStorm.clock/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/IceStorm/clock/.gitignore b/java/demo/IceStorm/clock/.gitignore deleted file mode 100644 index 9c39416c539..00000000000 --- a/java/demo/IceStorm/clock/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db/* diff --git a/java/demo/IceStorm/clock/Clock.ice b/java/demo/IceStorm/clock/Clock.ice deleted file mode 100644 index 19be150180c..00000000000 --- a/java/demo/IceStorm/clock/Clock.ice +++ /dev/null @@ -1,20 +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 Demo -{ - -interface Clock -{ - void tick(string time); -}; - -}; diff --git a/java/demo/IceStorm/clock/Publisher.java b/java/demo/IceStorm/clock/Publisher.java deleted file mode 100644 index cacf84ff840..00000000000 --- a/java/demo/IceStorm/clock/Publisher.java +++ /dev/null @@ -1,149 +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 Demo.*; - -public class Publisher extends Ice.Application -{ - public void - usage() - { - System.out.println("Usage: " + appName() + " [--datagram|--twoway|--oneway] [topic]"); - } - - @Override - public int - run(String[] args) - { - String option = "None"; - String topicName = "time"; - int i; - - for(i = 0; i < args.length; ++i) - { - String oldoption = option; - if(args[i].equals("--datagram")) - { - option = "Datagram"; - } - else if(args[i].equals("--twoway")) - { - option = "Twoway"; - } - else if(args[i].equals("--oneway")) - { - option = "Oneway"; - } - else if(args[i].startsWith("--")) - { - usage(); - return 1; - } - else - { - topicName = args[i++]; - break; - } - - if(!oldoption.equals(option) && !oldoption.equals("None")) - { - usage(); - return 1; - } - } - - if(i != args.length) - { - usage(); - return 1; - } - - IceStorm.TopicManagerPrx manager = IceStorm.TopicManagerPrxHelper.checkedCast( - communicator().propertyToProxy("TopicManager.Proxy")); - if(manager == null) - { - System.err.println("invalid proxy"); - return 1; - } - - // - // Retrieve the topic. - // - IceStorm.TopicPrx topic; - try - { - topic = manager.retrieve(topicName); - } - catch(IceStorm.NoSuchTopic e) - { - try - { - topic = manager.create(topicName); - } - catch(IceStorm.TopicExists ex) - { - System.err.println(appName() + ": temporary failure, try again."); - return 1; - } - } - - // - // Get the topic's publisher object, and create a Clock proxy with - // the mode specified as an argument of this application. - // - Ice.ObjectPrx publisher = topic.getPublisher(); - if(option.equals("Datagram")) - { - publisher = publisher.ice_datagram(); - } - else if(option.equals("Twoway")) - { - // Do nothing. - } - else // if(oneway) - { - publisher = publisher.ice_oneway(); - } - ClockPrx clock = ClockPrxHelper.uncheckedCast(publisher); - - System.out.println("publishing tick events. Press ^C to terminate the application."); - try - { - java.text.SimpleDateFormat date = new java.text.SimpleDateFormat("MM/dd/yy HH:mm:ss:SSS"); - while(true) - { - - clock.tick(date.format(new java.util.Date())); - - try - { - Thread.currentThread(); - Thread.sleep(1000); - } - catch(java.lang.InterruptedException e) - { - } - } - } - catch(Ice.CommunicatorDestroyedException ex) - { - // Ignore - } - - return 0; - } - - public static void - main(String[] args) - { - Publisher app = new Publisher(); - int status = app.main("Publisher", args, "config.pub"); - System.exit(status); - } -} diff --git a/java/demo/IceStorm/clock/README b/java/demo/IceStorm/clock/README deleted file mode 100644 index 3dd0e4b363c..00000000000 --- a/java/demo/IceStorm/clock/README +++ /dev/null @@ -1,134 +0,0 @@ -Overview --------- - -To run the demo: - -Start the IceStorm service: - -$ icebox --Ice.Config=config.icebox - -This configuration assumes there is a subdirectory named db in the -current working directory. - -In a separate window: - -$ java -jar build/libs/subscriber.jar - -In another window: - -$ java -jar build/libs/publisher.jar - -While the publisher continues to run, "tick" messages should be -displayed in the subscriber window. - - -Options -------- - -Both the subscriber and publisher take an optional topic name as a -final argument. The default value for this topic is "time". - -Through the use of command-line options both the subscriber and -publisher can use different QoS for sending and receiving messages. - -For the subscriber: - -java -jar build/libs/subscriber.jar --oneway - - The subscriber receives events as oneway messages. This is the - default. - -java -jar build/libs/subscriber.jar --datagram - - The subscriber receives events as datagrams. - -java -jar build/libs/subscriber.jar --twoway - - The subscriber receives events as twoway messages. - -java -jar build/libs/subscriber.jar --ordered - - The subscriber receives events as twoway messages with guaranteed - ordering. - -java -jar build/libs/subscriber.jar --batch - - This is an additional flag that forwards datagram and oneway events - to the subscriber in batches. - -java -jar build/libs/subscriber.jar --id <id> - - This option specifies a unique identity for this subscriber. When - you use this option, you should also run the subscriber on a fixed - port by setting the Clock.Subscriber.Endpoints property. For - example: - - $ subscriber --Clock.Subscriber.Endpoints="tcp -p <port> -h <host>" - - Replace "tcp" with "udp" when using the --datagram option. - -java -jar build/libs/subscriber.jar --retryCount <count> - - This option sets the retry count for a subscriber. This option - should be used in conjunction with the --id option. Setting - retryCount changes the default subscriber QoS to twoway. - -For the publisher: - -java -jar build/libs/publisher.jar --oneway - - The publisher sends events as oneway messages. This is the default. - -java -jar build/libs/publisher.jar --datagram - - The publisher sends events as datagrams. - -java -jar build/libs/publisher.jar --twoway - - The publisher sends events as twoway messages. - - -Running the demo on several hosts ---------------------------------- - -You must modify several configuration files in order to run the -publisher, subscriber, and IceStorm service on separate hosts. For -the sake of discussion, let us assume that the processes are running -on the following hosts: - - Host <P>: publisher - Host <S>: subscriber - Host <I>: IceStorm - -Replace <P>, <S>, and <I> with the appropriate host names or IP -addresses in the steps below: - -1. Edit the subscriber's configuration file, config.sub, and change - the TopicManager.Proxy property to - - TopicManager.Proxy=DemoIceStorm/TopicManager:default -h <I> -p 10000 - -2. Edit the publisher's configuration file, config.pub, and change - the TopicManager.Proxy property to - - TopicManager.Proxy=DemoIceStorm/TopicManager:default -h <I> -p 10000 - -3. Since the default configurations for the subscriber and IceStorm - endpoints listen only to localhost, you must also modify the Endpoints - properties to explicitly include the host machine's name or IP - address. - - In config.sub: - - Clock.Subscriber.Endpoints=tcp -h <S>:udp -h <S> - - In config.service: - - IceStorm.TopicManager.Endpoints=default -h <I> -p 10000 - IceStorm.Publish.Endpoints=tcp -h <I> -p 10001:udp -h <I> -p 10001 - -If you experience any network delays or errors, edit all of the -configuration files and enable the Ice.Trace.Network property. Running -the processes with this property enabled displays a log of Ice's -network activity and may help you to identify the problem more -quickly.
\ No newline at end of file diff --git a/java/demo/IceStorm/clock/Subscriber.java b/java/demo/IceStorm/clock/Subscriber.java deleted file mode 100644 index 6d4519fe6dc..00000000000 --- a/java/demo/IceStorm/clock/Subscriber.java +++ /dev/null @@ -1,264 +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 Demo.*; - -public class Subscriber extends Ice.Application -{ - public class ClockI extends _ClockDisp - { - @Override - public void - tick(String date, Ice.Current current) - { - System.out.println(date); - } - } - - public void - usage() - { - System.out.println("Usage: " + appName() + " [--batch] [--datagram|--twoway|--ordered|--oneway] " + - "[--retryCount count] [--id id] [topic]"); - } - - @Override - public int - run(String[] args) - { - args = communicator().getProperties().parseCommandLineOptions("Clock", args); - - String topicName = "time"; - String option = "None"; - boolean batch = false; - String id = null; - String retryCount = null; - int i; - for(i = 0; i < args.length; ++i) - { - String oldoption = option; - if(args[i].equals("--datagram")) - { - option = "Datagram"; - } - else if(args[i].equals("--twoway")) - { - option = "Twoway"; - } - else if(args[i].equals("--ordered")) - { - option = "Ordered"; - } - else if(args[i].equals("--oneway")) - { - option = "Oneway"; - } - else if(args[i].equals("--batch")) - { - batch = true; - } - else if(args[i].equals("--id")) - { - ++i; - if(i >= args.length) - { - usage(); - return 1; - } - id = args[i]; - } - else if(args[i].equals("--retryCount")) - { - ++i; - if(i >= args.length) - { - usage(); - return 1; - } - retryCount = args[i]; - } - else if(args[i].startsWith("--")) - { - usage(); - return 1; - } - else - { - topicName = args[i++]; - break; - } - - if(!oldoption.equals(option) && !oldoption.equals("None")) - { - usage(); - return 1; - } - } - - if(i != args.length) - { - usage(); - return 1; - } - - if(retryCount != null) - { - if(option.equals("None")) - { - option = "Twoway"; - } - else if(!option.equals("Twoway") && !option.equals("Ordered")) - { - usage(); - return 1; - } - } - - if(batch && (option.equals("Twoway") || option.equals("Ordered"))) - { - System.err.println(appName() + ": batch can only be set with oneway or datagram"); - return 1; - } - - IceStorm.TopicManagerPrx manager = IceStorm.TopicManagerPrxHelper.checkedCast( - communicator().propertyToProxy("TopicManager.Proxy")); - if(manager == null) - { - System.err.println("invalid proxy"); - return 1; - } - - // - // Retrieve the topic. - // - IceStorm.TopicPrx topic; - try - { - topic = manager.retrieve(topicName); - } - catch(IceStorm.NoSuchTopic e) - { - try - { - topic = manager.create(topicName); - } - catch(IceStorm.TopicExists ex) - { - System.err.println(appName() + ": temporary failure, try again."); - return 1; - } - } - - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Clock.Subscriber"); - - // - // Add a servant for the Ice object. If --id is used the - // identity comes from the command line, otherwise a UUID is - // used. - // - // id is not directly altered since it is used below to detect - // whether subscribeAndGetPublisher can raise - // AlreadySubscribed. - // - Ice.Identity subId = new Ice.Identity(id, ""); - if(subId.name == null) - { - subId.name = java.util.UUID.randomUUID().toString(); - } - Ice.ObjectPrx subscriber = adapter.add(new ClockI(), subId); - - // - // Activate the object adapter before subscribing. - // - adapter.activate(); - - java.util.Map<String, String> qos = new java.util.HashMap<String, String>(); - if(retryCount != null) - { - qos.put("retryCount", retryCount); - } - // - // Set up the proxy. - // - if(option.equals("Datagram")) - { - if(batch) - { - subscriber = subscriber.ice_batchDatagram(); - } - else - { - subscriber = subscriber.ice_datagram(); - } - } - else if(option.equals("Twoway")) - { - // Do nothing to the subscriber proxy. Its already twoway. - } - else if(option.equals("Ordered")) - { - // Do nothing to the subscriber proxy. Its already twoway. - qos.put("reliability", "ordered"); - } - else if(option.equals("Oneway") || option.equals("None")) - { - if(batch) - { - subscriber = subscriber.ice_batchOneway(); - } - else - { - subscriber = subscriber.ice_oneway(); - } - } - - try - { - topic.subscribeAndGetPublisher(qos, subscriber); - } - catch(IceStorm.AlreadySubscribed e) - { - // If we're manually setting the subscriber id ignore. - if(id == null) - { - e.printStackTrace(); - return 1; - } - else - { - System.out.println("reactivating persistent subscriber"); - } - } - catch(IceStorm.InvalidSubscriber e) - { - e.printStackTrace(); - return 1; - } - catch(IceStorm.BadQoS e) - { - e.printStackTrace(); - return 1; - } - - shutdownOnInterrupt(); - communicator().waitForShutdown(); - - topic.unsubscribe(subscriber); - - return 0; - } - - public static void - main(String[] args) - { - Subscriber app = new Subscriber(); - int status = app.main("Subscriber", args, "config.sub"); - System.exit(status); - } -} diff --git a/java/demo/IceStorm/clock/build.gradle b/java/demo/IceStorm/clock/build.gradle deleted file mode 100644 index 29a73b18c16..00000000000 --- a/java/demo/IceStorm/clock/build.gradle +++ /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. -// -// ********************************************************************** - -slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - compile localDependency("ice") - compile localDependency("icestorm") - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } -} - -// Create a jar for the publisher & subscriber which includes everything in the demo. -task publisherJar(type: Jar) { - version = "" - baseName = "publisher" - from(sourceSets.main.output) { - include "**" - } -} - -task subscriberJar(type: Jar) { - version = "" - baseName = "subscriber" - from(sourceSets.main.output) { - include "**" - } -} - -publisherJar { - manifest { - attributes("Main-Class": "Publisher") - attributes("Class-Path": configurations.compile.resolve().collect { it.toURI() }.join(' ')) - } -} - -subscriberJar { - manifest { - attributes("Main-Class": "Subscriber") - attributes("Class-Path": configurations.compile.resolve().collect { it.toURI() }.join(' ')) - } -} - -artifacts { - archives publisherJar, subscriberJar; -} - -clean { - delete fileTree(dir: 'db', excludes:['.gitignore', 'DB_CONFIG']) -} - -jar.enabled = false diff --git a/java/demo/IceStorm/clock/config.admin b/java/demo/IceStorm/clock/config.admin deleted file mode 100644 index f748656a515..00000000000 --- a/java/demo/IceStorm/clock/config.admin +++ /dev/null @@ -1,14 +0,0 @@ -# -# This property is used by the icestormadmin to connect to IceStorm. -# -IceStormAdmin.TopicManager.Default=DemoIceStorm/TopicManager:default -h localhost -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 diff --git a/java/demo/IceStorm/clock/config.icebox b/java/demo/IceStorm/clock/config.icebox deleted file mode 100644 index 4beae8cfa1e..00000000000 --- a/java/demo/IceStorm/clock/config.icebox +++ /dev/null @@ -1,35 +0,0 @@ -# -# Enable Ice.Admin object -# The IceStorm service has its own endpoints (see config.service). -# -Ice.Admin.Endpoints=tcp -h localhost -p 9996 -Ice.Admin.InstanceName=icebox - -# -# The IceStorm service. The service is configured using a separate -# configuration file (see config.service). -# -IceBox.Service.IceStorm=IceStormService,36:createIceStorm --Ice.Config=config.service - -# -# 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/IceStorm/clock/config.pub b/java/demo/IceStorm/clock/config.pub deleted file mode 100644 index 9d0dd727ce7..00000000000 --- a/java/demo/IceStorm/clock/config.pub +++ /dev/null @@ -1,22 +0,0 @@ -# -# This property is used by the clients to connect to IceStorm. -# -TopicManager.Proxy=DemoIceStorm/TopicManager:default -h localhost -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 - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10003 -Ice.Admin.InstanceName=publisher -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/IceStorm/clock/config.service b/java/demo/IceStorm/clock/config.service deleted file mode 100644 index 56d87edd66a..00000000000 --- a/java/demo/IceStorm/clock/config.service +++ /dev/null @@ -1,74 +0,0 @@ -# -# The IceStorm service instance name. -# -IceStorm.InstanceName=DemoIceStorm - -# -# This property defines the endpoints on which the IceStorm -# TopicManager listens. -# -IceStorm.TopicManager.Endpoints=default -h localhost -p 10000 - -# -# This property defines the endpoints on which the topic -# publisher objects listen. If you want to federate -# IceStorm instances this must run on a fixed port (or use -# IceGrid). -# -IceStorm.Publish.Endpoints=tcp -h localhost -p 10001:udp -h localhost -p 10001 - -# -# TopicManager Tracing -# -# 0 = no tracing -# 1 = trace topic creation, subscription, unsubscription -# 2 = like 1, but with more detailed subscription information -# -IceStorm.Trace.TopicManager=2 - -# -# Topic Tracing -# -# 0 = no tracing -# 1 = trace unsubscription diagnostics -# -IceStorm.Trace.Topic=1 - -# -# Subscriber Tracing -# -# 0 = no tracing -# 1 = subscriber diagnostics (subscription, unsubscription, event -# propagation failures) -# -IceStorm.Trace.Subscriber=1 - -# -# Amount of time in milliseconds between flushes for batch mode -# transfer. The minimum allowable value is 100ms. -# -IceStorm.Flush.Timeout=2000 - -# -# 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 - -# -# This property defines the home directory of the Freeze -# database environment for the IceStorm service. -# -Freeze.DbEnv.IceStorm.DbHome=db - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10004 -Ice.Admin.InstanceName=icestorm -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/IceStorm/clock/config.sub b/java/demo/IceStorm/clock/config.sub deleted file mode 100644 index b7774fd0f8c..00000000000 --- a/java/demo/IceStorm/clock/config.sub +++ /dev/null @@ -1,34 +0,0 @@ -# -# This property is used to configure the endpoints of the clock -# subscriber adapter. These endpoints are where the client receives -# topic messages from IceStorm. -# -Clock.Subscriber.Endpoints=tcp:udp - -# -# Only listen on the localhost interface by default. -# -Ice.Default.Host=localhost - -# -# This property is used by the clients to connect to IceStorm. -# -TopicManager.Proxy=DemoIceStorm/TopicManager:default -h localhost -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 - -# -# IceMX configuration. -# -#Ice.Admin.Endpoints=tcp -h localhost -p 10002 -Ice.Admin.InstanceName=subscriber -IceMX.Metrics.Debug.GroupBy=id -IceMX.Metrics.ByParent.GroupBy=parent diff --git a/java/demo/IceStorm/clock/db/.gitignore b/java/demo/IceStorm/clock/db/.gitignore deleted file mode 100644 index 39af5887579..00000000000 --- a/java/demo/IceStorm/clock/db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# Dummy file, so that git retains this otherwise empty directory. diff --git a/java/demo/IceStorm/clock/expect.py b/java/demo/IceStorm/clock/expect.py deleted file mode 100755 index 2126cf5d722..00000000000 --- a/java/demo/IceStorm/clock/expect.py +++ /dev/null @@ -1,25 +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 - -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 -from demoscript.IceStorm import clock - -clock.run('java -jar build/libs/subscriber.jar', 'java -jar build/libs/publisher.jar') diff --git a/java/demo/Manual/README b/java/demo/Manual/README deleted file mode 100644 index 6dbc708834e..00000000000 --- a/java/demo/Manual/README +++ /dev/null @@ -1,31 +0,0 @@ -Demos in this directory: - -- evictor - - This is the source code for the evictor implementation described in - the Ice Run Time chapter. You can copy and modify this code to - suit your needs. - -- evictor_filesystem - - An implementation of the persistent version of the file system - example described in the Freeze chapter using a Freeze evictor. - -- map_filesystem - - An implementation of the persistent version of the file system - example described in the Freeze chapter using a Freeze map. - -- lifecycle - - An implementation of the file system that supports life cycle operations. - -- printer - - An implementation of the simple printer example at the beginning of - the manual. - -- simple_filesystem - - An implementation of the simple (non-persistent, non-life-cycle) - version of the file system example. diff --git a/java/demo/Manual/build.gradle b/java/demo/Manual/build.gradle deleted file mode 100644 index 088da29f94f..00000000000 --- a/java/demo/Manual/build.gradle +++ /dev/null @@ -1,56 +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. -// -// ********************************************************************** - -['evictor_filesystem', 'lifecycle', 'printer', 'simple_filesystem'].each { - // abc_def -> AbcDef - def name = it.split('_').collect { it.capitalize() }.join() - project(":demoManual${name}") { - slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } - } - - sourceSets { - main { - java { - srcDir '.' - } - } - } - - dependencies { - compile localDependency("ice") - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } - } - - if(name == "EvictorFilesystem") { - dependencies { - compile localDependency("freeze") - } - dependencies { - runtime files(dbJar) - } - } - - - // Don't create the default jar. - jar.enabled = false - - clean { - delete fileTree(dir: 'db', excludes:['.gitignore', 'DB_CONFIG']) - } - - demoJar("client") - demoJar("server") - } -} diff --git a/java/demo/Manual/evictor/EvictorBase.java b/java/demo/Manual/evictor/EvictorBase.java deleted file mode 100644 index c309bd2866a..00000000000 --- a/java/demo/Manual/evictor/EvictorBase.java +++ /dev/null @@ -1,124 +0,0 @@ -package Evictor; - -public abstract class EvictorBase implements Ice.ServantLocator -{ - public - EvictorBase() - { - _size = 1000; - } - - public - EvictorBase(int size) - { - _size = size < 0 ? 1000 : size; - } - - public abstract Ice.Object - add(Ice.Current c, Ice.LocalObjectHolder cookie); - - public abstract void - evict(Ice.Object servant, java.lang.Object cookie); - - synchronized public final Ice.Object - locate(Ice.Current c, Ice.LocalObjectHolder cookie) - { - // - // Check if we have a servant in the map already. - // - EvictorEntry entry = _map.get(c.id); - if(entry != null) - { - // - // Got an entry already, dequeue the entry from its current position. - // - entry.queuePos.remove(); - } - else - { - // - // We do not have entry. Ask the derived class to - // instantiate a servant and add a new entry to the map. - // - entry = new EvictorEntry(); - Ice.LocalObjectHolder cookieHolder = new Ice.LocalObjectHolder(); - entry.servant = add(c, cookieHolder); // Down-call - if(entry.servant == null) - { - return null; - } - entry.userCookie = cookieHolder.value; - entry.useCount = 0; - _map.put(c.id, entry); - } - - // - // Increment the use count of the servant and enqueue - // the entry at the front, so we get LRU order. - // - ++(entry.useCount); - _queue.addFirst(c.id); - entry.queuePos = _queue.iterator(); - entry.queuePos.next(); // Position the iterator on the element. - - cookie.value = entry; - - return entry.servant; - } - - synchronized public final void - finished(Ice.Current c, Ice.Object o, java.lang.Object cookie) - { - EvictorEntry entry = (EvictorEntry)cookie; - - // - // Decrement use count and check if - // there is something to evict. - // - --(entry.useCount); - evictServants(); - } - - synchronized public final void - deactivate(String category) - { - _size = 0; - evictServants(); - } - - private class EvictorEntry - { - Ice.Object servant; - java.lang.Object userCookie; - java.util.Iterator<Ice.Identity> queuePos; - int useCount; - } - - private void evictServants() - { - // - // If the evictor queue has grown larger than the limit, - // look at the excess elements to see whether any of them - // can be evicted. - // - java.util.Iterator<Ice.Identity> p = _queue.riterator(); - int excessEntries = _map.size() - _size; - for(int i = 0; i < excessEntries; ++i) - { - Ice.Identity id = p.next(); - EvictorEntry e = _map.get(id); - if(e.useCount == 0) - { - evict(e.servant, e.userCookie); // Down-call - e.queuePos.remove(); - _map.remove(id); - } - } - } - - private java.util.Map<Ice.Identity, EvictorEntry> _map = - new java.util.HashMap<Ice.Identity, EvictorEntry>(); - private Evictor.LinkedList<Ice.Identity> _queue = - new Evictor.LinkedList<Ice.Identity>(); - private int _size; -} diff --git a/java/demo/Manual/evictor/LinkedList.java b/java/demo/Manual/evictor/LinkedList.java deleted file mode 100644 index 3ab320d2e07..00000000000 --- a/java/demo/Manual/evictor/LinkedList.java +++ /dev/null @@ -1,225 +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 Evictor; - -// -// Stripped down LinkedList implementation for use in the Evictor. The -// API is similar to java.util.LinkedList. -// -// Major differences: -// * listIterator() is not implemented. -// * Operation riterator() returns a reverse iterator. -// * This implementation also has the property that an Iterator can be -// retained over structural changes to the list itself (similar to an -// STL list). -// -public class LinkedList<T> -{ - public - LinkedList() - { - _header.next = _header.previous = _header; - } - - public T - getFirst() - { - if(_size == 0) - { - throw new java.util.NoSuchElementException(); - } - - return _header.next.element; - } - - public void - addFirst(T o) - { - addBefore(o, _header.next); - } - - public boolean - isEmpty() - { - return _size == 0; - } - - public int - size() - { - return _size; - } - - public java.util.Iterator<T> - iterator() - { - return new ForwardIterator(); - } - - public java.util.Iterator<T> - riterator() - { - return new ReverseIterator(); - } - - private class ForwardIterator implements java.util.Iterator<T> - { - public boolean - hasNext() - { - return _next != null; - } - - public T - next() - { - if(_next == null) - { - throw new java.util.NoSuchElementException(); - } - - _current = _next; - - if(_next.next != _header) - { - _next = _next.next; - } - else - { - _next = null; - } - return _current.element; - } - - public void - remove() - { - if(_current == null) - { - throw new IllegalStateException(); - } - LinkedList.this.remove(_current); - _current = null; - } - - ForwardIterator() - { - if(_header.next == _header) - { - _next = null; - } - else - { - _next = _header.next; - } - _current = null; - } - - private Entry<T> _current; - private Entry<T> _next; - } - - private class ReverseIterator implements java.util.Iterator<T> - { - public boolean - hasNext() - { - return _next != null; - } - - public T - next() - { - if(_next == null) - { - throw new java.util.NoSuchElementException(); - } - - _current = _next; - - if(_next.previous != _header) - { - _next = _next.previous; - } - else - { - _next = null; - } - return _current.element; - } - - public void - remove() - { - if(_current == null) - { - throw new IllegalStateException(); - } - LinkedList.this.remove(_current); - _current = null; - } - - ReverseIterator() - { - if(_header.next == _header) - { - _next = null; - } - else - { - _next = _header.previous; - } - _current = null; - } - - private Entry<T> _current; - private Entry<T> _next; - } - - private static class Entry<T> - { - T element; - Entry<T> next; - Entry<T> previous; - - Entry(T element, Entry<T> next, Entry<T> previous) - { - this.element = element; - this.next = next; - this.previous = previous; - } - } - - private Entry<T> - addBefore(T o, Entry<T> e) - { - Entry<T> newEntry = new Entry<T>(o, e, e.previous); - newEntry.previous.next = newEntry; - newEntry.next.previous = newEntry; - _size++; - return newEntry; - } - - private void - remove(Entry<T> e) - { - if(e == _header) - { - throw new java.util.NoSuchElementException(); - } - - e.previous.next = e.next; - e.next.previous = e.previous; - _size--; - } - - private Entry<T> _header = new Entry<T>(null, null, null); - private int _size = 0; -} diff --git a/java/demo/Manual/evictor/README b/java/demo/Manual/evictor/README deleted file mode 100644 index cc6b56f5d65..00000000000 --- a/java/demo/Manual/evictor/README +++ /dev/null @@ -1,15 +0,0 @@ -The source code provided here implements a Java evictor base class. To -use it, you must derive a class from EvictorBase and implement the -abstract add() and evict() methods. - -add() is called when the evictor needs to instantiate a servant, and -evict() is called when the evictor has decided to evict a servant. -Note that you can pass information from add() to the corresponding -call to evict() via the cookie argument. - -The evictor implementation relies on a linked list that allows items -to be added and removed without invalidating iterators. Such an -implementation is provided in LinkedList.java. - -For more details on this evictor, see the section "Server -Implementation Techniques" in the Ice documentation. diff --git a/java/demo/Manual/evictor_filesystem/.externalToolBuilders/book.demo.evictor_filesystem.slice.launch b/java/demo/Manual/evictor_filesystem/.externalToolBuilders/book.demo.evictor_filesystem.slice.launch deleted file mode 100644 index 0ce604434d2..00000000000 --- a/java/demo/Manual/evictor_filesystem/.externalToolBuilders/book.demo.evictor_filesystem.slice.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.evictor_filesystem"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.book.evictor_filesystem/Filesystem.ice" type="1"/> <item path="/demo.book.evictor_filesystem/PersistentFilesystem.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.book.evictor_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/evictor_filesystem/.gitignore b/java/demo/Manual/evictor_filesystem/.gitignore deleted file mode 100644 index 9c39416c539..00000000000 --- a/java/demo/Manual/evictor_filesystem/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db/* diff --git a/java/demo/Manual/evictor_filesystem/Client.java b/java/demo/Manual/evictor_filesystem/Client.java deleted file mode 100644 index 4f01c9e0787..00000000000 --- a/java/demo/Manual/evictor_filesystem/Client.java +++ /dev/null @@ -1,50 +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 extends Ice.Application -{ - @Override - public int - run(String[] args) - { - // - // Terminate cleanly on receipt of a signal. - // - shutdownOnInterrupt(); - - // - // Create a proxy for the root directory - // - DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(communicator().propertyToProxy("RootDir.Proxy")); - if(rootDir == null) - { - throw new Error("Client: invalid proxy"); - } - - Parser p = new Parser(rootDir); - return p.parse(); - } - - static public void - main(String[] args) - { - Client app = new Client(); - app.main("demo.book.evictor_filesystem.Client", args, "config.client"); - } - - static private class Error extends RuntimeException - { - public Error(String msg) - { - super(msg); - } - } -} diff --git a/java/demo/Manual/evictor_filesystem/DirectoryI.java b/java/demo/Manual/evictor_filesystem/DirectoryI.java deleted file mode 100644 index 0087731b0cf..00000000000 --- a/java/demo/Manual/evictor_filesystem/DirectoryI.java +++ /dev/null @@ -1,170 +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 final class DirectoryI extends PersistentDirectory -{ - public - DirectoryI() - { - _destroyed = false; - nodes = new java.util.HashMap<java.lang.String, NodeDesc>(); - } - - @Override - public synchronized String - name(Ice.Current current) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation); - } - - return nodeName; - } - - @Override - public void - destroy(Ice.Current current) - throws PermissionDenied - { - if(parent == null) - { - throw new PermissionDenied("Cannot destroy root directory"); - } - - synchronized(this) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation); - } - if(!nodes.isEmpty()) - { - throw new PermissionDenied("Cannot destroy non-empty directory"); - } - _destroyed = true; - } - - // - // Because we use a transactional evictor, these updates are guaranteed to be atomic. - // - parent.removeNode(nodeName); - _evictor.remove(current.id); - } - - @Override - public synchronized NodeDesc[] - list(Ice.Current current) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation); - } - - NodeDesc[] result = new NodeDesc[nodes.size()]; - int i = 0; - java.util.Iterator<NodeDesc> p = nodes.values().iterator(); - while(p.hasNext()) - { - result[i++] = p.next(); - } - return result; - } - - @Override - public synchronized NodeDesc - find(String name, Ice.Current current) - throws NoSuchName - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation); - } - - if(!nodes.containsKey(name)) - { - throw new NoSuchName(name); - } - - return nodes.get(name); - } - - @Override - public synchronized DirectoryPrx - createDirectory(String name, Ice.Current current) - throws NameInUse - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation); - } - - if(name.length() == 0 || nodes.containsKey(name)) - { - throw new NameInUse(name); - } - - Ice.Identity id = current.adapter.getCommunicator().stringToIdentity(java.util.UUID.randomUUID().toString()); - PersistentDirectory dir = new DirectoryI(); - dir.nodeName = name; - dir.parent = PersistentDirectoryPrxHelper.uncheckedCast(current.adapter.createProxy(current.id)); - DirectoryPrx proxy = DirectoryPrxHelper.uncheckedCast(_evictor.add(dir, id)); - - NodeDesc nd = new NodeDesc(); - nd.name = name; - nd.type = NodeType.DirType; - nd.proxy = proxy; - nodes.put(name, nd); - - return proxy; - } - - @Override - public synchronized FilePrx - createFile(String name, Ice.Current current) - throws NameInUse - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation); - } - - if(name.length() == 0 || nodes.containsKey(name)) - { - throw new NameInUse(name); - } - - Ice.Identity id = current.adapter.getCommunicator().stringToIdentity(java.util.UUID.randomUUID().toString()); - PersistentFile file = new FileI(); - file.nodeName = name; - file.parent = PersistentDirectoryPrxHelper.uncheckedCast(current.adapter.createProxy(current.id)); - FilePrx proxy = FilePrxHelper.uncheckedCast(_evictor.add(file, id)); - - NodeDesc nd = new NodeDesc(); - nd.name = name; - nd.type = NodeType.FileType; - nd.proxy = proxy; - nodes.put(name, nd); - - return proxy; - } - - @Override - public synchronized void - removeNode(String name, Ice.Current current) - { - assert(nodes.containsKey(name)); - nodes.remove(name); - } - - public static Freeze.Evictor _evictor; - private boolean _destroyed; -} diff --git a/java/demo/Manual/evictor_filesystem/FileI.java b/java/demo/Manual/evictor_filesystem/FileI.java deleted file mode 100644 index 7f269e3b514..00000000000 --- a/java/demo/Manual/evictor_filesystem/FileI.java +++ /dev/null @@ -1,80 +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 final class FileI extends PersistentFile -{ - public - FileI() - { - _destroyed = false; - } - - @Override - public synchronized String - name(Ice.Current current) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation); - } - - return nodeName; - } - - @Override - public void - destroy(Ice.Current current) - throws PermissionDenied - { - synchronized(this) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation); - } - _destroyed = true; - } - - // - // Because we use a transactional evictor, these updates are guaranteed to be atomic. - // - parent.removeNode(nodeName); - _evictor.remove(current.id); - } - - @Override - public synchronized String[] - read(Ice.Current current) - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation); - } - - return text.clone(); - } - - @Override - public synchronized void - write(String[] text, Ice.Current current) - throws GenericError - { - if(_destroyed) - { - throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation); - } - - this.text = text; - } - - public static Freeze.Evictor _evictor; - private boolean _destroyed; -} diff --git a/java/demo/Manual/evictor_filesystem/Filesystem.ice b/java/demo/Manual/evictor_filesystem/Filesystem.ice deleted file mode 100644 index a9c863544f1..00000000000 --- a/java/demo/Manual/evictor_filesystem/Filesystem.ice +++ /dev/null @@ -1,63 +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; - }; - exception PermissionDenied extends GenericError {}; - exception NameInUse extends GenericError {}; - exception NoSuchName extends GenericError {}; - - interface Node - { - idempotent string name(); - - ["freeze:write"] - void destroy() throws PermissionDenied; - }; - - sequence<string> Lines; - - interface File extends Node - { - idempotent Lines read(); - - ["freeze:write"] - idempotent void write(Lines text) throws GenericError; - }; - - enum NodeType { DirType, FileType }; - - struct NodeDesc - { - string name; - NodeType type; - Node* proxy; - }; - - sequence<NodeDesc> NodeDescSeq; - - interface Directory extends Node - { - idempotent NodeDescSeq list(); - - idempotent NodeDesc find(string name) throws NoSuchName; - - ["freeze:write"] - File* createFile(string name) throws NameInUse; - - ["freeze:write"] - Directory* createDirectory(string name) throws NameInUse; - }; -}; diff --git a/java/demo/Manual/evictor_filesystem/Grammar.java b/java/demo/Manual/evictor_filesystem/Grammar.java deleted file mode 100644 index 57f046c62e3..00000000000 --- a/java/demo/Manual/evictor_filesystem/Grammar.java +++ /dev/null @@ -1,202 +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. -// -// ********************************************************************** - -class Grammar -{ - Grammar(Parser p) - { - _parser = p; - _scanner = new Scanner(_parser); - } - - void - parse() - { - while(true) - { - try - { - _token = _scanner.nextToken(); - if(_token == null) - { - return; - } - else if(_token.type == Token.TOK_SEMI) - { - // Continue - } - else if(_token.type == Token.TOK_HELP) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.usage(); - } - else if(_token.type == Token.TOK_EXIT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - return; - } - else if(_token.type == Token.TOK_LIST) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.list(false); - } - else if(_token.type == Token.TOK_LIST_RECURSIVE) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.list(true); - } - else if(_token.type == Token.TOK_CREATE_FILE) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: mkfile FILE [FILE...]"); - } - _parser.createFile(s); - } - else if(_token.type == Token.TOK_CREATE_DIR) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: mkdir DIR [DIR...]"); - } - _parser.createDir(s); - } - else if(_token.type == Token.TOK_PWD) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.pwd(); - } - else if(_token.type == Token.TOK_CD) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() > 1) - { - throw new ParseError("usage: cd [DIR]"); - } - else if(s.size() == 0) - { - _parser.cd("/"); - } - else - { - _parser.cd(s.get(0)); - } - } - else if(_token.type == Token.TOK_CAT) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() != 1) - { - throw new ParseError("usage: cat FILE"); - } - _parser.cat(s.get(0)); - } - else if(_token.type == Token.TOK_WRITE) - { - java.util.LinkedList<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: write FILE [STRING...]"); - } - _parser.write(s); - } - else if(_token.type == Token.TOK_RM) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: rm NAME [NAME...]"); - } - _parser.destroy(s); - } - else - { - _parser.error("parse error"); - } - } - catch(ParseError e) - { - _parser.error("Parse error: " + e.getMessage()); - } - } - } - - private java.util.LinkedList<String> - strings() - { - java.util.LinkedList<String> l = new java.util.LinkedList<String>(); - while(true) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_STRING) - { - return l; - } - l.add(_token.value); - } - } - - static private class ParseError extends RuntimeException - { - ParseError(String msg) - { - super(msg); - } - } - - private Parser _parser; - private Scanner _scanner; - private Token _token; -} diff --git a/java/demo/Manual/evictor_filesystem/NodeFactory.java b/java/demo/Manual/evictor_filesystem/NodeFactory.java deleted file mode 100644 index 851af0d4a3b..00000000000 --- a/java/demo/Manual/evictor_filesystem/NodeFactory.java +++ /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. -// -// ********************************************************************** - -import Filesystem.*; - -public class NodeFactory implements Ice.ObjectFactory -{ - @Override - public Ice.Object - create(String type) - { - if(type.equals(PersistentFile.ice_staticId())) - { - return new FileI(); - } - else if(type.equals(PersistentDirectory.ice_staticId())) - { - return new DirectoryI(); - } - else - { - assert(false); - return null; - } - } - - @Override - public void - destroy() - { - } -} diff --git a/java/demo/Manual/evictor_filesystem/Parser.java b/java/demo/Manual/evictor_filesystem/Parser.java deleted file mode 100644 index 5e7854156aa..00000000000 --- a/java/demo/Manual/evictor_filesystem/Parser.java +++ /dev/null @@ -1,349 +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.*; - -class Parser -{ - Parser(DirectoryPrx root) - { - _dirs = new java.util.LinkedList<DirectoryPrx>(); - _dirs.addFirst(root); - } - - void - usage() - { - System.err.print( - "help Print this message.\n" + - "pwd Print current directory (/ = root).\n" + - "cd [DIR] Change directory (/ or empty = root).\n" + - "ls List current directory.\n" + - "lr Recursively list current directory.\n" + - "mkdir DIR [DIR...] Create directories DIR in current directory.\n" + - "mkfile FILE [FILE...] Create files FILE in current directory.\n" + - "rm NAME [NAME...] Delete directory or file NAME (rm * to delete all).\n" + - "cat FILE List the contents of FILE.\n" + - "write FILE [STRING...] Write STRING to FILE.\n" + - "exit, quit Exit this program.\n"); - } - - void - list(boolean recursive) - { - try - { - list(_dirs.get(0), recursive, 0); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - list(Filesystem.DirectoryPrx dir, boolean recursive, int depth) - { - StringBuilder b = new StringBuilder(); - for(int i = 0; i < depth; ++i) - { - b.append('\t'); - } - String indent = b.toString(); - - NodeDesc[] contents = dir.list(); - - for(int i = 0; i < contents.length; ++i) - { - DirectoryPrx d - = contents[i].type == NodeType.DirType - ? DirectoryPrxHelper.uncheckedCast(contents[i].proxy) - : null; - System.out.print(indent + contents[i].name + (d != null ? " (directory)" : " (file)")); - if(d != null && recursive) - { - System.out.println(":"); - list(d, true, ++depth); - } - else - { - System.out.println(); - } - } - } - - void - createFile(java.util.List<String> names) - { - DirectoryPrx dir = _dirs.getFirst(); - - for(String name : names) - { - if(name.equals("..")) - { - System.out.println("Cannot create a file named `..'"); - continue; - } - - try - { - dir.createFile(name); - } - catch(NameInUse ex) - { - System.out.println("`" + name + "' exists already"); - } - } - } - - void - createDir(java.util.List<String> names) - { - DirectoryPrx dir = _dirs.getFirst(); - - for(String name : names) - { - if(name.equals("..")) - { - System.out.println("Cannot create a directory named `..'"); - continue; - } - - try - { - dir.createDirectory(name); - } - catch(NameInUse ex) - { - System.out.println("`" + name + "' exists already"); - } - } - } - - void - pwd() - { - if(_dirs.size() == 1) - { - System.out.print("/"); - } - else - { - java.util.ListIterator<DirectoryPrx> i = _dirs.listIterator(_dirs.size()); - i.previous(); - while(i.hasPrevious()) - { - System.out.print("/" + i.previous().name()); - } - } - System.out.println(); - } - - void - cd(String name) - { - if(name.equals("/")) - { - while(_dirs.size() > 1) - { - _dirs.removeFirst(); - } - return; - } - - if(name.equals("..")) - { - if(_dirs.size() > 1) - { - _dirs.removeFirst(); - } - return; - } - - DirectoryPrx dir = _dirs.getFirst(); - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such directory"); - return; - } - if(d.type == NodeType.FileType) - { - System.out.println("`" + name + "': not a directory"); - return; - } - _dirs.addFirst(DirectoryPrxHelper.uncheckedCast(d.proxy)); - } - - void - cat(String name) - { - DirectoryPrx dir = _dirs.getFirst(); - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such file"); - return; - } - if(d.type == NodeType.DirType) - { - System.out.println("`" + name + "': not a file"); - return; - } - FilePrx f = FilePrxHelper.uncheckedCast(d.proxy); - String[] l = f.read(); - for(int i = 0; i < l.length; ++i) - { - System.out.println(l[i]); - } - } - - void - write(java.util.LinkedList<String> args) - { - DirectoryPrx dir = _dirs.getFirst(); - String name = args.getFirst(); - args.removeFirst(); - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such file"); - return; - } - if(d.type == NodeType.DirType) - { - System.out.println("`" + name + "': not a file"); - return; - } - FilePrx f = FilePrxHelper.uncheckedCast(d.proxy); - - String[] l = args.toArray(new String[0]); - try - { - f.write(l); - } - catch(GenericError ex) - { - System.out.println("`" + name + "': cannot write to file: " + ex.reason); - } - } - - void - destroy(java.util.List<String> names) - { - DirectoryPrx dir = _dirs.getFirst(); - - for(String name : names) - { - if(name.equals("*")) - { - NodeDesc[] nodes = dir.list(); - for(NodeDesc node : nodes) - { - try - { - node.proxy.destroy(); - } - catch(PermissionDenied ex) - { - System.out.println("cannot remove `" + node.name + "': " + ex.reason); - } - } - return; - } - else - { - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such file or directory"); - return; - } - try - { - d.proxy.destroy(); - } - catch(PermissionDenied ex) - { - System.out.println("cannot remove `" + name + "': " + ex.reason); - } - } - } - } - - void - error(String s) - { - System.err.println("error: " + s); - } - - void - warning(String s) - { - System.err.println("warning: " + s); - } - - String - getInput() - { - System.out.print("> "); - System.out.flush(); - - try - { - return _in.readLine(); - } - catch(java.io.IOException e) - { - return null; - } - } - - int - parse() - { - _in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - int - parse(java.io.BufferedReader in) - { - _in = in; - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - private java.util.LinkedList<DirectoryPrx> _dirs; - - private java.io.BufferedReader _in; -} diff --git a/java/demo/Manual/evictor_filesystem/PersistentFilesystem.ice b/java/demo/Manual/evictor_filesystem/PersistentFilesystem.ice deleted file mode 100644 index b1334994276..00000000000 --- a/java/demo/Manual/evictor_filesystem/PersistentFilesystem.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 - -#include <Filesystem.ice> - -module Filesystem -{ - class PersistentDirectory; - - class PersistentNode implements Node - { - string nodeName; - PersistentDirectory* parent; - }; - - class PersistentFile extends PersistentNode implements File - { - Lines text; - }; - - dictionary<string, NodeDesc> NodeDict; - - class PersistentDirectory extends PersistentNode implements Directory - { - ["freeze:write"] - void removeNode(string name); - - NodeDict nodes; - }; -}; diff --git a/java/demo/Manual/evictor_filesystem/README b/java/demo/Manual/evictor_filesystem/README deleted file mode 100644 index 73ff1f9f14d..00000000000 --- a/java/demo/Manual/evictor_filesystem/README +++ /dev/null @@ -1,11 +0,0 @@ -This demo presents an alternate implementation of the filesystem -application using a Freeze evictor, as discussed in the Freeze chapter -of the Ice manual. - -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/evictor_filesystem/Scanner.java b/java/demo/Manual/evictor_filesystem/Scanner.java deleted file mode 100644 index 18ac8eacf09..00000000000 --- a/java/demo/Manual/evictor_filesystem/Scanner.java +++ /dev/null @@ -1,283 +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. -// -// ********************************************************************** - -class Scanner -{ - Scanner(Parser p) - { - _parser = p; - } - - Token - nextToken() - { - String s = next(); - if(s == null) - { - return null; - } - - if(s.equals(";")) - { - return new Token(Token.TOK_SEMI); - } - else if(s.equals("help")) - { - return new Token(Token.TOK_HELP); - } - else if(s.equals("exit") || s.equals("quit")) - { - return new Token(Token.TOK_EXIT); - } - else if(s.equals("ls")) - { - return new Token(Token.TOK_LIST); - } - else if(s.equals("lr")) - { - return new Token(Token.TOK_LIST_RECURSIVE); - } - else if(s.equals("mkfile")) - { - return new Token(Token.TOK_CREATE_FILE); - } - else if(s.equals("mkdir")) - { - return new Token(Token.TOK_CREATE_DIR); - } - else if(s.equals("pwd")) - { - return new Token(Token.TOK_PWD); - } - else if(s.equals("cd")) - { - return new Token(Token.TOK_CD); - } - else if(s.equals("cat")) - { - return new Token(Token.TOK_CAT); - } - else if(s.equals("write")) - { - return new Token(Token.TOK_WRITE); - } - else if(s.equals("rm")) - { - return new Token(Token.TOK_RM); - } - else - { - return new Token(Token.TOK_STRING, s); - } - } - - static private class EndOfInput extends Exception - { - } - - private char - get() - throws EndOfInput - { - // - // If there is an character in the unget buffer, return it. - // - if(_unget) - { - _unget = false; - return _ungetChar; - } - - // - // No current buffer? - // - if(_buf == null) - { - _buf = _parser.getInput(); - _pos = 0; - if(_buf == null) - { - throw new EndOfInput(); - } - } - - // - // At the end-of-buffer? - // - while(_pos >= _buf.length()) - { - _buf = null; - _pos = 0; - return '\n'; - } - - return _buf.charAt(_pos++); - } - - // - // unget only works with one character. - // - private void - unget(char c) - { - assert(!_unget); - _unget = true; - _ungetChar = c; - } - - private String - next() - { - // - // Eat any whitespace. - // - char c; - try - { - do - { - c = get(); - } - while(Character.isWhitespace(c) && c != '\n'); - } - catch(EndOfInput ignore) - { - return null; - } - - StringBuilder buf = new StringBuilder(128); - - if(c == ';' || c == '\n') - { - buf.append(';'); - } - else if(c == '\'') - { - try - { - while(true) - { - c = get(); - if(c == '\'') - { - break; - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else if(c == '\"') - { - try - { - while(true) - { - c = get(); - if(c == '\"') - { - break; - } - else if(c == '\\') - { - try - { - char next = get(); - switch(next) - { - case '\\': - case '"': - { - buf.append(next); - break; - } - - case 'n': - { - buf.append('\n'); - break; - } - - case 'r': - { - buf.append('\r'); - break; - } - - case 't': - { - buf.append('\t'); - break; - } - - case 'f': - { - buf.append('\f'); - break; - } - - default: - { - buf.append(c); - unget(next); - } - } - } - catch(EndOfInput e) - { - buf.append(c); - } - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else - { - // - // Otherwise it's a string. - // - try - { - do - { - buf.append(c); - c = get(); - } - while(!Character.isWhitespace(c) && c != ';' && c != '\n'); - - unget(c); - } - catch(EndOfInput ignore) - { - } - } - - return buf.toString(); - } - - private Parser _parser; - private boolean _unget = false; - private char _ungetChar; - private String _buf = null; - private int _pos; -} diff --git a/java/demo/Manual/evictor_filesystem/Server.java b/java/demo/Manual/evictor_filesystem/Server.java deleted file mode 100644 index cc84dec9ffe..00000000000 --- a/java/demo/Manual/evictor_filesystem/Server.java +++ /dev/null @@ -1,82 +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 - Server(String envName) - { - _envName = envName; - } - - @Override - public int - run(String[] args) - { - // - // Install object factories. - // - Ice.ObjectFactory factory = new NodeFactory(); - communicator().addObjectFactory(factory, PersistentFile.ice_staticId()); - communicator().addObjectFactory(factory, PersistentDirectory.ice_staticId()); - - // - // Create an object adapter. - // - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("EvictorFilesystem"); - - // - // Create the Freeze evictor (stored in the _evictor - // static member). - // - Freeze.Evictor evictor = Freeze.Util.createTransactionalEvictor(adapter, _envName, "evictorfs", - null, null, null, true); - DirectoryI._evictor = evictor; - FileI._evictor = evictor; - - adapter.addServantLocator(evictor, ""); - - // - // Create the root node if it doesn't exist. - // - Ice.Identity rootId = new Ice.Identity(); - rootId.name = "RootDir"; - if(!evictor.hasObject(rootId)) - { - PersistentDirectory root = new DirectoryI(); - root.nodeName = "/"; - root.nodes = new java.util.HashMap<java.lang.String, NodeDesc>(); - evictor.add(root, rootId); - } - - // - // Ready to accept requests now. - // - adapter.activate(); - - // - // Wait until we are done. - // - communicator().waitForShutdown(); - - return 0; - } - - public static void - main(String[] args) - { - Server app = new Server("db"); - int status = app.main("demo.book.evictor_filesystem.Server", args, "config.server"); - System.exit(status); - } - - private String _envName; -} diff --git a/java/demo/Manual/evictor_filesystem/Token.java b/java/demo/Manual/evictor_filesystem/Token.java deleted file mode 100644 index bcbb7baf96e..00000000000 --- a/java/demo/Manual/evictor_filesystem/Token.java +++ /dev/null @@ -1,40 +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. -// -// ********************************************************************** - -class Token -{ - public static final int TOK_HELP = 0; - public static final int TOK_EXIT = 1; - public static final int TOK_SEMI = 2; - public static final int TOK_LIST = 3; - public static final int TOK_LIST_RECURSIVE = 4; - public static final int TOK_CREATE_FILE = 5; - public static final int TOK_CREATE_DIR = 6; - public static final int TOK_PWD = 7; - public static final int TOK_CD = 8; - public static final int TOK_CAT = 9; - public static final int TOK_WRITE = 10; - public static final int TOK_RM = 11; - public static final int TOK_STRING = 12; - - int type; - String value; - - Token(int t) - { - type = t; - value = null; - } - - Token(int t, String v) - { - type = t; - value = v; - } -} diff --git a/java/demo/Manual/evictor_filesystem/config.client b/java/demo/Manual/evictor_filesystem/config.client deleted file mode 100644 index 640cfade4f1..00000000000 --- a/java/demo/Manual/evictor_filesystem/config.client +++ /dev/null @@ -1,28 +0,0 @@ -# -# The client reads this property to create the reference to the root -# "directory" object in the server. -# -RootDir.Proxy=RootDir:default -h localhost -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/Manual/evictor_filesystem/config.server b/java/demo/Manual/evictor_filesystem/config.server deleted file mode 100644 index 69e536ab202..00000000000 --- a/java/demo/Manual/evictor_filesystem/config.server +++ /dev/null @@ -1,49 +0,0 @@ -# -# Configure the server endpoints. -# -EvictorFilesystem.Endpoints=default -h localhost -p 10000 - -# -# Freeze Map Tracing. -# -# 0 = No map activity trace (default). -# 1 = Trace database open and close. -# 2 = Also trace iterator and transaction operations, and reference -# counting of the underlying database. -# -Freeze.Trace.Map=1 - -# -# Freeze Evictor Tracing. -# -# 0 = No evictor activity trace (default). -# 1 = Trace Ice object and facet creation and destruction, facet -# streaming time, facet saving time, object eviction (every 50 -# objects) and evictor deactivation. -# 2 = Also trace object lookups, and all object evictions. -# 3 = Also trace object retrieval from the database. -# -Freeze.Trace.Evictor=2 - -# -# 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/Manual/evictor_filesystem/db/.gitignore b/java/demo/Manual/evictor_filesystem/db/.gitignore deleted file mode 100644 index 39af5887579..00000000000 --- a/java/demo/Manual/evictor_filesystem/db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# Dummy file, so that git retains this otherwise empty directory. diff --git a/java/demo/Manual/evictor_filesystem/expect.py b/java/demo/Manual/evictor_filesystem/expect.py deleted file mode 100755 index 0c682a99f07..00000000000 --- a/java/demo/Manual/evictor_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 - -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 -from demoscript.manual import evictor_filesystem - -sys.stdout.write("cleaning databases... ") -sys.stdout.flush() -Util.cleanDbDir("db") -print("ok") - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar') - -evictor_filesystem.run(client, server) diff --git a/java/demo/Manual/lifecycle/.externalToolBuilders/demo.book.lifecycle.slice.launch b/java/demo/Manual/lifecycle/.externalToolBuilders/demo.book.lifecycle.slice.launch deleted file mode 100644 index f4da860e3df..00000000000 --- a/java/demo/Manual/lifecycle/.externalToolBuilders/demo.book.lifecycle.slice.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="${project}"/> -<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.lifecycle"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.book.lifecycle/Filesystem.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.book.lifecycle/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/lifecycle/Client.java b/java/demo/Manual/lifecycle/Client.java deleted file mode 100644 index 161c775fe14..00000000000 --- a/java/demo/Manual/lifecycle/Client.java +++ /dev/null @@ -1,55 +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 extends Ice.Application -{ - @Override - public int - run(String[] args) - { - // - // Terminate cleanly on receipt of a signal. - // - shutdownOnInterrupt(); - - // - // Create a proxy for the root directory - // - Ice.ObjectPrx base = communicator().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 Error("Invalid proxy"); - } - - Parser p = new Parser(rootDir); - return p.parse(); - } - - static public void - main(String[] args) - { - Client app = new Client(); - app.main("demo.book.lifecycle.Client", args); - } - - static private class Error extends RuntimeException - { - public Error(String msg) - { - super(msg); - } - } -} diff --git a/java/demo/Manual/lifecycle/Filesystem.ice b/java/demo/Manual/lifecycle/Filesystem.ice deleted file mode 100644 index dd81204e1de..00000000000 --- a/java/demo/Manual/lifecycle/Filesystem.ice +++ /dev/null @@ -1,54 +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; - }; - exception PermissionDenied extends GenericError {}; - exception NameInUse extends GenericError {}; - exception NoSuchName extends GenericError {}; - - interface Node - { - idempotent string name(); - void destroy() throws PermissionDenied; - }; - - sequence<string> Lines; - - interface File extends Node - { - idempotent Lines read(); - idempotent void write(Lines text) throws GenericError; - }; - - enum NodeType { DirType, FileType }; - - struct NodeDesc - { - string name; - NodeType type; - Node* proxy; - }; - - sequence<NodeDesc> NodeDescSeq; - - interface Directory extends Node - { - idempotent NodeDescSeq list(); - idempotent NodeDesc find(string name) throws NoSuchName; - File* createFile(string name) throws NameInUse; - Directory* createDirectory(string name) throws NameInUse; - }; -}; diff --git a/java/demo/Manual/lifecycle/FilesystemI/DirectoryI.java b/java/demo/Manual/lifecycle/FilesystemI/DirectoryI.java deleted file mode 100644 index e852a6a3a83..00000000000 --- a/java/demo/Manual/lifecycle/FilesystemI/DirectoryI.java +++ /dev/null @@ -1,189 +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 FilesystemI; - -import Ice.*; -import Filesystem.*; - -public class DirectoryI extends _DirectoryDisp implements NodeI -{ - - // Slice name() operation. - - public synchronized String - name(Current c) - { - if(_destroyed) - { - throw new ObjectNotExistException(); - } - return _name; - } - - // Return the object identity for this node. - - public Identity - id() - { - return _id; - } - - // Slice list() operation. - - public synchronized NodeDesc[] - list(Current c) - { - if(_destroyed) - { - throw new ObjectNotExistException(); - } - - NodeDesc[] ret = new NodeDesc[_contents.size()]; - java.util.Iterator<java.util.Map.Entry<String, NodeI> > pos = _contents.entrySet().iterator(); - for(int i = 0; i < _contents.size(); ++i) - { - java.util.Map.Entry<String, NodeI> e = pos.next(); - NodeI p = e.getValue(); - ret[i] = new NodeDesc(); - ret[i].name = e.getKey(); - ret[i].type = p instanceof FileI ? NodeType.FileType : NodeType.DirType; - ret[i].proxy = NodePrxHelper.uncheckedCast(c.adapter.createProxy(p.id())); - } - return ret; - } - - // Slice find() operation. - - public synchronized NodeDesc - find(String name, Current c) throws NoSuchName - { - if(_destroyed) - { - throw new ObjectNotExistException(); - } - - NodeI p = _contents.get(name); - if(p == null) - { - throw new NoSuchName(name); - } - - NodeDesc d = new NodeDesc(); - d.name = name; - d.type = p instanceof FileI ? NodeType.FileType : NodeType.DirType; - d.proxy = NodePrxHelper.uncheckedCast(c.adapter.createProxy(p.id())); - return d; - } - - // Slice createFile() operation. - - public synchronized FilePrx - createFile(String name, Current c) throws NameInUse - { - if(_destroyed) - { - throw new ObjectNotExistException(); - } - - if(name.length() == 0 || _contents.containsKey(name)) - { - throw new NameInUse(name); - } - - FileI f = new FileI(name, this); - ObjectPrx node = c.adapter.add(f, f.id()); - _contents.put(name, f); - return FilePrxHelper.uncheckedCast(node); - } - - // Slice createDirectory() operation. - - public synchronized DirectoryPrx - createDirectory(String name, Current c) throws NameInUse - { - if(_destroyed) - { - throw new ObjectNotExistException(); - } - - if(name.length() == 0 || _contents.containsKey(name)) - { - throw new NameInUse(name); - } - - DirectoryI d = new DirectoryI(name, this); - ObjectPrx node = c.adapter.add(d, d.id()); - _contents.put(name, d); - return DirectoryPrxHelper.uncheckedCast(node); - } - - // Slice destroy() operation. - - public void - destroy(Current c) throws PermissionDenied - { - if(_parent == null) - { - throw new PermissionDenied("Cannot destroy root directory"); - } - - synchronized(this) - { - if(_destroyed) - { - throw new ObjectNotExistException(); - } - - if(_contents.size() != 0) - { - throw new PermissionDenied("Cannot destroy non-empty directory"); - } - - c.adapter.remove(id()); - _destroyed = true; - } - - _parent.removeEntry(_name); - } - - // DirectoryI constructor for root directory. - - public DirectoryI() - { - this("/", null); - } - - // DirectoryI constructor. parent == null indicates root directory. - - public DirectoryI(String name, DirectoryI parent) - { - _name = name; - _parent = parent; - _id = new Identity(); - _destroyed = false; - _contents = new java.util.HashMap<String, NodeI>(); - - _id.name = parent == null ? "RootDir" : java.util.UUID.randomUUID().toString(); - } - - // Remove the entry from the _contents map. - - public synchronized void - removeEntry(String name) - { - _contents.remove(name); - } - - private String _name; // Immutable - private DirectoryI _parent; // Immutable - private Identity _id; // Immutable - private boolean _destroyed; - private java.util.Map<String, NodeI> _contents; -} diff --git a/java/demo/Manual/lifecycle/FilesystemI/FileI.java b/java/demo/Manual/lifecycle/FilesystemI/FileI.java deleted file mode 100644 index 02853ee2d80..00000000000 --- a/java/demo/Manual/lifecycle/FilesystemI/FileI.java +++ /dev/null @@ -1,86 +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 FilesystemI; - -import Ice.*; -import Filesystem.*; - -public class FileI extends _FileDisp implements NodeI -{ - public synchronized String - name(Current c) - { - if(_destroyed) - { - throw new ObjectNotExistException(); - } - return _name; - } - - public Identity - id() - { - return _id; - } - - public synchronized String[] - read(Current c) - { - if(_destroyed) - { - throw new ObjectNotExistException(); - } - - return _lines; - } - - public synchronized void - write(String[] text, Current c) - { - if(_destroyed) - { - throw new ObjectNotExistException(); - } - - _lines = (String[])text.clone(); - } - - public void - destroy(Current c) - { - synchronized(this) - { - if(_destroyed) - { - throw new ObjectNotExistException(); - } - - c.adapter.remove(id()); - _destroyed = true; - } - - _parent.removeEntry(_name); - } - - public FileI(String name, DirectoryI parent) - { - _name = name; - _parent = parent; - _destroyed = false; - _id = new Identity(); - _id.name = java.util.UUID.randomUUID().toString(); - } - - private String _name; - private DirectoryI _parent; - private boolean _destroyed; - private Identity _id; - private String[] _lines; -} diff --git a/java/demo/Manual/lifecycle/FilesystemI/NodeI.java b/java/demo/Manual/lifecycle/FilesystemI/NodeI.java deleted file mode 100644 index 6bc951395e0..00000000000 --- a/java/demo/Manual/lifecycle/FilesystemI/NodeI.java +++ /dev/null @@ -1,15 +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 FilesystemI; - -public interface NodeI -{ - Ice.Identity id(); -} diff --git a/java/demo/Manual/lifecycle/Grammar.java b/java/demo/Manual/lifecycle/Grammar.java deleted file mode 100644 index 57f046c62e3..00000000000 --- a/java/demo/Manual/lifecycle/Grammar.java +++ /dev/null @@ -1,202 +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. -// -// ********************************************************************** - -class Grammar -{ - Grammar(Parser p) - { - _parser = p; - _scanner = new Scanner(_parser); - } - - void - parse() - { - while(true) - { - try - { - _token = _scanner.nextToken(); - if(_token == null) - { - return; - } - else if(_token.type == Token.TOK_SEMI) - { - // Continue - } - else if(_token.type == Token.TOK_HELP) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.usage(); - } - else if(_token.type == Token.TOK_EXIT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - return; - } - else if(_token.type == Token.TOK_LIST) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.list(false); - } - else if(_token.type == Token.TOK_LIST_RECURSIVE) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.list(true); - } - else if(_token.type == Token.TOK_CREATE_FILE) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: mkfile FILE [FILE...]"); - } - _parser.createFile(s); - } - else if(_token.type == Token.TOK_CREATE_DIR) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: mkdir DIR [DIR...]"); - } - _parser.createDir(s); - } - else if(_token.type == Token.TOK_PWD) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.pwd(); - } - else if(_token.type == Token.TOK_CD) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() > 1) - { - throw new ParseError("usage: cd [DIR]"); - } - else if(s.size() == 0) - { - _parser.cd("/"); - } - else - { - _parser.cd(s.get(0)); - } - } - else if(_token.type == Token.TOK_CAT) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() != 1) - { - throw new ParseError("usage: cat FILE"); - } - _parser.cat(s.get(0)); - } - else if(_token.type == Token.TOK_WRITE) - { - java.util.LinkedList<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: write FILE [STRING...]"); - } - _parser.write(s); - } - else if(_token.type == Token.TOK_RM) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: rm NAME [NAME...]"); - } - _parser.destroy(s); - } - else - { - _parser.error("parse error"); - } - } - catch(ParseError e) - { - _parser.error("Parse error: " + e.getMessage()); - } - } - } - - private java.util.LinkedList<String> - strings() - { - java.util.LinkedList<String> l = new java.util.LinkedList<String>(); - while(true) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_STRING) - { - return l; - } - l.add(_token.value); - } - } - - static private class ParseError extends RuntimeException - { - ParseError(String msg) - { - super(msg); - } - } - - private Parser _parser; - private Scanner _scanner; - private Token _token; -} diff --git a/java/demo/Manual/lifecycle/Parser.java b/java/demo/Manual/lifecycle/Parser.java deleted file mode 100644 index 5e7854156aa..00000000000 --- a/java/demo/Manual/lifecycle/Parser.java +++ /dev/null @@ -1,349 +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.*; - -class Parser -{ - Parser(DirectoryPrx root) - { - _dirs = new java.util.LinkedList<DirectoryPrx>(); - _dirs.addFirst(root); - } - - void - usage() - { - System.err.print( - "help Print this message.\n" + - "pwd Print current directory (/ = root).\n" + - "cd [DIR] Change directory (/ or empty = root).\n" + - "ls List current directory.\n" + - "lr Recursively list current directory.\n" + - "mkdir DIR [DIR...] Create directories DIR in current directory.\n" + - "mkfile FILE [FILE...] Create files FILE in current directory.\n" + - "rm NAME [NAME...] Delete directory or file NAME (rm * to delete all).\n" + - "cat FILE List the contents of FILE.\n" + - "write FILE [STRING...] Write STRING to FILE.\n" + - "exit, quit Exit this program.\n"); - } - - void - list(boolean recursive) - { - try - { - list(_dirs.get(0), recursive, 0); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - list(Filesystem.DirectoryPrx dir, boolean recursive, int depth) - { - StringBuilder b = new StringBuilder(); - for(int i = 0; i < depth; ++i) - { - b.append('\t'); - } - String indent = b.toString(); - - NodeDesc[] contents = dir.list(); - - for(int i = 0; i < contents.length; ++i) - { - DirectoryPrx d - = contents[i].type == NodeType.DirType - ? DirectoryPrxHelper.uncheckedCast(contents[i].proxy) - : null; - System.out.print(indent + contents[i].name + (d != null ? " (directory)" : " (file)")); - if(d != null && recursive) - { - System.out.println(":"); - list(d, true, ++depth); - } - else - { - System.out.println(); - } - } - } - - void - createFile(java.util.List<String> names) - { - DirectoryPrx dir = _dirs.getFirst(); - - for(String name : names) - { - if(name.equals("..")) - { - System.out.println("Cannot create a file named `..'"); - continue; - } - - try - { - dir.createFile(name); - } - catch(NameInUse ex) - { - System.out.println("`" + name + "' exists already"); - } - } - } - - void - createDir(java.util.List<String> names) - { - DirectoryPrx dir = _dirs.getFirst(); - - for(String name : names) - { - if(name.equals("..")) - { - System.out.println("Cannot create a directory named `..'"); - continue; - } - - try - { - dir.createDirectory(name); - } - catch(NameInUse ex) - { - System.out.println("`" + name + "' exists already"); - } - } - } - - void - pwd() - { - if(_dirs.size() == 1) - { - System.out.print("/"); - } - else - { - java.util.ListIterator<DirectoryPrx> i = _dirs.listIterator(_dirs.size()); - i.previous(); - while(i.hasPrevious()) - { - System.out.print("/" + i.previous().name()); - } - } - System.out.println(); - } - - void - cd(String name) - { - if(name.equals("/")) - { - while(_dirs.size() > 1) - { - _dirs.removeFirst(); - } - return; - } - - if(name.equals("..")) - { - if(_dirs.size() > 1) - { - _dirs.removeFirst(); - } - return; - } - - DirectoryPrx dir = _dirs.getFirst(); - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such directory"); - return; - } - if(d.type == NodeType.FileType) - { - System.out.println("`" + name + "': not a directory"); - return; - } - _dirs.addFirst(DirectoryPrxHelper.uncheckedCast(d.proxy)); - } - - void - cat(String name) - { - DirectoryPrx dir = _dirs.getFirst(); - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such file"); - return; - } - if(d.type == NodeType.DirType) - { - System.out.println("`" + name + "': not a file"); - return; - } - FilePrx f = FilePrxHelper.uncheckedCast(d.proxy); - String[] l = f.read(); - for(int i = 0; i < l.length; ++i) - { - System.out.println(l[i]); - } - } - - void - write(java.util.LinkedList<String> args) - { - DirectoryPrx dir = _dirs.getFirst(); - String name = args.getFirst(); - args.removeFirst(); - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such file"); - return; - } - if(d.type == NodeType.DirType) - { - System.out.println("`" + name + "': not a file"); - return; - } - FilePrx f = FilePrxHelper.uncheckedCast(d.proxy); - - String[] l = args.toArray(new String[0]); - try - { - f.write(l); - } - catch(GenericError ex) - { - System.out.println("`" + name + "': cannot write to file: " + ex.reason); - } - } - - void - destroy(java.util.List<String> names) - { - DirectoryPrx dir = _dirs.getFirst(); - - for(String name : names) - { - if(name.equals("*")) - { - NodeDesc[] nodes = dir.list(); - for(NodeDesc node : nodes) - { - try - { - node.proxy.destroy(); - } - catch(PermissionDenied ex) - { - System.out.println("cannot remove `" + node.name + "': " + ex.reason); - } - } - return; - } - else - { - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such file or directory"); - return; - } - try - { - d.proxy.destroy(); - } - catch(PermissionDenied ex) - { - System.out.println("cannot remove `" + name + "': " + ex.reason); - } - } - } - } - - void - error(String s) - { - System.err.println("error: " + s); - } - - void - warning(String s) - { - System.err.println("warning: " + s); - } - - String - getInput() - { - System.out.print("> "); - System.out.flush(); - - try - { - return _in.readLine(); - } - catch(java.io.IOException e) - { - return null; - } - } - - int - parse() - { - _in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - int - parse(java.io.BufferedReader in) - { - _in = in; - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - private java.util.LinkedList<DirectoryPrx> _dirs; - - private java.io.BufferedReader _in; -} diff --git a/java/demo/Manual/lifecycle/README b/java/demo/Manual/lifecycle/README deleted file mode 100644 index ea985301bfd..00000000000 --- a/java/demo/Manual/lifecycle/README +++ /dev/null @@ -1,11 +0,0 @@ -This demo implements the file system with life cycle support. - -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 - -Type "help" at the client prompt to see a list of commands. diff --git a/java/demo/Manual/lifecycle/Scanner.java b/java/demo/Manual/lifecycle/Scanner.java deleted file mode 100644 index 18ac8eacf09..00000000000 --- a/java/demo/Manual/lifecycle/Scanner.java +++ /dev/null @@ -1,283 +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. -// -// ********************************************************************** - -class Scanner -{ - Scanner(Parser p) - { - _parser = p; - } - - Token - nextToken() - { - String s = next(); - if(s == null) - { - return null; - } - - if(s.equals(";")) - { - return new Token(Token.TOK_SEMI); - } - else if(s.equals("help")) - { - return new Token(Token.TOK_HELP); - } - else if(s.equals("exit") || s.equals("quit")) - { - return new Token(Token.TOK_EXIT); - } - else if(s.equals("ls")) - { - return new Token(Token.TOK_LIST); - } - else if(s.equals("lr")) - { - return new Token(Token.TOK_LIST_RECURSIVE); - } - else if(s.equals("mkfile")) - { - return new Token(Token.TOK_CREATE_FILE); - } - else if(s.equals("mkdir")) - { - return new Token(Token.TOK_CREATE_DIR); - } - else if(s.equals("pwd")) - { - return new Token(Token.TOK_PWD); - } - else if(s.equals("cd")) - { - return new Token(Token.TOK_CD); - } - else if(s.equals("cat")) - { - return new Token(Token.TOK_CAT); - } - else if(s.equals("write")) - { - return new Token(Token.TOK_WRITE); - } - else if(s.equals("rm")) - { - return new Token(Token.TOK_RM); - } - else - { - return new Token(Token.TOK_STRING, s); - } - } - - static private class EndOfInput extends Exception - { - } - - private char - get() - throws EndOfInput - { - // - // If there is an character in the unget buffer, return it. - // - if(_unget) - { - _unget = false; - return _ungetChar; - } - - // - // No current buffer? - // - if(_buf == null) - { - _buf = _parser.getInput(); - _pos = 0; - if(_buf == null) - { - throw new EndOfInput(); - } - } - - // - // At the end-of-buffer? - // - while(_pos >= _buf.length()) - { - _buf = null; - _pos = 0; - return '\n'; - } - - return _buf.charAt(_pos++); - } - - // - // unget only works with one character. - // - private void - unget(char c) - { - assert(!_unget); - _unget = true; - _ungetChar = c; - } - - private String - next() - { - // - // Eat any whitespace. - // - char c; - try - { - do - { - c = get(); - } - while(Character.isWhitespace(c) && c != '\n'); - } - catch(EndOfInput ignore) - { - return null; - } - - StringBuilder buf = new StringBuilder(128); - - if(c == ';' || c == '\n') - { - buf.append(';'); - } - else if(c == '\'') - { - try - { - while(true) - { - c = get(); - if(c == '\'') - { - break; - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else if(c == '\"') - { - try - { - while(true) - { - c = get(); - if(c == '\"') - { - break; - } - else if(c == '\\') - { - try - { - char next = get(); - switch(next) - { - case '\\': - case '"': - { - buf.append(next); - break; - } - - case 'n': - { - buf.append('\n'); - break; - } - - case 'r': - { - buf.append('\r'); - break; - } - - case 't': - { - buf.append('\t'); - break; - } - - case 'f': - { - buf.append('\f'); - break; - } - - default: - { - buf.append(c); - unget(next); - } - } - } - catch(EndOfInput e) - { - buf.append(c); - } - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else - { - // - // Otherwise it's a string. - // - try - { - do - { - buf.append(c); - c = get(); - } - while(!Character.isWhitespace(c) && c != ';' && c != '\n'); - - unget(c); - } - catch(EndOfInput ignore) - { - } - } - - return buf.toString(); - } - - private Parser _parser; - private boolean _unget = false; - private char _ungetChar; - private String _buf = null; - private int _pos; -} diff --git a/java/demo/Manual/lifecycle/Server.java b/java/demo/Manual/lifecycle/Server.java deleted file mode 100644 index 515a74eac6e..00000000000 --- a/java/demo/Manual/lifecycle/Server.java +++ /dev/null @@ -1,60 +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 FilesystemI.*; - -class Server extends Ice.Application -{ - @Override - public int - run(String[] args) - { - // - // Terminate cleanly on receipt of a signal. - // - shutdownOnInterrupt(); - - // - // Create an object adapter - // - Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints( - "LifecycleFilesystem", "default -h localhost -p 10000"); - - // - // Create the root directory. - // - DirectoryI root = new DirectoryI(); - Ice.Identity id = new Ice.Identity(); - id.name = "RootDir"; - adapter.add(root, id); - - // - // All objects are created, allow client requests now. - // - adapter.activate(); - - // - // Wait until we are done. - // - communicator().waitForShutdown(); - if(interrupted()) - { - System.err.println(appName() + ": received signal, shutting down"); - } - - return 0; - } - - static public void - main(String[] args) - { - Server app = new Server(); - app.main("demo.book.lifecycle.Server", args); - } -} diff --git a/java/demo/Manual/lifecycle/Token.java b/java/demo/Manual/lifecycle/Token.java deleted file mode 100644 index bcbb7baf96e..00000000000 --- a/java/demo/Manual/lifecycle/Token.java +++ /dev/null @@ -1,40 +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. -// -// ********************************************************************** - -class Token -{ - public static final int TOK_HELP = 0; - public static final int TOK_EXIT = 1; - public static final int TOK_SEMI = 2; - public static final int TOK_LIST = 3; - public static final int TOK_LIST_RECURSIVE = 4; - public static final int TOK_CREATE_FILE = 5; - public static final int TOK_CREATE_DIR = 6; - public static final int TOK_PWD = 7; - public static final int TOK_CD = 8; - public static final int TOK_CAT = 9; - public static final int TOK_WRITE = 10; - public static final int TOK_RM = 11; - public static final int TOK_STRING = 12; - - int type; - String value; - - Token(int t) - { - type = t; - value = null; - } - - Token(int t, String v) - { - type = t; - value = v; - } -} diff --git a/java/demo/Manual/lifecycle/expect.py b/java/demo/Manual/lifecycle/expect.py deleted file mode 100755 index e2a601a96c6..00000000000 --- a/java/demo/Manual/lifecycle/expect.py +++ /dev/null @@ -1,29 +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 - -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 -from demoscript.manual import lifecycle - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar') - -lifecycle.run(client, server) diff --git a/java/demo/Manual/map_filesystem/.externalToolBuilders/demo.book.map_filesystem.launch b/java/demo/Manual/map_filesystem/.externalToolBuilders/demo.book.map_filesystem.launch deleted file mode 100644 index abe7897ac17..00000000000 --- a/java/demo/Manual/map_filesystem/.externalToolBuilders/demo.book.map_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="${project}"/> -<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.map_filesystem"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.book.map_filesystem/Filesystem.ice" type="1"/> <item path="/demo.book.map_filesystem/FilesystemDB.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.book.map_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/map_filesystem/.gitignore b/java/demo/Manual/map_filesystem/.gitignore deleted file mode 100644 index 9c39416c539..00000000000 --- a/java/demo/Manual/map_filesystem/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db/* diff --git a/java/demo/Manual/map_filesystem/Client.java b/java/demo/Manual/map_filesystem/Client.java deleted file mode 100644 index 5a424bedc85..00000000000 --- a/java/demo/Manual/map_filesystem/Client.java +++ /dev/null @@ -1,50 +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 extends Ice.Application -{ - @Override - public int - run(String[] args) - { - // - // Terminate cleanly on receipt of a signal. - // - shutdownOnInterrupt(); - - // - // Create a proxy for the root directory - // - DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(communicator().propertyToProxy("RootDir.Proxy")); - if(rootDir == null) - { - throw new Error("Client: invalid proxy"); - } - - Parser p = new Parser(rootDir); - return p.parse(); - } - - static public void - main(String[] args) - { - Client app = new Client(); - app.main("demo.book.map_filesystem.Client", args, "config.client"); - } - - static private class Error extends RuntimeException - { - public Error(String msg) - { - super(msg); - } - } -} diff --git a/java/demo/Manual/map_filesystem/DirectoryI.java b/java/demo/Manual/map_filesystem/DirectoryI.java deleted file mode 100644 index 708a73984f3..00000000000 --- a/java/demo/Manual/map_filesystem/DirectoryI.java +++ /dev/null @@ -1,407 +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.*; -import FilesystemDB.*; - -public class DirectoryI extends _DirectoryDisp -{ - public - DirectoryI(Ice.Communicator communicator, String envName) - { - _communicator = communicator; - _envName = envName; - - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityDirectoryEntryMap dirDB = new IdentityDirectoryEntryMap(connection, directoriesDB()); - - // - // Create the record for the root directory if necessary. - // - for(;;) - { - try - { - Ice.Identity rootId = new Ice.Identity("RootDir", ""); - DirectoryEntry entry = dirDB.get(rootId); - if(entry == null) - { - dirDB.put(rootId, new DirectoryEntry("/", new Ice.Identity("", ""), null)); - } - break; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - } - } - finally - { - connection.close(); - } - } - - @Override - public String - name(Ice.Current c) - { - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityDirectoryEntryMap dirDB = new IdentityDirectoryEntryMap(connection, directoriesDB()); - - for(;;) - { - try - { - DirectoryEntry entry = dirDB.get(c.id); - if(entry == null) - { - throw new Ice.ObjectNotExistException(); - } - return entry.name; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - } - } - finally - { - connection.close(); - } - } - - @Override - public NodeDesc[] - list(Ice.Current c) - { - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityDirectoryEntryMap dirDB = new IdentityDirectoryEntryMap(connection, directoriesDB()); - - for(;;) - { - try - { - DirectoryEntry entry = dirDB.get(c.id); - if(entry == null) - { - throw new Ice.ObjectNotExistException(); - } - NodeDesc[] result = new NodeDesc[entry.nodes.size()]; - java.util.Iterator<NodeDesc> p = entry.nodes.values().iterator(); - for(int i = 0; i < entry.nodes.size(); ++i) - { - result[i] = p.next(); - } - return result; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - } - } - finally - { - connection.close(); - } - } - - @Override - public NodeDesc - find(String name, Ice.Current c) - throws NoSuchName - { - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityDirectoryEntryMap dirDB = new IdentityDirectoryEntryMap(connection, directoriesDB()); - - for(;;) - { - try - { - DirectoryEntry entry = dirDB.get(c.id); - if(entry == null) - { - throw new Ice.ObjectNotExistException(); - } - NodeDesc nd = entry.nodes.get(name); - if(nd == null) - { - throw new NoSuchName(name); - } - return nd; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - } - } - finally - { - connection.close(); - } - } - - @Override - public FilePrx - createFile(String name, Ice.Current c) - throws NameInUse - { - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityFileEntryMap fileDB = new IdentityFileEntryMap(connection, FileI.filesDB()); - IdentityDirectoryEntryMap dirDB = new IdentityDirectoryEntryMap(connection, directoriesDB()); - - for(;;) - { - // - // The transaction is necessary since we are altering - // two records in one atomic action. - // - Freeze.Transaction txn = null; - try - { - txn = connection.beginTransaction(); - DirectoryEntry entry = dirDB.get(c.id); - if(entry == null) - { - throw new Ice.ObjectNotExistException(); - } - if(name.length() == 0 || entry.nodes.get(name) != null) - { - throw new NameInUse(name); - } - - FileEntry newEntry = new FileEntry(name, c.id, null); - Ice.Identity id = new Ice.Identity(java.util.UUID.randomUUID().toString(), "file"); - FilePrx proxy = FilePrxHelper.uncheckedCast(c.adapter.createProxy(id)); - - entry.nodes.put(name, new NodeDesc(name, NodeType.FileType, proxy)); - dirDB.put(c.id, entry); - - fileDB.put(id, newEntry); - - txn.commit(); - txn = null; - - return proxy; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - finally - { - if(txn != null) - { - txn.rollback(); - } - } - } - } - finally - { - connection.close(); - } - } - - @Override - public DirectoryPrx - createDirectory(String name, Ice.Current c) - throws NameInUse - { - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityDirectoryEntryMap dirDB = new IdentityDirectoryEntryMap(connection, directoriesDB()); - - for(;;) - { - // - // The transaction is necessary since we are altering - // two records in one atomic action. - // - Freeze.Transaction txn = null; - try - { - txn = connection.beginTransaction(); - DirectoryEntry entry = dirDB.get(c.id); - if(entry == null) - { - throw new Ice.ObjectNotExistException(); - } - if(name.length() == 0 || entry.nodes.get(name) != null) - { - throw new NameInUse(name); - } - - DirectoryEntry newEntry = new DirectoryEntry(name, c.id, null); - Ice.Identity id = new Ice.Identity(java.util.UUID.randomUUID().toString(), ""); - DirectoryPrx proxy = DirectoryPrxHelper.uncheckedCast(c.adapter.createProxy(id)); - - entry.nodes.put(name, new NodeDesc(name, NodeType.DirType, proxy)); - dirDB.put(c.id, entry); - - dirDB.put(id, newEntry); - - txn.commit(); - txn = null; - - return proxy; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - finally - { - if(txn != null) - { - txn.rollback(); - } - } - } - } - finally - { - connection.close(); - } - } - - @Override - public void - destroy(Ice.Current c) - throws PermissionDenied - { - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityDirectoryEntryMap dirDB = new IdentityDirectoryEntryMap(connection, directoriesDB()); - - for(;;) - { - // - // The transaction is necessary since we are altering - // two records in one atomic action. - // - Freeze.Transaction txn = null; - try - { - txn = connection.beginTransaction(); - DirectoryEntry entry = dirDB.get(c.id); - if(entry == null) - { - throw new Ice.ObjectNotExistException(); - } - if(entry.parent.name.length() == 0) - { - throw new PermissionDenied("Cannot destroy root directory"); - } - if(!entry.nodes.isEmpty()) - { - throw new PermissionDenied("Cannot destroy non-empty directory"); - } - - DirectoryEntry dirEntry = dirDB.get(entry.parent); - if(dirEntry == null) - { - halt(new Freeze.DatabaseException("consistency error: directory without parent")); - } - - dirEntry.nodes.remove(entry.name); - dirDB.put(entry.parent, dirEntry); - - dirDB.remove(c.id); - - txn.commit(); - txn = null; - break; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - finally - { - if(txn != null) - { - txn.rollback(); - } - } - } - } - finally - { - connection.close(); - } - } - - private void - halt(Freeze.DatabaseException e) - { - // - // If this is called it's very bad news. We log the error and - // then kill the server. - // - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - e.printStackTrace(pw); - pw.flush(); - _communicator.getLogger().error("fatal database error\n" + sw.toString() + "\n*** Halting JVM ***"); - Runtime.getRuntime().halt(1); - } - - public static String - directoriesDB() - { - return "directories"; - } - - private Ice.Communicator _communicator; - private String _envName; -} diff --git a/java/demo/Manual/map_filesystem/FileI.java b/java/demo/Manual/map_filesystem/FileI.java deleted file mode 100644 index 3381d17e5c1..00000000000 --- a/java/demo/Manual/map_filesystem/FileI.java +++ /dev/null @@ -1,221 +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.*; -import FilesystemDB.*; - -public class FileI extends _FileDisp -{ - public - FileI(Ice.Communicator communicator, String envName) - { - _communicator = communicator; - _envName = envName; - } - - @Override - public String - name(Ice.Current c) - { - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityFileEntryMap fileDB = new IdentityFileEntryMap(connection, filesDB()); - - for(;;) - { - try - { - FileEntry entry = fileDB.get(c.id); - if(entry == null) - { - throw new Ice.ObjectNotExistException(); - } - return entry.name; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - } - } - finally - { - connection.close(); - } - } - - @Override - public String[] - read(Ice.Current c) - { - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityFileEntryMap fileDB = new IdentityFileEntryMap(connection, filesDB()); - - for(;;) - { - try - { - FileEntry entry = fileDB.get(c.id); - if(entry == null) - { - throw new Ice.ObjectNotExistException(); - } - return entry.text; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - } - } - finally - { - connection.close(); - } - } - - @Override - public void - write(String[] text, Ice.Current c) - throws GenericError - { - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityFileEntryMap fileDB = new IdentityFileEntryMap(connection, filesDB()); - - for(;;) - { - try - { - FileEntry entry = fileDB.get(c.id); - if(entry == null) - { - throw new Ice.ObjectNotExistException(); - } - entry.text = text; - fileDB.put(c.id, entry); - break; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - } - } - finally - { - connection.close(); - } - } - - @Override - public void - destroy(Ice.Current c) - throws PermissionDenied - { - Freeze.Connection connection = Freeze.Util.createConnection(_communicator, _envName); - try - { - IdentityFileEntryMap fileDB = new IdentityFileEntryMap(connection, filesDB()); - IdentityDirectoryEntryMap dirDB = new IdentityDirectoryEntryMap(connection, DirectoryI.directoriesDB()); - - for(;;) - { - Freeze.Transaction txn = null; - try - { - // - // The transaction is necessary since we are - // altering two records in one atomic action. - // - txn = connection.beginTransaction(); - FileEntry entry = fileDB.get(c.id); - if(entry == null) - { - throw new Ice.ObjectNotExistException(); - } - - DirectoryEntry dirEntry = dirDB.get(entry.parent); - if(dirEntry == null) - { - halt(new Freeze.DatabaseException("consistency error: file without parent")); - } - - dirEntry.nodes.remove(entry.name); - dirDB.put(entry.parent, dirEntry); - - fileDB.remove(c.id); - - txn.commit(); - txn = null; - break; - } - catch(Freeze.DeadlockException ex) - { - continue; - } - catch(Freeze.DatabaseException ex) - { - halt(ex); - } - finally - { - if(txn != null) - { - txn.rollback(); - } - } - } - } - finally - { - connection.close(); - } - } - - public static String - filesDB() - { - return "files"; - } - - private void - halt(Freeze.DatabaseException e) - { - // - // If this is called it's very bad news. We log the error and - // then kill the server. - // - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - e.printStackTrace(pw); - pw.flush(); - _communicator.getLogger().error("fatal database error\n" + sw.toString() + "\n*** Halting JVM ***"); - Runtime.getRuntime().halt(1); - } - - private Ice.Communicator _communicator; - private String _envName; -} diff --git a/java/demo/Manual/map_filesystem/Filesystem.ice b/java/demo/Manual/map_filesystem/Filesystem.ice deleted file mode 100644 index dd81204e1de..00000000000 --- a/java/demo/Manual/map_filesystem/Filesystem.ice +++ /dev/null @@ -1,54 +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; - }; - exception PermissionDenied extends GenericError {}; - exception NameInUse extends GenericError {}; - exception NoSuchName extends GenericError {}; - - interface Node - { - idempotent string name(); - void destroy() throws PermissionDenied; - }; - - sequence<string> Lines; - - interface File extends Node - { - idempotent Lines read(); - idempotent void write(Lines text) throws GenericError; - }; - - enum NodeType { DirType, FileType }; - - struct NodeDesc - { - string name; - NodeType type; - Node* proxy; - }; - - sequence<NodeDesc> NodeDescSeq; - - interface Directory extends Node - { - idempotent NodeDescSeq list(); - idempotent NodeDesc find(string name) throws NoSuchName; - File* createFile(string name) throws NameInUse; - Directory* createDirectory(string name) throws NameInUse; - }; -}; diff --git a/java/demo/Manual/map_filesystem/FilesystemDB.ice b/java/demo/Manual/map_filesystem/FilesystemDB.ice deleted file mode 100644 index e50f64d4f43..00000000000 --- a/java/demo/Manual/map_filesystem/FilesystemDB.ice +++ /dev/null @@ -1,31 +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 - -#include <Filesystem.ice> -#include <Ice/Identity.ice> - -module FilesystemDB -{ - struct FileEntry - { - string name; - Ice::Identity parent; - Filesystem::Lines text; - }; - - dictionary<string, Filesystem::NodeDesc> StringNodeDescDict; - struct DirectoryEntry - { - string name; - Ice::Identity parent; - StringNodeDescDict nodes; - }; -}; diff --git a/java/demo/Manual/map_filesystem/Grammar.java b/java/demo/Manual/map_filesystem/Grammar.java deleted file mode 100644 index 57f046c62e3..00000000000 --- a/java/demo/Manual/map_filesystem/Grammar.java +++ /dev/null @@ -1,202 +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. -// -// ********************************************************************** - -class Grammar -{ - Grammar(Parser p) - { - _parser = p; - _scanner = new Scanner(_parser); - } - - void - parse() - { - while(true) - { - try - { - _token = _scanner.nextToken(); - if(_token == null) - { - return; - } - else if(_token.type == Token.TOK_SEMI) - { - // Continue - } - else if(_token.type == Token.TOK_HELP) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.usage(); - } - else if(_token.type == Token.TOK_EXIT) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - return; - } - else if(_token.type == Token.TOK_LIST) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.list(false); - } - else if(_token.type == Token.TOK_LIST_RECURSIVE) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.list(true); - } - else if(_token.type == Token.TOK_CREATE_FILE) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: mkfile FILE [FILE...]"); - } - _parser.createFile(s); - } - else if(_token.type == Token.TOK_CREATE_DIR) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: mkdir DIR [DIR...]"); - } - _parser.createDir(s); - } - else if(_token.type == Token.TOK_PWD) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - _parser.pwd(); - } - else if(_token.type == Token.TOK_CD) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() > 1) - { - throw new ParseError("usage: cd [DIR]"); - } - else if(s.size() == 0) - { - _parser.cd("/"); - } - else - { - _parser.cd(s.get(0)); - } - } - else if(_token.type == Token.TOK_CAT) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() != 1) - { - throw new ParseError("usage: cat FILE"); - } - _parser.cat(s.get(0)); - } - else if(_token.type == Token.TOK_WRITE) - { - java.util.LinkedList<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: write FILE [STRING...]"); - } - _parser.write(s); - } - else if(_token.type == Token.TOK_RM) - { - java.util.List<String> s = strings(); - if(_token.type != Token.TOK_SEMI) - { - throw new ParseError("Expected ';'"); - } - if(s.size() == 0) - { - throw new ParseError("usage: rm NAME [NAME...]"); - } - _parser.destroy(s); - } - else - { - _parser.error("parse error"); - } - } - catch(ParseError e) - { - _parser.error("Parse error: " + e.getMessage()); - } - } - } - - private java.util.LinkedList<String> - strings() - { - java.util.LinkedList<String> l = new java.util.LinkedList<String>(); - while(true) - { - _token = _scanner.nextToken(); - if(_token.type != Token.TOK_STRING) - { - return l; - } - l.add(_token.value); - } - } - - static private class ParseError extends RuntimeException - { - ParseError(String msg) - { - super(msg); - } - } - - private Parser _parser; - private Scanner _scanner; - private Token _token; -} diff --git a/java/demo/Manual/map_filesystem/Parser.java b/java/demo/Manual/map_filesystem/Parser.java deleted file mode 100644 index 5e7854156aa..00000000000 --- a/java/demo/Manual/map_filesystem/Parser.java +++ /dev/null @@ -1,349 +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.*; - -class Parser -{ - Parser(DirectoryPrx root) - { - _dirs = new java.util.LinkedList<DirectoryPrx>(); - _dirs.addFirst(root); - } - - void - usage() - { - System.err.print( - "help Print this message.\n" + - "pwd Print current directory (/ = root).\n" + - "cd [DIR] Change directory (/ or empty = root).\n" + - "ls List current directory.\n" + - "lr Recursively list current directory.\n" + - "mkdir DIR [DIR...] Create directories DIR in current directory.\n" + - "mkfile FILE [FILE...] Create files FILE in current directory.\n" + - "rm NAME [NAME...] Delete directory or file NAME (rm * to delete all).\n" + - "cat FILE List the contents of FILE.\n" + - "write FILE [STRING...] Write STRING to FILE.\n" + - "exit, quit Exit this program.\n"); - } - - void - list(boolean recursive) - { - try - { - list(_dirs.get(0), recursive, 0); - } - catch(Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void - list(Filesystem.DirectoryPrx dir, boolean recursive, int depth) - { - StringBuilder b = new StringBuilder(); - for(int i = 0; i < depth; ++i) - { - b.append('\t'); - } - String indent = b.toString(); - - NodeDesc[] contents = dir.list(); - - for(int i = 0; i < contents.length; ++i) - { - DirectoryPrx d - = contents[i].type == NodeType.DirType - ? DirectoryPrxHelper.uncheckedCast(contents[i].proxy) - : null; - System.out.print(indent + contents[i].name + (d != null ? " (directory)" : " (file)")); - if(d != null && recursive) - { - System.out.println(":"); - list(d, true, ++depth); - } - else - { - System.out.println(); - } - } - } - - void - createFile(java.util.List<String> names) - { - DirectoryPrx dir = _dirs.getFirst(); - - for(String name : names) - { - if(name.equals("..")) - { - System.out.println("Cannot create a file named `..'"); - continue; - } - - try - { - dir.createFile(name); - } - catch(NameInUse ex) - { - System.out.println("`" + name + "' exists already"); - } - } - } - - void - createDir(java.util.List<String> names) - { - DirectoryPrx dir = _dirs.getFirst(); - - for(String name : names) - { - if(name.equals("..")) - { - System.out.println("Cannot create a directory named `..'"); - continue; - } - - try - { - dir.createDirectory(name); - } - catch(NameInUse ex) - { - System.out.println("`" + name + "' exists already"); - } - } - } - - void - pwd() - { - if(_dirs.size() == 1) - { - System.out.print("/"); - } - else - { - java.util.ListIterator<DirectoryPrx> i = _dirs.listIterator(_dirs.size()); - i.previous(); - while(i.hasPrevious()) - { - System.out.print("/" + i.previous().name()); - } - } - System.out.println(); - } - - void - cd(String name) - { - if(name.equals("/")) - { - while(_dirs.size() > 1) - { - _dirs.removeFirst(); - } - return; - } - - if(name.equals("..")) - { - if(_dirs.size() > 1) - { - _dirs.removeFirst(); - } - return; - } - - DirectoryPrx dir = _dirs.getFirst(); - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such directory"); - return; - } - if(d.type == NodeType.FileType) - { - System.out.println("`" + name + "': not a directory"); - return; - } - _dirs.addFirst(DirectoryPrxHelper.uncheckedCast(d.proxy)); - } - - void - cat(String name) - { - DirectoryPrx dir = _dirs.getFirst(); - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such file"); - return; - } - if(d.type == NodeType.DirType) - { - System.out.println("`" + name + "': not a file"); - return; - } - FilePrx f = FilePrxHelper.uncheckedCast(d.proxy); - String[] l = f.read(); - for(int i = 0; i < l.length; ++i) - { - System.out.println(l[i]); - } - } - - void - write(java.util.LinkedList<String> args) - { - DirectoryPrx dir = _dirs.getFirst(); - String name = args.getFirst(); - args.removeFirst(); - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such file"); - return; - } - if(d.type == NodeType.DirType) - { - System.out.println("`" + name + "': not a file"); - return; - } - FilePrx f = FilePrxHelper.uncheckedCast(d.proxy); - - String[] l = args.toArray(new String[0]); - try - { - f.write(l); - } - catch(GenericError ex) - { - System.out.println("`" + name + "': cannot write to file: " + ex.reason); - } - } - - void - destroy(java.util.List<String> names) - { - DirectoryPrx dir = _dirs.getFirst(); - - for(String name : names) - { - if(name.equals("*")) - { - NodeDesc[] nodes = dir.list(); - for(NodeDesc node : nodes) - { - try - { - node.proxy.destroy(); - } - catch(PermissionDenied ex) - { - System.out.println("cannot remove `" + node.name + "': " + ex.reason); - } - } - return; - } - else - { - NodeDesc d; - try - { - d = dir.find(name); - } - catch(NoSuchName ex) - { - System.out.println("`" + name + "': no such file or directory"); - return; - } - try - { - d.proxy.destroy(); - } - catch(PermissionDenied ex) - { - System.out.println("cannot remove `" + name + "': " + ex.reason); - } - } - } - } - - void - error(String s) - { - System.err.println("error: " + s); - } - - void - warning(String s) - { - System.err.println("warning: " + s); - } - - String - getInput() - { - System.out.print("> "); - System.out.flush(); - - try - { - return _in.readLine(); - } - catch(java.io.IOException e) - { - return null; - } - } - - int - parse() - { - _in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - int - parse(java.io.BufferedReader in) - { - _in = in; - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - private java.util.LinkedList<DirectoryPrx> _dirs; - - private java.io.BufferedReader _in; -} diff --git a/java/demo/Manual/map_filesystem/README b/java/demo/Manual/map_filesystem/README deleted file mode 100644 index f1b64f52ed4..00000000000 --- a/java/demo/Manual/map_filesystem/README +++ /dev/null @@ -1,11 +0,0 @@ -This demo presents an alternate implementation of the filesystem -application using a Freeze map, as discussed in the Freeze chapter of -the Ice manual. - -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/map_filesystem/Scanner.java b/java/demo/Manual/map_filesystem/Scanner.java deleted file mode 100644 index 18ac8eacf09..00000000000 --- a/java/demo/Manual/map_filesystem/Scanner.java +++ /dev/null @@ -1,283 +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. -// -// ********************************************************************** - -class Scanner -{ - Scanner(Parser p) - { - _parser = p; - } - - Token - nextToken() - { - String s = next(); - if(s == null) - { - return null; - } - - if(s.equals(";")) - { - return new Token(Token.TOK_SEMI); - } - else if(s.equals("help")) - { - return new Token(Token.TOK_HELP); - } - else if(s.equals("exit") || s.equals("quit")) - { - return new Token(Token.TOK_EXIT); - } - else if(s.equals("ls")) - { - return new Token(Token.TOK_LIST); - } - else if(s.equals("lr")) - { - return new Token(Token.TOK_LIST_RECURSIVE); - } - else if(s.equals("mkfile")) - { - return new Token(Token.TOK_CREATE_FILE); - } - else if(s.equals("mkdir")) - { - return new Token(Token.TOK_CREATE_DIR); - } - else if(s.equals("pwd")) - { - return new Token(Token.TOK_PWD); - } - else if(s.equals("cd")) - { - return new Token(Token.TOK_CD); - } - else if(s.equals("cat")) - { - return new Token(Token.TOK_CAT); - } - else if(s.equals("write")) - { - return new Token(Token.TOK_WRITE); - } - else if(s.equals("rm")) - { - return new Token(Token.TOK_RM); - } - else - { - return new Token(Token.TOK_STRING, s); - } - } - - static private class EndOfInput extends Exception - { - } - - private char - get() - throws EndOfInput - { - // - // If there is an character in the unget buffer, return it. - // - if(_unget) - { - _unget = false; - return _ungetChar; - } - - // - // No current buffer? - // - if(_buf == null) - { - _buf = _parser.getInput(); - _pos = 0; - if(_buf == null) - { - throw new EndOfInput(); - } - } - - // - // At the end-of-buffer? - // - while(_pos >= _buf.length()) - { - _buf = null; - _pos = 0; - return '\n'; - } - - return _buf.charAt(_pos++); - } - - // - // unget only works with one character. - // - private void - unget(char c) - { - assert(!_unget); - _unget = true; - _ungetChar = c; - } - - private String - next() - { - // - // Eat any whitespace. - // - char c; - try - { - do - { - c = get(); - } - while(Character.isWhitespace(c) && c != '\n'); - } - catch(EndOfInput ignore) - { - return null; - } - - StringBuilder buf = new StringBuilder(128); - - if(c == ';' || c == '\n') - { - buf.append(';'); - } - else if(c == '\'') - { - try - { - while(true) - { - c = get(); - if(c == '\'') - { - break; - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else if(c == '\"') - { - try - { - while(true) - { - c = get(); - if(c == '\"') - { - break; - } - else if(c == '\\') - { - try - { - char next = get(); - switch(next) - { - case '\\': - case '"': - { - buf.append(next); - break; - } - - case 'n': - { - buf.append('\n'); - break; - } - - case 'r': - { - buf.append('\r'); - break; - } - - case 't': - { - buf.append('\t'); - break; - } - - case 'f': - { - buf.append('\f'); - break; - } - - default: - { - buf.append(c); - unget(next); - } - } - } - catch(EndOfInput e) - { - buf.append(c); - } - } - else - { - buf.append(c); - } - } - } - catch(EndOfInput e) - { - _parser.warning("EOF in string"); - } - } - else - { - // - // Otherwise it's a string. - // - try - { - do - { - buf.append(c); - c = get(); - } - while(!Character.isWhitespace(c) && c != ';' && c != '\n'); - - unget(c); - } - catch(EndOfInput ignore) - { - } - } - - return buf.toString(); - } - - private Parser _parser; - private boolean _unget = false; - private char _ungetChar; - private String _buf = null; - private int _pos; -} diff --git a/java/demo/Manual/map_filesystem/Server.java b/java/demo/Manual/map_filesystem/Server.java deleted file mode 100644 index b3793185e34..00000000000 --- a/java/demo/Manual/map_filesystem/Server.java +++ /dev/null @@ -1,80 +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 FilesystemDB.*; - -public class Server extends Ice.Application -{ - public - Server(String envName) - { - _envName = envName; - } - - @Override - public int - run(String[] args) - { - // - // Create an object adapter - // - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("MapFilesystem"); - - Freeze.Connection connection = null; - try - { - // - // Open a connection to the files and directories - // database. This should remain open for the duration of the - // application for performance reasons. - // - connection = Freeze.Util.createConnection(communicator(), _envName); - new IdentityFileEntryMap(connection, FileI.filesDB(), true); - new IdentityDirectoryEntryMap(connection, DirectoryI.directoriesDB(), true); - - // - // Add default servants for the file and directory. - // - adapter.addDefaultServant(new FileI(communicator(), _envName), "file"); - adapter.addDefaultServant(new DirectoryI(communicator(), _envName), ""); - - // - // Ready to accept requests now - // - adapter.activate(); - - // - // Wait until we are done - // - communicator().waitForShutdown(); - } - finally - { - // - // Close the connection gracefully. - // - if(connection != null) - { - connection.close(); - } - } - - return 0; - } - - public static void - main(String[] args) - { - Server app = new Server("db"); - app.main("demo.book.map_filesystem.Server", args, "config.server"); - System.exit(0); - } - - private String _envName; -} diff --git a/java/demo/Manual/map_filesystem/Token.java b/java/demo/Manual/map_filesystem/Token.java deleted file mode 100644 index bcbb7baf96e..00000000000 --- a/java/demo/Manual/map_filesystem/Token.java +++ /dev/null @@ -1,40 +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. -// -// ********************************************************************** - -class Token -{ - public static final int TOK_HELP = 0; - public static final int TOK_EXIT = 1; - public static final int TOK_SEMI = 2; - public static final int TOK_LIST = 3; - public static final int TOK_LIST_RECURSIVE = 4; - public static final int TOK_CREATE_FILE = 5; - public static final int TOK_CREATE_DIR = 6; - public static final int TOK_PWD = 7; - public static final int TOK_CD = 8; - public static final int TOK_CAT = 9; - public static final int TOK_WRITE = 10; - public static final int TOK_RM = 11; - public static final int TOK_STRING = 12; - - int type; - String value; - - Token(int t) - { - type = t; - value = null; - } - - Token(int t, String v) - { - type = t; - value = v; - } -} diff --git a/java/demo/Manual/map_filesystem/build.gradle b/java/demo/Manual/map_filesystem/build.gradle deleted file mode 100644 index ece390dfe6b..00000000000 --- a/java/demo/Manual/map_filesystem/build.gradle +++ /dev/null @@ -1,60 +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. -// -// ********************************************************************** - -slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } - freezej { - files = [file("FilesystemDB.ice"), - file("${sliceDir}/Ice/Identity.ice")] - include = ["${projectDir}"] - args = "--ice" - dict { - IdentityFileEntryMap { - javaType = "FilesystemDB.IdentityFileEntryMap" - key = "Ice::Identity" - value = "FilesystemDB::FileEntry" - } - IdentityDirectoryEntryMap { - javaType = "FilesystemDB.IdentityDirectoryEntryMap" - key="Ice::Identity" - value="FilesystemDB::DirectoryEntry" - } - } - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - compile localDependency("ice") - compile localDependency("freeze") - compile files(dbJar) - if (!useLocalOnly) { - runtime "org.apache.tools:bzip2:1.0" - } -} - -clean { - delete fileTree(dir: 'db', excludes:['.gitignore', 'DB_CONFIG']) -} - -// Don't create the default jar. -jar.enabled = false - -demoJar("client") -demoJar("server") diff --git a/java/demo/Manual/map_filesystem/config.client b/java/demo/Manual/map_filesystem/config.client deleted file mode 100644 index 640cfade4f1..00000000000 --- a/java/demo/Manual/map_filesystem/config.client +++ /dev/null @@ -1,28 +0,0 @@ -# -# The client reads this property to create the reference to the root -# "directory" object in the server. -# -RootDir.Proxy=RootDir:default -h localhost -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/Manual/map_filesystem/config.server b/java/demo/Manual/map_filesystem/config.server deleted file mode 100644 index c8694039614..00000000000 --- a/java/demo/Manual/map_filesystem/config.server +++ /dev/null @@ -1,37 +0,0 @@ -# -# Configure the server endpoints. -# -MapFilesystem.Endpoints=default -h localhost -p 10000 - -# -# Freeze Map Tracing. -# -# 0 = No map activity trace (default). -# 1 = Trace database open and close. -# 2 = Also trace iterator and transaction operations, and reference -# counting of the underlying database. -# -Freeze.Trace.Map=1 - -# -# 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/Manual/map_filesystem/db/.gitignore b/java/demo/Manual/map_filesystem/db/.gitignore deleted file mode 100644 index 39af5887579..00000000000 --- a/java/demo/Manual/map_filesystem/db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# Dummy file, so that git retains this otherwise empty directory. diff --git a/java/demo/Manual/map_filesystem/expect.py b/java/demo/Manual/map_filesystem/expect.py deleted file mode 100755 index 87081be4973..00000000000 --- a/java/demo/Manual/map_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 - -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 -from demoscript.manual import map_filesystem - -sys.stdout.write("cleaning databases... ") -sys.stdout.flush() -Util.cleanDbDir("db") -print("ok") - -server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady') -server.expect('.* ready') -client = Util.spawn('java -jar build/libs/client.jar') - -map_filesystem.run(client, server) diff --git a/java/demo/Manual/printer/.externalToolBuilders/demo.book.printer.launch b/java/demo/Manual/printer/.externalToolBuilders/demo.book.printer.launch deleted file mode 100644 index b8b0aefe5db..00000000000 --- a/java/demo/Manual/printer/.externalToolBuilders/demo.book.printer.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="${project}"/> -<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.printer"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.book.printer/Printer.ice" type="1"/> </resources>}"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.book.printer/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/printer/Client.java b/java/demo/Manual/printer/Client.java deleted file mode 100644 index fbd9960b476..00000000000 --- a/java/demo/Manual/printer/Client.java +++ /dev/null @@ -1,53 +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. -// -// ********************************************************************** - -public class Client -{ - public static void - main(String[] args) - { - int status = 0; - Ice.Communicator ic = null; - try - { - ic = Ice.Util.initialize(args); - Ice.ObjectPrx base = ic.stringToProxy("SimplePrinter:default -h localhost -p 10000"); - Demo.PrinterPrx printer = Demo.PrinterPrxHelper.checkedCast(base); - if(printer == null) - { - throw new Error("Invalid proxy"); - } - - printer.printString("Hello World!"); - } - 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/printer/Printer.ice b/java/demo/Manual/printer/Printer.ice deleted file mode 100755 index faa2238ac80..00000000000 --- a/java/demo/Manual/printer/Printer.ice +++ /dev/null @@ -1,20 +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 Demo -{ - - interface Printer - { - void printString(string s); - }; - -}; diff --git a/java/demo/Manual/printer/PrinterI.java b/java/demo/Manual/printer/PrinterI.java deleted file mode 100644 index 53b74efc97b..00000000000 --- a/java/demo/Manual/printer/PrinterI.java +++ /dev/null @@ -1,17 +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. -// -// ********************************************************************** - -public class PrinterI extends Demo._PrinterDisp -{ - public void - printString(String s, Ice.Current current) - { - System.out.println(s); - } -} diff --git a/java/demo/Manual/printer/README b/java/demo/Manual/printer/README deleted file mode 100644 index 8a89f134050..00000000000 --- a/java/demo/Manual/printer/README +++ /dev/null @@ -1,8 +0,0 @@ -This demo implements the printer example in chapter 3 of the -documentation. To run it, start the server in a window: - -$ java -jar build/libs/server.jar - -In a separate window, run the client: - -$ java -jar build/libs/client.jar diff --git a/java/demo/Manual/printer/Server.java b/java/demo/Manual/printer/Server.java deleted file mode 100644 index f8f756206f1..00000000000 --- a/java/demo/Manual/printer/Server.java +++ /dev/null @@ -1,45 +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. -// -// ********************************************************************** - -public class Server -{ - public static void - main(String[] args) - { - int status = 0; - Ice.Communicator ic = null; - try - { - ic = Ice.Util.initialize(args); - Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -h localhost -p 10000"); - Ice.Object object = new PrinterI(); - adapter.add(object, ic.stringToIdentity("SimplePrinter")); - adapter.activate(); - ic.waitForShutdown(); - } - catch(Exception e) - { - e.printStackTrace(); - 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/printer/expect.py b/java/demo/Manual/printer/expect.py deleted file mode 100755 index f65a140f2dc..00000000000 --- a/java/demo/Manual/printer/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.waitTestSuccess() -server.expect('Hello World!') -server.kill(signal.SIGINT) -server.waitTestSuccess() -print("ok") 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:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/demo.book.simple_filesystem/Filesystem.ice" type="1"/> </resources>}"/> -<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") diff --git a/java/demo/README b/java/demo/README deleted file mode 100644 index 59e44463dfa..00000000000 --- a/java/demo/README +++ /dev/null @@ -1,12 +0,0 @@ -This directory contains demos for various Ice components. The demos -are provided to get you started on how to use a particular feature or -coding technique. See the README file in each subdirectory for details -on the demos. - -The Manual directory contains demos for some of the code examples in -the Ice manual available online: - - https://doc.zeroc.com/display/Ice/Ice+Manual - -For more examples of the features of the Ice services (Glacier2, -IceGrid, IceStorm) please see the Ice for C++ demos. diff --git a/java/settings.gradle b/java/settings.gradle index 8bd67c74ddc..7844e9b219c 100644 --- a/java/settings.gradle +++ b/java/settings.gradle @@ -39,36 +39,3 @@ include ':testPlugins' project(':testPlugins').projectDir = new File('test/plugins') include ':testController' project(':testController').projectDir = new File('test/controller') - -// Map of dir->subdir for each of the demos. -def demos = [ - 'Ice' : ['async', 'bidir', 'callback', 'hello', 'invoke', - 'interrupt', 'latency', 'minimal', 'multicast', 'nested', - 'plugin', 'properties', 'serialize','session', 'swing', - 'throughput', 'value', 'optional','context'], - 'IceDiscovery' : ['hello', 'replication'], - 'Database' : ['library'], - 'Freeze' : ['bench', 'casino', 'library', 'phonebook', 'transform'], - 'IceBox' : ['hello'], - 'Glacier2' : ['callback', 'chat', 'voip'], - 'IceStorm' : ['clock'], - 'IceGrid' : ['icebox', 'simple'], - 'Manual' : ['evictor_filesystem', 'lifecycle', 'map_filesystem', 'printer', 'simple_filesystem'] -] - -demos.each { - def dir = it.key - def subdirs = it.value - - subdirs.each { - // abc_def -> AbcDef - def name = it.split('_').collect { it.capitalize() }.join() - - // A project in directory xyz is demoXyzAbcDef - def projectName = ":demo${dir.capitalize()}${name}" - include projectName - - // The directory is demo/<dir>/<name>. - project("${projectName}").projectDir = new File("demo/${dir}/${it}") - } -} |