From 5b42fa9250d89b8060cad4de729ab793f5eac7d4 Mon Sep 17 00:00:00 2001 From: Joe George Date: Fri, 31 May 2024 12:18:15 -0400 Subject: [PATCH 01/17] Add Java CI --- .github/workflows/ci.yml | 11 +- java/Chat/build.gradle | 1 - java/Database/README.md | 6 - java/Database/library/BookI.java | 389 ---------------- java/Database/library/BookQueryResultI.java | 74 ---- java/Database/library/Client.java | 34 -- java/Database/library/ConnectionPool.java | 148 ------- .../library/DispatchInterceptorI.java | 65 --- java/Database/library/Glacier2Session.ice | 33 -- .../library/Glacier2SessionManagerI.java | 105 ----- java/Database/library/Grammar.java | 169 ------- java/Database/library/Library.ice | 290 ------------ java/Database/library/LibraryI.java | 364 --------------- java/Database/library/Parser.java | 416 ------------------ java/Database/library/README.md | 121 ----- java/Database/library/RunParser.java | 160 ------- java/Database/library/SQLRequestContext.java | 138 ------ java/Database/library/Scanner.java | 274 ------------ java/Database/library/Server.java | 134 ------ java/Database/library/Session.ice | 56 --- java/Database/library/SessionFactoryI.java | 63 --- java/Database/library/SessionI.java | 50 --- java/Database/library/SessionManager.java | 8 - java/Database/library/Token.java | 35 -- java/Database/library/books | 30 -- java/Database/library/build.gradle | 32 -- java/Database/library/config.client | 56 --- java/Database/library/config.glacier2 | 50 --- java/Database/library/config.server | 74 ---- java/Database/library/createTypes.sql | 38 -- java/Glacier2/build.gradle | 1 - java/Ice/build.gradle | 1 - java/Ice/properties/Props.ice | 2 +- java/Ice/swing/build.gradle | 1 - java/IceBox/hello/build.gradle | 1 - java/IceDiscovery/build.gradle | 1 - java/IceGrid/build.gradle | 3 +- java/IceStorm/clock/build.gradle | 1 - java/Manual/README.md | 4 - java/Manual/build.gradle | 3 +- java/Manual/lifecycle/Client.java | 48 -- java/Manual/lifecycle/DirectoryI.java | 178 -------- java/Manual/lifecycle/FileI.java | 74 ---- java/Manual/lifecycle/Filesystem.ice | 50 --- java/Manual/lifecycle/Grammar.java | 195 -------- java/Manual/lifecycle/NodeI.java | 8 - java/Manual/lifecycle/Parser.java | 333 -------------- java/Manual/lifecycle/README.md | 17 - java/Manual/lifecycle/Scanner.java | 274 ------------ java/Manual/lifecycle/Server.java | 60 --- java/Manual/lifecycle/Token.java | 35 -- java/android/hello/build.gradle | 1 - java/gradle/ice.gradle | 1 - java/settings.gradle | 3 +- 54 files changed, 12 insertions(+), 4707 deletions(-) delete mode 100644 java/Database/README.md delete mode 100644 java/Database/library/BookI.java delete mode 100644 java/Database/library/BookQueryResultI.java delete mode 100644 java/Database/library/Client.java delete mode 100644 java/Database/library/ConnectionPool.java delete mode 100644 java/Database/library/DispatchInterceptorI.java delete mode 100644 java/Database/library/Glacier2Session.ice delete mode 100644 java/Database/library/Glacier2SessionManagerI.java delete mode 100644 java/Database/library/Grammar.java delete mode 100644 java/Database/library/Library.ice delete mode 100644 java/Database/library/LibraryI.java delete mode 100644 java/Database/library/Parser.java delete mode 100644 java/Database/library/README.md delete mode 100644 java/Database/library/RunParser.java delete mode 100644 java/Database/library/SQLRequestContext.java delete mode 100644 java/Database/library/Scanner.java delete mode 100644 java/Database/library/Server.java delete mode 100644 java/Database/library/Session.ice delete mode 100644 java/Database/library/SessionFactoryI.java delete mode 100644 java/Database/library/SessionI.java delete mode 100644 java/Database/library/SessionManager.java delete mode 100644 java/Database/library/Token.java delete mode 100644 java/Database/library/books delete mode 100644 java/Database/library/build.gradle delete mode 100644 java/Database/library/config.client delete mode 100644 java/Database/library/config.glacier2 delete mode 100644 java/Database/library/config.server delete mode 100644 java/Database/library/createTypes.sql delete mode 100644 java/Manual/lifecycle/Client.java delete mode 100644 java/Manual/lifecycle/DirectoryI.java delete mode 100644 java/Manual/lifecycle/FileI.java delete mode 100644 java/Manual/lifecycle/Filesystem.ice delete mode 100644 java/Manual/lifecycle/Grammar.java delete mode 100644 java/Manual/lifecycle/NodeI.java delete mode 100644 java/Manual/lifecycle/Parser.java delete mode 100644 java/Manual/lifecycle/README.md delete mode 100644 java/Manual/lifecycle/Scanner.java delete mode 100644 java/Manual/lifecycle/Server.java delete mode 100644 java/Manual/lifecycle/Token.java diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 796133fcdb..2fe89b379f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: - name: Build Ice on ${{ matrix.os }} uses: ./ice/.github/actions/build - timeout-minutes: 90 + timeout-minutes: 60 with: working_directory: ice build_flags: ${{ matrix.ice_build_flags || '' }} @@ -62,12 +62,17 @@ jobs: - name: Build C++ Demos on ${{ matrix.os }} uses: ./ice/.github/actions/build - timeout-minutes: 30 + timeout-minutes: 5 with: working_directory: ice-demos/cpp msbuild_project: msbuild/ice.proj - name: Build C# Demos on ${{ matrix.os }} - timeout-minutes: 30 + timeout-minutes: 5 working-directory: ice-demos/csharp run: ${{ matrix.csharp_build_command }} /m msbuild/ice.proj + + - name: Run Java Demos on ${{ matrix.os }} + timeout-minutes: 5 + working-directory: ice-demos/java + run: ./gradlew build diff --git a/java/Chat/build.gradle b/java/Chat/build.gradle index 767e719f2e..152a43cbf9 100644 --- a/java/Chat/build.gradle +++ b/java/Chat/build.gradle @@ -20,7 +20,6 @@ dependencies { implementation 'com.jgoodies:jgoodies-looks:2.6.0' implementation 'com.jgoodies:jgoodies-forms:1.8.0' implementation localDependency("ice") - runtimeOnly localDependency("icessl") implementation localDependency("glacier2") } diff --git a/java/Database/README.md b/java/Database/README.md deleted file mode 100644 index 178c8a0d91..0000000000 --- a/java/Database/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Demos in this directory: - -- [library](./library) - - This demo shows how to implement an Ice server that uses mysql through - a JDBC API. diff --git a/java/Database/library/BookI.java b/java/Database/library/BookI.java deleted file mode 100644 index 29caf07166..0000000000 --- a/java/Database/library/BookI.java +++ /dev/null @@ -1,389 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.demos.Database.library.Demo.*; - -// -// This servant is a default servant. The book identity is retrieved -// from the Ice.Current object. -// -class BookI implements Book -{ - @Override - public void ice_ping(com.zeroc.Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = Integer.valueOf(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 com.zeroc.Ice.ObjectNotExistException(); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public BookDescription describe(com.zeroc.Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = Integer.valueOf(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 com.zeroc.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, com.zeroc.Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = Integer.valueOf(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 com.zeroc.Ice.ObjectNotExistException(); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public void setAuthors(java.util.List authors, com.zeroc.Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = Integer.valueOf(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 com.zeroc.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 authIds = new java.util.LinkedList<>(); - 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(com.zeroc.Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = Integer.valueOf(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 com.zeroc.Ice.ObjectNotExistException(); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public String getRenter(com.zeroc.Ice.Current current) - throws BookNotRentedException - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = Integer.valueOf(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 com.zeroc.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, com.zeroc.Ice.Current current) - throws InvalidCustomerException, BookRentedException - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = Integer.valueOf(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 com.zeroc.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(com.zeroc.Ice.Current current) - throws BookNotRentedException - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - Integer id = Integer.valueOf(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 com.zeroc.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 com.zeroc.Ice.Identity createIdentity(Integer bookId) - { - com.zeroc.Ice.Identity id = new com.zeroc.Ice.Identity(); - id.category = "book"; - id.name = bookId.toString(); - return id; - } - - static BookDescription extractDescription(SQLRequestContext context, java.sql.ResultSet rs, - com.zeroc.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<>(); - desc.proxy = BookPrx.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/Database/library/BookQueryResultI.java b/java/Database/library/BookQueryResultI.java deleted file mode 100644 index 29925a72f6..0000000000 --- a/java/Database/library/BookQueryResultI.java +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.demos.Database.library.Demo.*; - -class BookQueryResultI implements BookQueryResult -{ - BookQueryResultI(SQLRequestContext context, java.sql.ResultSet rs, com.zeroc.Ice.ObjectAdapter adapter) - throws java.sql.SQLException - { - _books = new java.util.Stack<>(); - for(int i = 0; i < MAX_BOOK_QUERY_RESULT; ++i) - { - _books.add(BookI.extractDescription(context, rs, adapter)); - if(!rs.next()) - { - break; - } - } - } - - @Override - synchronized public BookQueryResult.NextResult next(int n, com.zeroc.Ice.Current current) - { - if(_destroyed) - { - throw new com.zeroc.Ice.ObjectNotExistException(); - } - BookQueryResult.NextResult r = new BookQueryResult.NextResult(); - r.destroyed = false; - r.returnValue = new java.util.LinkedList<>(); - if(n <= 0) - { - return r; - } - - for(int i = 0; i < n && _books.size() > 0; ++i) - { - r.returnValue.add(_books.pop()); - } - - if(_books.size() <= 0) - { - try - { - r.destroyed = true; - destroy(current); - } - catch(Exception e) - { - // Ignore. - } - } - - return r; - } - - @Override - synchronized public void destroy(com.zeroc.Ice.Current current) - { - if(_destroyed) - { - throw new com.zeroc.Ice.ObjectNotExistException(); - } - _destroyed = true; - - current.adapter.remove(current.id); - } - - private java.util.Stack _books; - private boolean _destroyed = false; - private static final int MAX_BOOK_QUERY_RESULT = 1000; -} diff --git a/java/Database/library/Client.java b/java/Database/library/Client.java deleted file mode 100644 index dd5d8d013f..0000000000 --- a/java/Database/library/Client.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -public class Client -{ - public static void main(String[] args) - { - int status = 0; - java.util.List extraArgs = new java.util.ArrayList<>(); - - final String appName = "demo.Database.library.Client"; - - // - // Try with resources block - communicator is automatically destroyed - // at the end of this try block - // - try(com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(args, "config.client", extraArgs)) - { - communicator.getProperties().setProperty("Ice.Default.Package", "com.zeroc.demos.Database.library"); - if(extraArgs.size() > 1) - { - System.err.println("Usage: " + appName + " [file]"); - status = 1; - } - else - { - status = RunParser.runParser(appName, args, communicator); - } - } - - System.exit(status); - } -} diff --git a/java/Database/library/ConnectionPool.java b/java/Database/library/ConnectionPool.java deleted file mode 100644 index d292ea483f..0000000000 --- a/java/Database/library/ConnectionPool.java +++ /dev/null @@ -1,148 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -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(com.zeroc.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 com.zeroc.Ice.Logger _logger; - private boolean _trace = true; - private String _url; - private String _username; - private String _password; - private java.util.LinkedList _connections = new java.util.LinkedList<>(); - private boolean _destroyed = false; - private int _nconnections; -} diff --git a/java/Database/library/DispatchInterceptorI.java b/java/Database/library/DispatchInterceptorI.java deleted file mode 100644 index 34c9edca45..0000000000 --- a/java/Database/library/DispatchInterceptorI.java +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.demos.Database.library.Demo.*; - -import java.util.concurrent.CompletionStage; - -import com.zeroc.Ice.DispatchInterceptor; -import com.zeroc.Ice.OutputStream; -import com.zeroc.Ice.Request; -import com.zeroc.Ice.UserException; - -class DispatchInterceptorI extends DispatchInterceptor -{ - @Override - public CompletionStage dispatch(Request request) - throws UserException - { - // Allocate a new SQLRequestContext associated with this - // request thread. - SQLRequestContext context = new SQLRequestContext(); - try - { - CompletionStage stage = _servant.ice_dispatch(request); - assert(stage == null); // We don't use asynchronous dispatch (AMD) with this demo - context.destroyFromDispatch(true); - return stage; - } - catch(JDBCException ex) - { - // Log the error. - com.zeroc.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. - com.zeroc.Ice.UnknownException e = new com.zeroc.Ice.UnknownException(); - e.initCause(ex); - throw e; - } - catch(UserException ex) - { - // A user exception causes the transaction to rollback. - context.destroyFromDispatch(false); - throw ex; - } - catch(RuntimeException ex) - { - // Any other exception causes the transaction to rollback. - context.destroyFromDispatch(false); - throw ex; - } - } - - DispatchInterceptorI(com.zeroc.Ice.Object servant) - { - _servant = servant; - } - - private com.zeroc.Ice.Object _servant; -} diff --git a/java/Database/library/Glacier2Session.ice b/java/Database/library/Glacier2Session.ice deleted file mode 100644 index 4e5ee80fc2..0000000000 --- a/java/Database/library/Glacier2Session.ice +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#pragma once - -#include -#include - -["java:package:com.zeroc.demos.Database.library"] -module Demo -{ - -/** - * - * 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(); -} - -} diff --git a/java/Database/library/Glacier2SessionManagerI.java b/java/Database/library/Glacier2SessionManagerI.java deleted file mode 100644 index 7289a3d7f6..0000000000 --- a/java/Database/library/Glacier2SessionManagerI.java +++ /dev/null @@ -1,105 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.demos.Database.library.Demo.*; - -import com.zeroc.Glacier2.SessionPrx; -import com.zeroc.Glacier2.SessionControlPrx; -import com.zeroc.Ice.ACMClose; -import com.zeroc.Ice.ACMHeartbeat; - -class Glacier2SessionManagerI implements com.zeroc.Glacier2.SessionManager, SessionManager -{ - @Override - public synchronized SessionPrx create(String userId, SessionControlPrx control, com.zeroc.Ice.Current current) - { - SessionI session = new SessionI(_logger, current.adapter, this); - - SessionPrx proxy = SessionPrx.uncheckedCast(current.adapter.addWithUUID(session)); - - _logger.trace("SessionFactory", "create new session: " + - com.zeroc.Ice.Util.identityToString(proxy.ice_getIdentity())); - - java.util.List sessions = _connectionMap.get(current.con); - if(sessions == null) - { - _logger.trace("SessionFactory", "enter: create new entry in connection map"); - - sessions = new java.util.ArrayList(); - sessions.add(proxy.ice_endpoints(new com.zeroc.Ice.Endpoint[0])); - _connectionMap.put(current.con, sessions); - - // - // Never close this connection from the client and turn on heartbeats with a timeout of 30s - // - current.con.setACM(java.util.OptionalInt.of(30), - java.util.Optional.of(ACMClose.CloseOff), - java.util.Optional.of(ACMHeartbeat.HeartbeatAlways)); - current.con.setCloseCallback((con) -> - { - try - { - deadRouter(con); - } - catch(com.zeroc.Ice.LocalException ex) - { - // The client already destroyed this session, or the server is shutting down - } - }); - - } - else - { - _logger.trace("SessionFactory", "create: add session to existing connection map entry"); - sessions.add(proxy.ice_endpoints(new com.zeroc.Ice.Endpoint[0])); - } - - return proxy; - } - - void - deadRouter(com.zeroc.Ice.Connection con) - { - _logger.trace("SessionFactory", "Detected dead router - destroying all associated sessions."); - - java.util.List sessions; - { - synchronized(this) - { - sessions = _connectionMap.remove(con); - } - } - - for(SessionPrx s : sessions) - { - // - // Collocated calls to the Session - // - s.destroy(); - } - } - - @Override - public synchronized void destroy(com.zeroc.Ice.Current current) - { - java.util.List sessions = _connectionMap.get(current.con); - if(sessions != null) - { - sessions.removeIf(s -> s.ice_getIdentity().equals(current.id)); - } - } - - Glacier2SessionManagerI(com.zeroc.Ice.Logger logger) - { - _logger = logger; - } - - final private com.zeroc.Ice.Logger _logger; - - // - // Map of connection from Glacier2 to proxies of Sessions in this server - // - java.util.Map> _connectionMap = - new java.util.HashMap>(); -} diff --git a/java/Database/library/Grammar.java b/java/Database/library/Grammar.java deleted file mode 100644 index 2d6e6b10e1..0000000000 --- a/java/Database/library/Grammar.java +++ /dev/null @@ -1,169 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -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 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 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 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 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 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 strings() - { - java.util.List l = new java.util.ArrayList<>(); - 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/Database/library/Library.ice b/java/Database/library/Library.ice deleted file mode 100644 index ba03dacbe6..0000000000 --- a/java/Database/library/Library.ice +++ /dev/null @@ -1,290 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#pragma once - -#include - -["java:package:com.zeroc.demos.Database.library"] -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:java.util.List"] 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:java.util.List"] -sequence 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:java.util.List"] 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:java.util.List"] Ice::StringSeq authors) - throws BookExistsException, InvalidISBNException; -} - -} diff --git a/java/Database/library/LibraryI.java b/java/Database/library/LibraryI.java deleted file mode 100644 index 2ebe71b3c6..0000000000 --- a/java/Database/library/LibraryI.java +++ /dev/null @@ -1,364 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.demos.Database.library.Demo.*; - -// -// This is a per-session library object. -// -class LibraryI implements Library -{ - @Override - public Library.QueryByIsbnResult queryByIsbn(String isbn, int n, com.zeroc.Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - - reapQueries(); - - Library.QueryByIsbnResult r = new Library.QueryByIsbnResult(); - - 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; - r.nrows = rs.getInt(1); - if(r.nrows == 0) - { - return r; - } - - stmt = context.prepareStatement("SELECT * FROM books WHERE isbn LIKE ?"); - stmt.setString(1, isbn + "%"); - rs = stmt.executeQuery(); - next = rs.next(); - assert next; - - r.first = new java.util.LinkedList<>(); - next = true; - for(int i = 0; i < n && next; ++i) - { - r.first.add(BookI.extractDescription(context, rs, current.adapter)); - next = rs.next(); - } - if(next) - { - BookQueryResultI impl = new BookQueryResultI(context, rs, current.adapter); - r.result = BookQueryResultPrx.uncheckedCast(current.adapter.addWithUUID(impl)); - add(r.result, impl); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - - return r; - } - - @Override - public Library.QueryByAuthorResult queryByAuthor(String author, int n, com.zeroc.Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - - reapQueries(); - - Library.QueryByAuthorResult r = new Library.QueryByAuthorResult(); - - 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. - r.nrows = 0; - return r; - } - - // 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; - r.nrows = rs.getInt(1); - if(r.nrows == 0) - { - return r; - } - - // 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; - r.first = new java.util.LinkedList<>(); - for(int i = 0; i < n && next; ++i) - { - r.first.add(BookI.extractDescription(context, rs, current.adapter)); - next = rs.next(); - } - - if(next) - { - BookQueryResultI impl = new BookQueryResultI(context, rs, current.adapter); - r.result = BookQueryResultPrx.uncheckedCast(current.adapter.addWithUUID(impl)); - add(r.result, impl); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - - return r; - } - - @Override - public Library.QueryByTitleResult queryByTitle(String title, int n, com.zeroc.Ice.Current current) - { - SQLRequestContext context = SQLRequestContext.getCurrentContext(); - assert context != null; - - reapQueries(); - - Library.QueryByTitleResult r = new Library.QueryByTitleResult(); - - 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; - r.nrows = rs.getInt(1); - if(r.nrows == 0) - { - return r; - } - - stmt = context.prepareStatement("SELECT * FROM books WHERE title LIKE ?"); - stmt.setString(1, "%" + title + "%"); - rs = stmt.executeQuery(); - next = rs.next(); - assert next; - - r.first = new java.util.LinkedList<>(); - next = true; - for(int i = 0; i < n && next; ++i) - { - r.first.add(BookI.extractDescription(context, rs, current.adapter)); - next = rs.next(); - } - if(next) - { - BookQueryResultI impl = new BookQueryResultI(context, rs, current.adapter); - r.result = BookQueryResultPrx.uncheckedCast(current.adapter.addWithUUID(impl)); - add(r.result, impl); - } - } - catch(java.sql.SQLException e) - { - JDBCException ex = new JDBCException(); - ex.initCause(e); - throw ex; - } - - return r; - } - - @Override - public BookPrx createBook(String isbn, String title, java.util.List authors, com.zeroc.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 authIds = new java.util.LinkedList<>(); - 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 BookPrx.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(com.zeroc.Ice.ObjectNotExistException e) - { - // Ignore, it could have already been destroyed. - } - } - } - - 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 com.zeroc.Ice.ObjectNotExistException(); - } - _queries.add(new QueryProxyPair(proxy, impl)); - } - - synchronized private void reapQueries() - { - if(_destroyed) - { - throw new com.zeroc.Ice.ObjectNotExistException(); - } - - java.util.Iterator p = _queries.iterator(); - while(p.hasNext()) - { - QueryProxyPair pair = p.next(); - try - { - pair.proxy.ice_ping(); - } - catch(com.zeroc.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 _queries = new java.util.LinkedList<>(); - private boolean _destroyed = false; -} diff --git a/java/Database/library/Parser.java b/java/Database/library/Parser.java deleted file mode 100644 index b862b845b6..0000000000 --- a/java/Database/library/Parser.java +++ /dev/null @@ -1,416 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.demos.Database.library.Demo.*; - -class Parser -{ - Parser(com.zeroc.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 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 authors = new java.util.LinkedList<>(); - 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(com.zeroc.Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void findIsbn(java.util.List 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; - } - - Library.QueryByIsbnResult r = _library.queryByIsbn(args.get(0), 1); - - System.out.println(r.nrows + " results"); - if(r.nrows == 0) - { - return; - } - - _current = r.first.get(0); - _query = r.result; - printCurrent(); - } - catch(com.zeroc.Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void findAuthors(java.util.List 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; - } - - Library.QueryByAuthorResult r = _library.queryByAuthor(args.get(0), 1); - - System.out.println(r.nrows + " results"); - if(r.nrows == 0) - { - return; - } - - _current = r.first.get(0); - _query = r.result; - printCurrent(); - } - catch(com.zeroc.Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void findTitle(java.util.List 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; - } - - Library.QueryByTitleResult r = _library.queryByTitle(args.get(0), 1); - - System.out.println(r.nrows + " results"); - if(r.nrows == 0) - { - return; - } - - _current = r.first.get(0); - _query = r.result; - printCurrent(); - } - catch(com.zeroc.Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void nextFoundBook() - { - if(_query == null) - { - System.out.println("no next book"); - return; - } - - try - { - BookQueryResult.NextResult r = _query.next(1); - if(r.returnValue.size() > 0) - { - _current = r.returnValue.get(0); - } - else - { - assert r.destroyed; - _current = null; - } - if(r.destroyed) - { - _query = null; - } - printCurrent(); - } - catch(com.zeroc.Ice.ObjectNotExistException ex) - { - System.out.println("the query object no longer exists"); - } - catch(com.zeroc.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 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(com.zeroc.Ice.ObjectNotExistException ex) - { - System.out.println("current book no longer exists"); - } - catch(com.zeroc.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(com.zeroc.Ice.ObjectNotExistException ex) - { - System.out.println("current book no longer exists"); - } - catch(com.zeroc.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(com.zeroc.Ice.ObjectNotExistException ex) - { - System.out.println("current book no longer exists"); - } - catch(com.zeroc.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/Database/library/README.md b/java/Database/library/README.md deleted file mode 100644 index 888c6901be..0000000000 --- a/java/Database/library/README.md +++ /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][1]. - - Using a [dispatch interceptor][2]. - - Accessing a server with and without [Glacier2][3]. - -Setting up the demo -------------------- - -1. Install mysql or MariaDB as necessary. - -2. 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 - ``` - -3. Create the SQL tables using the script createTypes.sql: - ``` - $ mysql --user=USER --password=PASSWORD library < createTypes.sql - ``` - -4. 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 - -Running the demo ----------------- - -To run the demo, first start the server: - -``` -java -jar build/libs/server.jar -``` - -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 -jar build/libs/client.jar 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 -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 books -``` - -Omit the "books" argument if you have already populated the server's -database. - -[1]: https://doc.zeroc.com/ice/3.7/server-side-features/servant-locators -[2]: https://doc.zeroc.com/ice/3.7/server-side-features/dispatch-interceptors -[3]: https://doc.zeroc.com/ice/3.7/ice-services/glacier2 diff --git a/java/Database/library/RunParser.java b/java/Database/library/RunParser.java deleted file mode 100644 index 5e28376cc4..0000000000 --- a/java/Database/library/RunParser.java +++ /dev/null @@ -1,160 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.demos.Database.library.Demo.*; - -import com.zeroc.Ice.ACMClose; -import com.zeroc.Ice.ACMHeartbeat; - -class RunParser -{ - // - // Adapter for the two types of session objects. - // - interface SessionAdapter - { - public LibraryPrx getLibrary(); - public void destroy(); - } - - static SessionAdapter createSession(String appName, com.zeroc.Ice.Communicator communicator) - { - SessionAdapter session; - final com.zeroc.Glacier2.RouterPrx router = - com.zeroc.Glacier2.RouterPrx.uncheckedCast(communicator.getDefaultRouter()); - if(router != null) - { - com.zeroc.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); - final int acmTimeout = router.getACMTimeout(); - if(acmTimeout > 0) - { - com.zeroc.Ice.Connection connection = router.ice_getCachedConnection(); - assert(connection != null); - connection.setACM( - java.util.OptionalInt.of(acmTimeout), null, - java.util.Optional.of(ACMHeartbeat.HeartbeatAlways)); - } - break; - } - catch(com.zeroc.Glacier2.PermissionDeniedException ex) - { - System.out.println("permission denied:\n" + ex.reason); - } - catch(com.zeroc.Glacier2.CannotCreateSessionException ex) - { - System.out.println("cannot create session:\n" + ex.reason); - } - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - } - } - - final Glacier2SessionPrx sess = Glacier2SessionPrx.uncheckedCast(glacier2session); - session = new SessionAdapter() - { - @Override - public LibraryPrx getLibrary() - { - return sess.getLibrary(); - } - - @Override - public void destroy() - { - try - { - router.destroySession(); - } - catch(com.zeroc.Glacier2.SessionNotExistException ex) - { - } - catch(com.zeroc.Ice.ConnectionLostException ex) - { - // - // Expected: the router closed the connection. - // - } - } - }; - } - else - { - SessionFactoryPrx factory = SessionFactoryPrx.checkedCast( - communicator.propertyToProxy("SessionFactory.Proxy")); - if(factory == null) - { - System.err.println(appName + ": invalid object reference"); - return null; - } - - final SessionPrx sess = factory.create(); - session = new SessionAdapter() - { - @Override - public LibraryPrx getLibrary() - { - return sess.getLibrary(); - } - - @Override - public void destroy() - { - sess.destroy(); - } - }; - } - return session; - } - - static int runParser(String appName, String[] args, final com.zeroc.Ice.Communicator communicator) - { - final SessionAdapter session = createSession(appName, communicator); - if(session == null) - { - return 1; - } - - 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(); - } - - session.destroy(); - - return rc; - } -} diff --git a/java/Database/library/SQLRequestContext.java b/java/Database/library/SQLRequestContext.java deleted file mode 100644 index ff3c0d709e..0000000000 --- a/java/Database/library/SQLRequestContext.java +++ /dev/null @@ -1,138 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -// -// 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(com.zeroc.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 _contextMap = - java.util.Collections.synchronizedMap(new java.util.HashMap()); - - private static com.zeroc.Ice.Logger _logger = null; - private static ConnectionPool _pool = null; - - private boolean _trace = true; - private java.util.List _statements = new java.util.LinkedList<>(); - private java.sql.Connection _conn; -} diff --git a/java/Database/library/Scanner.java b/java/Database/library/Scanner.java deleted file mode 100644 index 79ccb2b624..0000000000 --- a/java/Database/library/Scanner.java +++ /dev/null @@ -1,274 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -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/Database/library/Server.java b/java/Database/library/Server.java deleted file mode 100644 index 9576669d67..0000000000 --- a/java/Database/library/Server.java +++ /dev/null @@ -1,134 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -class Server -{ - static class LocatorI implements com.zeroc.Ice.ServantLocator - { - @Override - public com.zeroc.Ice.ServantLocator.LocateResult locate(com.zeroc.Ice.Current c) - { - assert c.id.category.equals("book"); - return new com.zeroc.Ice.ServantLocator.LocateResult(_servant, null); - } - - @Override - public void finished(com.zeroc.Ice.Current c, com.zeroc.Ice.Object servant, Object cookie) - { - } - - @Override - public void deactivate(String category) - { - } - - LocatorI(com.zeroc.Ice.Object servant) - { - _servant = new DispatchInterceptorI(servant); - } - - private com.zeroc.Ice.Object _servant; - } - - public static void main(String[] args) - { - int status = 0; - java.util.List extraArgs = new java.util.ArrayList(); - - // - // Try with resources block - communicator is automatically destroyed - // at the end of this try block - // - try(com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(args, "config.server", extraArgs)) - { - communicator.getProperties().setProperty("Ice.Default.Package", "com.zeroc.demos.Database.library"); - // - // Install shutdown hook to (also) destroy communicator during JVM shutdown. - // This ensures the communicator gets destroyed when the user interrupts the application with Ctrl-C. - // - Runtime.getRuntime().addShutdownHook(new Thread(() -> communicator.destroy())); - - if(!extraArgs.isEmpty()) - { - System.err.println("too many arguments"); - status = 1; - } - else - { - status = run(communicator, extraArgs.toArray(new String[extraArgs.size()])); - } - } - - System.exit(status); - } - - private static int run(com.zeroc.Ice.Communicator communicator, String[] args) - { - args = communicator.getProperties().parseCommandLineOptions("JDBC", args); - com.zeroc.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; - } - - com.zeroc.Ice.Logger logger = communicator.getLogger(); - - try - { - Class.forName(properties.getProperty("JDBC.DriverClassName")).getConstructor().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 - { - final ConnectionPool pool = new ConnectionPool(logger, url, username, password, nConnections); - Runtime.getRuntime().addShutdownHook(new Thread(() -> pool.destroy())); - - SQLRequestContext.initialize(logger, pool); - } - 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; - } - - // - // Create an object adapter - // - com.zeroc.Ice.ObjectAdapter adapter = communicator.createObjectAdapter("SessionFactory"); - - adapter.addServantLocator(new LocatorI(new BookI()), "book"); - - adapter.add(new SessionFactoryI(logger), - com.zeroc.Ice.Util.stringToIdentity("SessionFactory")); - adapter.add(new Glacier2SessionManagerI(logger), - com.zeroc.Ice.Util.stringToIdentity("LibrarySessionManager")); - - // - // Everything ok, let's go. - // - adapter.activate(); - - communicator.waitForShutdown(); - - return 0; - } -} diff --git a/java/Database/library/Session.ice b/java/Database/library/Session.ice deleted file mode 100644 index 2ec071bb07..0000000000 --- a/java/Database/library/Session.ice +++ /dev/null @@ -1,56 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#pragma once - -#include - -["java:package:com.zeroc.demos.Database.library"] -module Demo -{ - -/** - * - * 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(); - - /** - * - * Destroy the session. - * - **/ - void destroy(); -} - -/** - * - * Interface to create new sessions. - * - **/ -interface SessionFactory -{ - /** - * - * Create a session. - * - * @return A proxy to the session. - * - **/ - Session* create(); -} - -} diff --git a/java/Database/library/SessionFactoryI.java b/java/Database/library/SessionFactoryI.java deleted file mode 100644 index be1c9251ad..0000000000 --- a/java/Database/library/SessionFactoryI.java +++ /dev/null @@ -1,63 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.demos.Database.library.Demo.*; - -import com.zeroc.Ice.ACMClose; -import com.zeroc.Ice.ACMHeartbeat; - -class SessionFactoryI implements SessionFactory, SessionManager -{ - @Override - public synchronized SessionPrx create(com.zeroc.Ice.Current current) - { - SessionI session = new SessionI(_logger, current.adapter, this); - - SessionPrx proxy = SessionPrx.uncheckedCast(current.adapter.addWithUUID(session)); - - _logger.trace("SessionFactory", "create new session: " + - com.zeroc.Ice.Util.identityToString(proxy.ice_getIdentity())); - - // - // Remove endpoints to ensure that calls are collocated-only - // This way, if we invoke on the proxy during shutdown, the invocation fails immediately - // without attempting to establish any connection - // - final SessionPrx collocProxy = proxy.ice_endpoints(new com.zeroc.Ice.Endpoint[0]); - - // - // Never close this connection from the client and turn on heartbeats - // - current.con.setACM(java.util.OptionalInt.of(30), - java.util.Optional.of(ACMClose.CloseOff), - java.util.Optional.of(ACMHeartbeat.HeartbeatAlways)); - - current.con.setCloseCallback((con) -> - { - try - { - collocProxy.destroy(); - _logger.trace("SessionFactory", "Cleaned up dead client."); - } - catch(com.zeroc.Ice.LocalException ex) - { - // The client already destroyed this session, or the server is shutting down - } - }); - - return proxy; - } - - @Override - public void destroy(com.zeroc.Ice.Current current) - { - } - - SessionFactoryI(com.zeroc.Ice.Logger logger) - { - _logger = logger; - } - - final private com.zeroc.Ice.Logger _logger; -} diff --git a/java/Database/library/SessionI.java b/java/Database/library/SessionI.java deleted file mode 100644 index cf433e5158..0000000000 --- a/java/Database/library/SessionI.java +++ /dev/null @@ -1,50 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.demos.Database.library.Demo.*; - -class SessionI implements Glacier2Session -{ - @Override - synchronized public LibraryPrx getLibrary(com.zeroc.Ice.Current c) - { - if(_destroyed) - { - throw new com.zeroc.Ice.ObjectNotExistException(); - } - return _library; - } - - @Override - synchronized public void destroy(com.zeroc.Ice.Current c) - { - if(_destroyed) - { - throw new com.zeroc.Ice.ObjectNotExistException(); - } - - _destroyed = true; - _logger.trace("Session", "session " + com.zeroc.Ice.Util.identityToString(c.id) + " is now destroyed."); - - // This method is never called on shutdown of the server. - _libraryI.destroy(); - _manager.destroy(c); - c.adapter.remove(_library.ice_getIdentity()); - c.adapter.remove(c.id); - } - - SessionI(com.zeroc.Ice.Logger logger, com.zeroc.Ice.ObjectAdapter adapter, SessionManager manager) - { - _logger = logger; - _libraryI = new LibraryI(); - _library = LibraryPrx.uncheckedCast(adapter.addWithUUID(new DispatchInterceptorI(_libraryI))); - _manager = manager; - } - - private com.zeroc.Ice.Logger _logger; - private boolean _destroyed = false; // true if destroy() was called, false otherwise. - private LibraryPrx _library; - private LibraryI _libraryI; - private SessionManager _manager; -} diff --git a/java/Database/library/SessionManager.java b/java/Database/library/SessionManager.java deleted file mode 100644 index 465702e8a9..0000000000 --- a/java/Database/library/SessionManager.java +++ /dev/null @@ -1,8 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -interface SessionManager -{ - public void destroy(com.zeroc.Ice.Current current); -} diff --git a/java/Database/library/Token.java b/java/Database/library/Token.java deleted file mode 100644 index 2cd801cd20..0000000000 --- a/java/Database/library/Token.java +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -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/Database/library/books b/java/Database/library/books deleted file mode 100644 index 18836dbdba..0000000000 --- a/java/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/Database/library/build.gradle b/java/Database/library/build.gradle deleted file mode 100644 index a5507e5cf2..0000000000 --- a/java/Database/library/build.gradle +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -slice { - java { - include = ["${projectDir}"] - srcDir = '.' - } -} - -sourceSets { - main { - java { - srcDir '.' - } - } -} - -dependencies { - implementation localDependency("ice") - runtimeOnly localDependency("icessl") - implementation localDependency("glacier2") - runtimeOnly "org.apache.commons:commons-compress:1.14" - runtimeOnly "mysql:mysql-connector-java:6.0.6" -} - -// Don't create the default jar. -jar.enabled = false - -demoJar("client") -demoJar("server") diff --git a/java/Database/library/config.client b/java/Database/library/config.client deleted file mode 100644 index 7c3bb3d4df..0000000000 --- a/java/Database/library/config.client +++ /dev/null @@ -1,56 +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 - -# -# 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=com.zeroc.IceSSL.PluginFactory -IceSSL.DefaultDir=../../../certs -IceSSL.Truststore=cacert.jks -IceSSL.TrustOnly.Client=CN=127.0.0.1 diff --git a/java/Database/library/config.glacier2 b/java/Database/library/config.glacier2 deleted file mode 100644 index d6b7850235..0000000000 --- a/java/Database/library/config.glacier2 +++ /dev/null @@ -1,50 +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 - -# -# Security Tracing -# -# 0 = no security tracing -# 1 = trace messages -# -#IceSSL.Trace.Security=1 - -# -# SSL Configuration -# -Ice.Plugin.IceSSL=IceSSL:createIceSSL -IceSSL.DefaultDir=../../../certs -IceSSL.CAs=cacert.pem -IceSSL.CertFile=server.p12 -IceSSL.Password=password -IceSSL.VerifyPeer=0 -IceSSL.Keychain=../../../certs/glacier2.keychain -IceSSL.KeychainPassword=password diff --git a/java/Database/library/config.server b/java/Database/library/config.server deleted file mode 100644 index 6fbac5596a..0000000000 --- a/java/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=com.zeroc.IceSSL.PluginFactory -IceSSL.VerifyPeer=0 -IceSSL.DefaultDir=../../../certs -IceSSL.Keystore=server.jks -IceSSL.Password=password diff --git a/java/Database/library/createTypes.sql b/java/Database/library/createTypes.sql deleted file mode 100644 index c8115a613f..0000000000 --- a/java/Database/library/createTypes.sql +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright (c) ZeroC, Inc. All rights reserved. -# -# -# 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/Glacier2/build.gradle b/java/Glacier2/build.gradle index d043ee95a5..552fdab99e 100644 --- a/java/Glacier2/build.gradle +++ b/java/Glacier2/build.gradle @@ -22,7 +22,6 @@ dependencies { implementation localDependency("ice") - runtimeOnly localDependency("icessl") implementation localDependency("glacier2") runtimeOnly "org.apache.commons:commons-compress:1.14" } diff --git a/java/Ice/build.gradle b/java/Ice/build.gradle index bffb3bc897..150e375509 100644 --- a/java/Ice/build.gradle +++ b/java/Ice/build.gradle @@ -25,7 +25,6 @@ dependencies { implementation localDependency("ice") - runtimeOnly localDependency("icessl") runtimeOnly "org.apache.commons:commons-compress:1.14" } diff --git a/java/Ice/properties/Props.ice b/java/Ice/properties/Props.ice index 89e08cab80..decee176b9 100644 --- a/java/Ice/properties/Props.ice +++ b/java/Ice/properties/Props.ice @@ -4,7 +4,7 @@ #pragma once -#include +#include ["java:package:com.zeroc.demos.Ice.properties"] module Demo diff --git a/java/Ice/swing/build.gradle b/java/Ice/swing/build.gradle index 74ff4d25b5..84defd7925 100644 --- a/java/Ice/swing/build.gradle +++ b/java/Ice/swing/build.gradle @@ -19,7 +19,6 @@ sourceSets { dependencies { implementation localDependency("ice") - runtimeOnly localDependency("icessl") runtimeOnly "org.apache.commons:commons-compress:1.14" } diff --git a/java/IceBox/hello/build.gradle b/java/IceBox/hello/build.gradle index f486f92ca1..bde4bbeee1 100644 --- a/java/IceBox/hello/build.gradle +++ b/java/IceBox/hello/build.gradle @@ -19,7 +19,6 @@ sourceSets { dependencies { implementation localDependency("ice") - runtimeOnly localDependency("icessl") implementation localDependency("icebox") runtimeOnly "org.apache.commons:commons-compress:1.14" } diff --git a/java/IceDiscovery/build.gradle b/java/IceDiscovery/build.gradle index c515a3efc3..19969dbb51 100644 --- a/java/IceDiscovery/build.gradle +++ b/java/IceDiscovery/build.gradle @@ -22,7 +22,6 @@ dependencies { implementation localDependency("ice") - runtimeOnly localDependency("icessl") runtimeOnly localDependency("icediscovery") runtimeOnly "org.apache.commons:commons-compress:1.14" } diff --git a/java/IceGrid/build.gradle b/java/IceGrid/build.gradle index b2b2c7e8f0..4b7ef8e6e1 100644 --- a/java/IceGrid/build.gradle +++ b/java/IceGrid/build.gradle @@ -21,7 +21,7 @@ def demoIceGridProject(name) { dependencies { implementation localDependency("ice") - runtimeOnly localDependency("icessl") + implementation localDependency("icegrid") runtimeOnly localDependency("icelocatordiscovery") runtimeOnly "org.apache.commons:commons-compress:1.14" @@ -54,7 +54,6 @@ project(":demoIceGridSimple") { project(":demoIceGridIcebox") { dependencies { - runtimeOnly localDependency("icessl") implementation localDependency("icebox") } demoJar("client") diff --git a/java/IceStorm/clock/build.gradle b/java/IceStorm/clock/build.gradle index f380ecd36f..bc7ebf867e 100644 --- a/java/IceStorm/clock/build.gradle +++ b/java/IceStorm/clock/build.gradle @@ -19,7 +19,6 @@ sourceSets { dependencies { implementation localDependency("ice") - runtimeOnly localDependency("icessl") implementation localDependency("icestorm") runtimeOnly "org.apache.commons:commons-compress:1.14" } diff --git a/java/Manual/README.md b/java/Manual/README.md index 89ec07fedd..aacccdb20b 100644 --- a/java/Manual/README.md +++ b/java/Manual/README.md @@ -1,9 +1,5 @@ Demos in this directory: -- [lifecycle](./lifecycle) - - An implementation of the file system that supports life cycle operations. - - [printer](./printer) An implementation of the simple printer example at the beginning of diff --git a/java/Manual/build.gradle b/java/Manual/build.gradle index 3d31a4ab3a..f0e9d970d5 100644 --- a/java/Manual/build.gradle +++ b/java/Manual/build.gradle @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -['lifecycle', 'simple_filesystem'].each { +['printer', 'simple_filesystem'].each { // abc_def -> AbcDef def name = it.split('_').collect { it.capitalize() }.join() project(":demoManual${name}") { @@ -23,7 +23,6 @@ dependencies { implementation "com.zeroc:ice:${project.iceArtifactVersion}" - runtimeOnly "com.zeroc:icessl:${project.iceArtifactVersion}" runtimeOnly "org.apache.commons:commons-compress:1.14" } diff --git a/java/Manual/lifecycle/Client.java b/java/Manual/lifecycle/Client.java deleted file mode 100644 index 00f050df53..0000000000 --- a/java/Manual/lifecycle/Client.java +++ /dev/null @@ -1,48 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.Ice.*; -import com.zeroc.demos.Manual.lifecycle.Filesystem.*; - -public class Client -{ - public static void main(String[] args) - { - int status = 0; - // - // Try with resources block - communicator is automatically destroyed - // at the end of this try block - // - try(com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(args)) - { - communicator.getProperties().setProperty("Ice.Default.Package", "com.zeroc.demos.Manual.lifecycle"); - // - // Create a proxy for the root directory - // - com.zeroc.Ice.ObjectPrx base = communicator.stringToProxy("RootDir:default -h localhost -p 10000"); - - // - // Down-cast the proxy to a Directory proxy. - // - DirectoryPrx rootDir = DirectoryPrx.checkedCast(base); - if(rootDir == null) - { - throw new Error("Invalid proxy"); - } - - Parser p = new Parser(rootDir); - status = p.parse(); - } - - System.exit(status); - } - - private static class Error extends RuntimeException - { - public Error(String msg) - { - super(msg); - } - } -} diff --git a/java/Manual/lifecycle/DirectoryI.java b/java/Manual/lifecycle/DirectoryI.java deleted file mode 100644 index ba17bf530e..0000000000 --- a/java/Manual/lifecycle/DirectoryI.java +++ /dev/null @@ -1,178 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.Ice.*; -import com.zeroc.demos.Manual.lifecycle.Filesystem.*; - -public class DirectoryI implements Directory, 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 > pos = _contents.entrySet().iterator(); - for(int i = 0; i < _contents.size(); ++i) - { - java.util.Map.Entry 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 = NodePrx.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 = NodePrx.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 FilePrx.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 DirectoryPrx.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<>(); - - _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 _contents; -} diff --git a/java/Manual/lifecycle/FileI.java b/java/Manual/lifecycle/FileI.java deleted file mode 100644 index 76e96c01b4..0000000000 --- a/java/Manual/lifecycle/FileI.java +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.Ice.*; -import com.zeroc.demos.Manual.lifecycle.Filesystem.*; - -public class FileI implements File, 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/Manual/lifecycle/Filesystem.ice b/java/Manual/lifecycle/Filesystem.ice deleted file mode 100644 index ab66572af5..0000000000 --- a/java/Manual/lifecycle/Filesystem.ice +++ /dev/null @@ -1,50 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#pragma once - -["java:package:com.zeroc.demos.Manual.lifecycle"] -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 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 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/Manual/lifecycle/Grammar.java b/java/Manual/lifecycle/Grammar.java deleted file mode 100644 index 3ca997bb78..0000000000 --- a/java/Manual/lifecycle/Grammar.java +++ /dev/null @@ -1,195 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -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 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 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 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 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 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 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 strings() - { - java.util.LinkedList l = new java.util.LinkedList(); - 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/Manual/lifecycle/NodeI.java b/java/Manual/lifecycle/NodeI.java deleted file mode 100644 index e4dae2613c..0000000000 --- a/java/Manual/lifecycle/NodeI.java +++ /dev/null @@ -1,8 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -public interface NodeI -{ - com.zeroc.Ice.Identity id(); -} diff --git a/java/Manual/lifecycle/Parser.java b/java/Manual/lifecycle/Parser.java deleted file mode 100644 index ffd4c68120..0000000000 --- a/java/Manual/lifecycle/Parser.java +++ /dev/null @@ -1,333 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -import com.zeroc.demos.Manual.lifecycle.Filesystem.*; - -class Parser -{ - Parser(DirectoryPrx root) - { - _dirs = new java.util.LinkedList(); - _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(com.zeroc.Ice.LocalException ex) - { - error(ex.toString()); - } - } - - void list(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 - ? DirectoryPrx.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 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 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 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(DirectoryPrx.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 = FilePrx.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 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 = FilePrx.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 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)); - - usage(); - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - int parse(java.io.BufferedReader in) - { - _in = in; - - usage(); - - Grammar g = new Grammar(this); - g.parse(); - - return 0; - } - - private java.util.LinkedList _dirs; - - private java.io.BufferedReader _in; -} diff --git a/java/Manual/lifecycle/README.md b/java/Manual/lifecycle/README.md deleted file mode 100644 index eace49b04a..0000000000 --- a/java/Manual/lifecycle/README.md +++ /dev/null @@ -1,17 +0,0 @@ -This demo implements the file system with [life cycle][1] 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. - -[1]: https://doc.zeroc.com/ice/3.7/best-practices/object-life-cycle/object-life-cycle-for-the-file-system-application/implementing-object-life-cycle-in-java diff --git a/java/Manual/lifecycle/Scanner.java b/java/Manual/lifecycle/Scanner.java deleted file mode 100644 index 33d91d64e2..0000000000 --- a/java/Manual/lifecycle/Scanner.java +++ /dev/null @@ -1,274 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -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/Manual/lifecycle/Server.java b/java/Manual/lifecycle/Server.java deleted file mode 100644 index c4e56b576a..0000000000 --- a/java/Manual/lifecycle/Server.java +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -class Server -{ - public static void main(String[] args) - { - int status = 0; - java.util.List extraArgs = new java.util.ArrayList(); - - // - // Try with resources block - communicator is automatically destroyed - // at the end of this try block - // - try(com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(args, extraArgs)) - { - communicator.getProperties().setProperty("Ice.Default.Package", "com.zeroc.demos.Manual.lifecycle"); - // - // Install shutdown hook to (also) destroy communicator during JVM shutdown. - // This ensures the communicator gets destroyed when the user interrupts the application with Ctrl-C. - // - Runtime.getRuntime().addShutdownHook(new Thread(() -> communicator.destroy())); - - if(!extraArgs.isEmpty()) - { - System.err.println("too many arguments"); - status = 1; - } - else - { - // - // Create an object adapter - // - com.zeroc.Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints( - "LifecycleFilesystem", "default -h localhost -p 10000"); - - // - // Create the root directory. - // - DirectoryI root = new DirectoryI(); - com.zeroc.Ice.Identity id = new com.zeroc.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(); - } - } - - System.exit(status); - } -} diff --git a/java/Manual/lifecycle/Token.java b/java/Manual/lifecycle/Token.java deleted file mode 100644 index 6f8fd3993e..0000000000 --- a/java/Manual/lifecycle/Token.java +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -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/android/hello/build.gradle b/java/android/hello/build.gradle index a8ec90bdef..f2fd67e665 100644 --- a/java/android/hello/build.gradle +++ b/java/android/hello/build.gradle @@ -43,7 +43,6 @@ clean { dependencies { implementation localDependency("ice") - implementation localDependency("icessl") runtimeOnly localDependency("icediscovery") implementation "androidx.fragment:fragment:1.5.5" implementation "androidx.appcompat:appcompat:1.6.1" diff --git a/java/gradle/ice.gradle b/java/gradle/ice.gradle index d486044577..43aa13ddac 100644 --- a/java/gradle/ice.gradle +++ b/java/gradle/ice.gradle @@ -138,7 +138,6 @@ def demoIceBoxServer() { dependencies { iceboxserver localDependency("ice") - iceboxserver localDependency("icessl") iceboxserver localDependency("icebox") iceboxserver "org.apache.commons:commons-compress:1.14" } diff --git a/java/settings.gradle b/java/settings.gradle index 38ebc27173..63006eef25 100644 --- a/java/settings.gradle +++ b/java/settings.gradle @@ -9,12 +9,11 @@ def demos = [ 'multicast', 'nested', 'plugin', 'properties', 'serialize', 'session', 'swing', 'throughput', 'optional', 'context'], 'IceDiscovery' : ['hello', 'replication'], - 'Database' : ['library'], 'IceBox' : ['hello'], 'Glacier2' : ['callback', 'simpleChat'], 'IceStorm' : ['clock'], 'IceGrid' : ['icebox', 'simple'], - 'Manual' : ['lifecycle', 'simpleFilesystem'] + 'Manual' : ['printer', 'simpleFilesystem'] ] demos.each { From 4e06635fb1aeeb0f9120a38f868efa862db6c3ff Mon Sep 17 00:00:00 2001 From: Joe George Date: Fri, 31 May 2024 13:54:40 -0400 Subject: [PATCH 02/17] Bump timeouts --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fe89b379f..da37ac5786 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,17 +62,17 @@ jobs: - name: Build C++ Demos on ${{ matrix.os }} uses: ./ice/.github/actions/build - timeout-minutes: 5 + timeout-minutes: 20 with: working_directory: ice-demos/cpp msbuild_project: msbuild/ice.proj - name: Build C# Demos on ${{ matrix.os }} - timeout-minutes: 5 + timeout-minutes: 20 working-directory: ice-demos/csharp run: ${{ matrix.csharp_build_command }} /m msbuild/ice.proj - name: Run Java Demos on ${{ matrix.os }} - timeout-minutes: 5 + timeout-minutes: 20 working-directory: ice-demos/java run: ./gradlew build From 3589b13b0f5b050fc7fcc84be4c246adf9dabd2f Mon Sep 17 00:00:00 2001 From: Joe George Date: Fri, 31 May 2024 14:50:32 -0400 Subject: [PATCH 03/17] Specify iceHome --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da37ac5786..3ab9e44275 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,4 +75,4 @@ jobs: - name: Run Java Demos on ${{ matrix.os }} timeout-minutes: 20 working-directory: ice-demos/java - run: ./gradlew build + run: ./gradlew -PiceHome=${{ env.IceHome }} build From 29c720f562e1a9003478a9bc3383f97955001bde Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 10:09:33 -0400 Subject: [PATCH 04/17] Remove Java ACM --- java/Glacier2/callback/Client.java | 3 --- java/Ice/session/SessionFactoryI.java | 7 ------- 2 files changed, 10 deletions(-) diff --git a/java/Glacier2/callback/Client.java b/java/Glacier2/callback/Client.java index 9230d1bccd..e5efa58292 100644 --- a/java/Glacier2/callback/Client.java +++ b/java/Glacier2/callback/Client.java @@ -84,11 +84,8 @@ private static int run(com.zeroc.Ice.Communicator communicator) } } - int acmTimeout = router.getACMTimeout(); com.zeroc.Ice.Connection connection = router.ice_getCachedConnection(); assert(connection != null); - connection.setACM(java.util.OptionalInt.of(acmTimeout), null, - java.util.Optional.of(com.zeroc.Ice.ACMHeartbeat.HeartbeatAlways)); connection.setCloseCallback(con -> System.out.println("The Glacier2 session has been destroyed.")); // diff --git a/java/Ice/session/SessionFactoryI.java b/java/Ice/session/SessionFactoryI.java index bab92ecd44..8f398174f1 100644 --- a/java/Ice/session/SessionFactoryI.java +++ b/java/Ice/session/SessionFactoryI.java @@ -19,13 +19,6 @@ public SessionPrx create(String name, com.zeroc.Ice.Current current) // SessionPrx collocProxy = proxy.ice_endpoints(new com.zeroc.Ice.Endpoint[0]); - // - // Never close this connection from the client and turn on heartbeats with a timeout of 30s - // - current.con.setACM(java.util.OptionalInt.of(30), - java.util.Optional.of(com.zeroc.Ice.ACMClose.CloseOff), - java.util.Optional.of(com.zeroc.Ice.ACMHeartbeat.HeartbeatAlways)); - current.con.setCloseCallback(con -> { try From 596b029395df12d3ba9c6855e1b0e7de9982cd1c Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 10:37:39 -0400 Subject: [PATCH 05/17] Java build fix --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ab9e44275..80c11c3c85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ concurrency: env: ICE_HOME: ${{ github.workspace }}/ice # Makefile - IceHome: ${{ github.workspace }}/ice # MSBuild + IceHome: ${{ github.workspace }}\ice # MSBuild Platform: x64 # For Msbuild Configuration: Release # For Msbuild @@ -72,7 +72,7 @@ jobs: working-directory: ice-demos/csharp run: ${{ matrix.csharp_build_command }} /m msbuild/ice.proj - - name: Run Java Demos on ${{ matrix.os }} + - name: Build Java Demos on ${{ matrix.os }} timeout-minutes: 20 working-directory: ice-demos/java - run: ./gradlew -PiceHome=${{ env.IceHome }} build + run: ./gradlew build From 110202f22bab30d2a09c59787fa6cfcfbf04497d Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 10:43:41 -0400 Subject: [PATCH 06/17] Fix deprecation warnings --- .../Chat/src/main/java/com/zeroc/demos/Chat/Coordinator.java | 5 ++--- java/Glacier2/simpleChat/Client.java | 4 ++-- java/Ice/interrupt/Server.java | 2 +- java/Ice/swing/Client.java | 2 +- java/build.gradle | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/java/Chat/src/main/java/com/zeroc/demos/Chat/Coordinator.java b/java/Chat/src/main/java/com/zeroc/demos/Chat/Coordinator.java index 8421fa311e..a29d3f027b 100644 --- a/java/Chat/src/main/java/com/zeroc/demos/Chat/Coordinator.java +++ b/java/Chat/src/main/java/com/zeroc/demos/Chat/Coordinator.java @@ -37,7 +37,6 @@ import com.zeroc.Glacier2.SessionHelper; import com.zeroc.Glacier2.SessionCallback; import com.zeroc.Glacier2.SessionNotExistException; -import com.zeroc.Ice.Util; class Coordinator { @@ -55,14 +54,14 @@ public Coordinator(MainView mainView, LoginView loginView, ChatView chatView, De com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData(); java.util.List rArgs = new java.util.ArrayList<>(); - initData.properties = com.zeroc.Ice.Util.createProperties(_args, rArgs); + initData.properties = new com.zeroc.Ice.Properties(_args, rArgs); _args = rArgs.toArray(new String[rArgs.size()]); initData.properties.setProperty("Ice.Plugin.IceSSL", "com.zeroc.IceSSL.PluginFactory"); // Load the configuration file. initData.properties.setProperty("Ice.Default.Package", "com.zeroc.demos"); - initData.properties = Util.createProperties(args, initData.properties); + initData.properties = new com.zeroc.Ice.Properties(args, initData.properties); // // Set Ice.Default.Router if not set. diff --git a/java/Glacier2/simpleChat/Client.java b/java/Glacier2/simpleChat/Client.java index 18943ebecd..c28dc5c29f 100644 --- a/java/Glacier2/simpleChat/Client.java +++ b/java/Glacier2/simpleChat/Client.java @@ -290,10 +290,10 @@ public void windowClosing(WindowEvent e) com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData(); // Load the configuration file. - initData.properties = com.zeroc.Ice.Util.createProperties(); + initData.properties = new com.zeroc.Ice.Properties(); initData.properties.load("config.client"); initData.properties.setProperty("Ice.Default.Package", "com.zeroc.demos.Glacier2.simpleChat"); - initData.properties = Util.createProperties(args, initData.properties); + initData.properties = new com.zeroc.Ice.Properties(args, initData.properties); // Setup a dispatcher to dispath Ice and Glacier2 helper callbacks to the GUI thread. initData.dispatcher = (runnable, connection) -> diff --git a/java/Ice/interrupt/Server.java b/java/Ice/interrupt/Server.java index d340c76300..d31d5f8dc6 100644 --- a/java/Ice/interrupt/Server.java +++ b/java/Ice/interrupt/Server.java @@ -13,7 +13,7 @@ public static void main(String[] args) java.util.List extraArgs = new java.util.ArrayList(); com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData(); - initData.properties = com.zeroc.Ice.Util.createProperties(); + initData.properties = new com.zeroc.Ice.Properties(); initData.properties.load("config.server"); // diff --git a/java/Ice/swing/Client.java b/java/Ice/swing/Client.java index 1ba209fb4d..f97af49947 100644 --- a/java/Ice/swing/Client.java +++ b/java/Ice/swing/Client.java @@ -47,7 +47,7 @@ public static void main(final String[] args) // Initialize an Ice communicator. // com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData(); - initData.properties = com.zeroc.Ice.Util.createProperties(); + initData.properties = new com.zeroc.Ice.Properties(); initData.properties.load("config.client"); initData.properties.setProperty("Ice.Default.Package", "com.zeroc.demos.Ice.swing"); initData.dispatcher = (runnable, connection) -> SwingUtilities.invokeLater(runnable); diff --git a/java/build.gradle b/java/build.gradle index f571ce8c6f..4b058313a8 100644 --- a/java/build.gradle +++ b/java/build.gradle @@ -9,7 +9,7 @@ subprojects { apply from: "$rootProject.projectDir/gradle/ice.gradle" tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:unchecked" << "-Xlint:-options" + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:-options" << "-Xlint:deprecation" options.encoding = "UTF-8" } } From 0f04414f90a9b8000aaf705ac66f6222cbbb82af Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 11:11:29 -0400 Subject: [PATCH 07/17] Restructure CI --- .github/workflows/ci.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80c11c3c85..b33a021f39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,6 @@ concurrency: cancel-in-progress: true env: - ICE_HOME: ${{ github.workspace }}/ice # Makefile - IceHome: ${{ github.workspace }}\ice # MSBuild Platform: x64 # For Msbuild Configuration: Release # For Msbuild @@ -28,13 +26,19 @@ jobs: include: - os: ubuntu-22.04 ice_build_flags: srcs + cpp_build_flags: ICE_HOME=${{github.workspace}}/ice csharp_build_command: dotnet build + java_buid_flags: -PiceHome=${{github.workspace}}/ice - os: macos-14 ice_build_flags: srcs + cpp_build_flags: ICE_HOME=${{github.workspace}}/ice csharp_build_command: dotnet build + java_buid_flags: -PiceHome=${{github.workspace}}/ice - os: windows-2022 ice_build_flags: /t:BuildDist + cpp_build_flags: /p:IceHome=${{github.workspace}}\ice csharp_build_command: MSBuild + java_buid_flags: -PiceHome=${{github.workspace}}\ice runs-on: ${{ matrix.os }} steps: @@ -53,7 +57,7 @@ jobs: timeout-minutes: 60 with: working_directory: ice - build_flags: ${{ matrix.ice_build_flags || '' }} + build_flags: ${{ matrix.ice_build_flags }} - name: Checkout repository uses: actions/checkout@v4 @@ -66,6 +70,7 @@ jobs: with: working_directory: ice-demos/cpp msbuild_project: msbuild/ice.proj + build_flags: ${{ matrix.cpp_build_flags }} - name: Build C# Demos on ${{ matrix.os }} timeout-minutes: 20 @@ -75,4 +80,4 @@ jobs: - name: Build Java Demos on ${{ matrix.os }} timeout-minutes: 20 working-directory: ice-demos/java - run: ./gradlew build + run: ./gradlew ${{ matrix.java_buid_flags }} build From b9e58eb2fe98f5f2cf8af844eef2d721accb383a Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 11:53:25 -0400 Subject: [PATCH 08/17] Cleanup --- .github/workflows/ci.yml | 36 ++++++++++++++++++++---------------- swift/Rakefile | 1 + 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b33a021f39..7b0be6f6eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,9 +13,9 @@ concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true -env: - Platform: x64 # For Msbuild - Configuration: Release # For Msbuild +# env: +# Platform: x64 # For Msbuild +# Configuration: Release # For Msbuild jobs: ci: @@ -26,19 +26,10 @@ jobs: include: - os: ubuntu-22.04 ice_build_flags: srcs - cpp_build_flags: ICE_HOME=${{github.workspace}}/ice - csharp_build_command: dotnet build - java_buid_flags: -PiceHome=${{github.workspace}}/ice - os: macos-14 ice_build_flags: srcs - cpp_build_flags: ICE_HOME=${{github.workspace}}/ice - csharp_build_command: dotnet build - java_buid_flags: -PiceHome=${{github.workspace}}/ice - os: windows-2022 ice_build_flags: /t:BuildDist - cpp_build_flags: /p:IceHome=${{github.workspace}}\ice - csharp_build_command: MSBuild - java_buid_flags: -PiceHome=${{github.workspace}}\ice runs-on: ${{ matrix.os }} steps: @@ -57,7 +48,21 @@ jobs: timeout-minutes: 60 with: working_directory: ice - build_flags: ${{ matrix.ice_build_flags }} + build_flags: ${{ runner.os == 'Windows' && '/t:BuildDist' || 'srcs' }} + + - name: Windows Environment + if: runner.os == 'Windows' + run: | + echo "Platform=x64" >> $GITHUB_ENV + echo "Configuration=Release" >> $GITHUB_ENV + echo "IceHome=${{github.workspace}}\ice" >> $GITHUB_ENV + echo "ICE_HOME=${{github.workspace}}\ice" >> $GITHUB_ENV + + - name: Linux/MacOS Environment + if: runner.os != 'Windows' + run: | + echo "ICE_HOME=${{github.workspace}}/ice" >> $GITHUB_ENV + echo "IceHome=${{github.workspace}}/ice" >> $GITHUB_ENV - name: Checkout repository uses: actions/checkout@v4 @@ -70,14 +75,13 @@ jobs: with: working_directory: ice-demos/cpp msbuild_project: msbuild/ice.proj - build_flags: ${{ matrix.cpp_build_flags }} - name: Build C# Demos on ${{ matrix.os }} timeout-minutes: 20 working-directory: ice-demos/csharp - run: ${{ matrix.csharp_build_command }} /m msbuild/ice.proj + run: ${{ runner.os == 'Windows' && 'MSBuild' || 'dotnet msbuild' }} /m msbuild/ice.proj - name: Build Java Demos on ${{ matrix.os }} timeout-minutes: 20 working-directory: ice-demos/java - run: ./gradlew ${{ matrix.java_buid_flags }} build + run: ./gradlew build diff --git a/swift/Rakefile b/swift/Rakefile index 187b7c8a2a..038606d777 100644 --- a/swift/Rakefile +++ b/swift/Rakefile @@ -91,6 +91,7 @@ task :iceproj do end project.root_object.development_region = "en" project.root_object.known_regions = ["Base", "en"] + project.build_independent_targets_in_parallel = true # # Sort the project and save it From e6a44850b0683c745538b163a65d144538b088ca Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 12:09:05 -0400 Subject: [PATCH 09/17] Fix name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b0be6f6eb..b8f9f9b156 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Build and test +name: Build on: workflow_dispatch: From ec3c289b68b20ab3fd71bb57a3f2ca6a3be668ae Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 12:16:18 -0400 Subject: [PATCH 10/17] Fix order --- .github/workflows/ci.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8f9f9b156..dcdbd4596e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,20 @@ jobs: runs-on: ${{ matrix.os }} steps: + - name: Windows Environment + if: runner.os == 'Windows' + run: | + echo "Platform=x64" >> $GITHUB_ENV + echo "Configuration=Release" >> $GITHUB_ENV + echo "IceHome=${{github.workspace}}\ice" >> $GITHUB_ENV + echo "ICE_HOME=${{github.workspace}}\ice" >> $GITHUB_ENV + + - name: Linux/MacOS Environment + if: runner.os != 'Windows' + run: | + echo "ICE_HOME=${{github.workspace}}/ice" >> $GITHUB_ENV + echo "IceHome=${{github.workspace}}/ice" >> $GITHUB_ENV + - name: Checkout Ice uses: actions/checkout@v4 with: @@ -50,20 +64,6 @@ jobs: working_directory: ice build_flags: ${{ runner.os == 'Windows' && '/t:BuildDist' || 'srcs' }} - - name: Windows Environment - if: runner.os == 'Windows' - run: | - echo "Platform=x64" >> $GITHUB_ENV - echo "Configuration=Release" >> $GITHUB_ENV - echo "IceHome=${{github.workspace}}\ice" >> $GITHUB_ENV - echo "ICE_HOME=${{github.workspace}}\ice" >> $GITHUB_ENV - - - name: Linux/MacOS Environment - if: runner.os != 'Windows' - run: | - echo "ICE_HOME=${{github.workspace}}/ice" >> $GITHUB_ENV - echo "IceHome=${{github.workspace}}/ice" >> $GITHUB_ENV - - name: Checkout repository uses: actions/checkout@v4 with: From a2b6dc6b63f72d35c4f7ee34e8a4d7c6584c85b5 Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 12:53:30 -0400 Subject: [PATCH 11/17] Fix env --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcdbd4596e..5abe238904 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,10 +36,10 @@ jobs: - name: Windows Environment if: runner.os == 'Windows' run: | - echo "Platform=x64" >> $GITHUB_ENV - echo "Configuration=Release" >> $GITHUB_ENV - echo "IceHome=${{github.workspace}}\ice" >> $GITHUB_ENV - echo "ICE_HOME=${{github.workspace}}\ice" >> $GITHUB_ENV + echo "Platform=x64" >> $env:GITHUB_ENV + echo "Configuration=Release" >> $env:GITHUB_ENV + echo "IceHome=${{github.workspace}}\ice" >> $env:GITHUB_ENV + echo "ICE_HOME=${{github.workspace}}\ice" >> $env:GITHUB_ENV - name: Linux/MacOS Environment if: runner.os != 'Windows' From f54bc0eb8900b754d42c952bb64697706d608f8f Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 14:15:49 -0400 Subject: [PATCH 12/17] Fix Windows ICE_HOME --- .github/workflows/ci.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5abe238904..b3eb3c9d7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,14 +38,17 @@ jobs: run: | echo "Platform=x64" >> $env:GITHUB_ENV echo "Configuration=Release" >> $env:GITHUB_ENV - echo "IceHome=${{github.workspace}}\ice" >> $env:GITHUB_ENV - echo "ICE_HOME=${{github.workspace}}\ice" >> $env:GITHUB_ENV + echo "IceHome=${{ github.workspace }}\ice" >> $env:GITHUB_ENV + + $iceHome = ${{ github.workspace }}/ice + $iceHome = $iceHome.Repalce("\", "/") + echo "ICE_HOME=$iceHome" >> $env:GITHUB_ENV - name: Linux/MacOS Environment if: runner.os != 'Windows' run: | - echo "ICE_HOME=${{github.workspace}}/ice" >> $GITHUB_ENV - echo "IceHome=${{github.workspace}}/ice" >> $GITHUB_ENV + echo "ICE_HOME=${{ github.workspace }}/ice" >> $GITHUB_ENV + echo "IceHome=${{ github.workspace }}/ice" >> $GITHUB_ENV - name: Checkout Ice uses: actions/checkout@v4 From 51fac2f9541c3401d692498644f39ccdbed94599 Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 14:20:54 -0400 Subject: [PATCH 13/17] Add note --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3eb3c9d7d..bdcf013d9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: echo "Configuration=Release" >> $env:GITHUB_ENV echo "IceHome=${{ github.workspace }}\ice" >> $env:GITHUB_ENV + # We need to replace \ with / in the path, specifically for Gradle $iceHome = ${{ github.workspace }}/ice $iceHome = $iceHome.Repalce("\", "/") echo "ICE_HOME=$iceHome" >> $env:GITHUB_ENV From 1d6aa0cdf057dfdeec3031a2198bd35ca793ce1b Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 14:25:17 -0400 Subject: [PATCH 14/17] set CPP_XXX --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdcf013d9b..b93f6569c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,4 +88,8 @@ jobs: - name: Build Java Demos on ${{ matrix.os }} timeout-minutes: 20 working-directory: ice-demos/java - run: ./gradlew build + env: + # For Ice Builder for Gradle + CPP_PLATFORM: x64 + CPP_CONFIGURATION: Release + run: ./gradlew build ${{ runner.os == 'Windows' && '' || '' }} From 14cde2f5c5d809b9fdedd759678f894625c2e417 Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 14:25:52 -0400 Subject: [PATCH 15/17] cleanup --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b93f6569c7..dd8ea5fb81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,4 +92,4 @@ jobs: # For Ice Builder for Gradle CPP_PLATFORM: x64 CPP_CONFIGURATION: Release - run: ./gradlew build ${{ runner.os == 'Windows' && '' || '' }} + run: ./gradlew build From 707555b583ce3e0a1025b629e586b5b9ad89e385 Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 14:31:54 -0400 Subject: [PATCH 16/17] Fix script --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd8ea5fb81..3e97eddb58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: echo "IceHome=${{ github.workspace }}\ice" >> $env:GITHUB_ENV # We need to replace \ with / in the path, specifically for Gradle - $iceHome = ${{ github.workspace }}/ice + $iceHome = "${{ github.workspace }}/ice" $iceHome = $iceHome.Repalce("\", "/") echo "ICE_HOME=$iceHome" >> $env:GITHUB_ENV From 552b1bf3238d7149760b701cbd77f48db66bf02b Mon Sep 17 00:00:00 2001 From: Joe George Date: Mon, 3 Jun 2024 14:35:15 -0400 Subject: [PATCH 17/17] typo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e97eddb58..fcd79a3d9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: # We need to replace \ with / in the path, specifically for Gradle $iceHome = "${{ github.workspace }}/ice" - $iceHome = $iceHome.Repalce("\", "/") + $iceHome = $iceHome.Replace("\", "/") echo "ICE_HOME=$iceHome" >> $env:GITHUB_ENV - name: Linux/MacOS Environment