diff --git a/java/Ice/interceptor/InterceptorI.java b/java/Ice/interceptor/InterceptorI.java index eca679afe7..ecfee3e730 100644 --- a/java/Ice/interceptor/InterceptorI.java +++ b/java/Ice/interceptor/InterceptorI.java @@ -4,11 +4,12 @@ import com.zeroc.demos.Ice.interceptor.Demo.*; import com.zeroc.Ice.Current; -import com.zeroc.Ice.Request; +import com.zeroc.Ice.IncomingRequest; +import com.zeroc.Ice.OutgoingResponse; import java.util.concurrent.CompletionStage; import java.util.Set; -class InterceptorI extends com.zeroc.Ice.DispatchInterceptor +class InterceptorI implements com.zeroc.Ice.Object { InterceptorI(com.zeroc.Ice.Object servant, AuthenticatorI authenticator, Set securedOperations) { @@ -18,20 +19,19 @@ class InterceptorI extends com.zeroc.Ice.DispatchInterceptor } @Override - public CompletionStage dispatch(Request request) + public CompletionStage dispatch(IncomingRequest request) throws com.zeroc.Ice.UserException { - Current current = request.getCurrent(); // // Check if the operation requires authorization to invoke. // - if(_securedOperations.contains(current.operation)) + if(_securedOperations.contains(request.current.operation)) { // // Validate the client's access token before dispatching to the servant. // 'validateToken' throws an exception if the token is invalid or expired. // - String tokenValue = current.ctx.get("accessToken"); + String tokenValue = request.current.ctx.get("accessToken"); if(tokenValue != null) { _authenticator.validateToken(tokenValue); @@ -44,7 +44,7 @@ public CompletionStage dispatch(Request request) throw new AuthorizationException(); } } - return _servant.ice_dispatch(request); + return _servant.dispatch(request); } private final com.zeroc.Ice.Object _servant; diff --git a/java/Ice/interrupt/Client.java b/java/Ice/interrupt/Client.java index 8da3b92b9e..e2f9527b3b 100644 --- a/java/Ice/interrupt/Client.java +++ b/java/Ice/interrupt/Client.java @@ -113,7 +113,7 @@ else if(line.equals("b")) { System.out.println("blocking task " + id + " interrupted"); } - catch(com.zeroc.Ice.Exception e) + catch(com.zeroc.Ice.LocalException e) { System.out.println("blocking task " + id + " failed"); e.printStackTrace(); diff --git a/java/Ice/interrupt/Server.java b/java/Ice/interrupt/Server.java index d31d5f8dc6..06c958407f 100644 --- a/java/Ice/interrupt/Server.java +++ b/java/Ice/interrupt/Server.java @@ -21,11 +21,8 @@ public static void main(String[] args) // By using an executor it is straightforward to interrupt any servant // dispatch threads by using ExecutorService.shutdownNow. // - final ExecutorService executor = Executors.newFixedThreadPool(5); - initData.dispatcher = (runnable, con) -> - { - executor.submit(runnable); - }; + final ExecutorService executorService = Executors.newFixedThreadPool(5); + initData.executor = (runnable, con) -> executorService.submit(runnable); // // Try with resources block - communicator is automatically destroyed @@ -41,7 +38,7 @@ public static void main(String[] args) // Runtime.getRuntime().addShutdownHook(new Thread(() -> { - executor.shutdownNow(); + executorService.shutdownNow(); communicator.destroy(); })); @@ -53,7 +50,7 @@ public static void main(String[] args) else { com.zeroc.Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TaskManager"); - adapter.add(new TaskManagerI(executor), com.zeroc.Ice.Util.stringToIdentity("manager")); + adapter.add(new TaskManagerI(executorService), com.zeroc.Ice.Util.stringToIdentity("manager")); adapter.activate(); communicator.waitForShutdown(); diff --git a/java/Ice/invoke/PrinterI.java b/java/Ice/invoke/PrinterI.java index 7227b3a60d..b502a15baf 100644 --- a/java/Ice/invoke/PrinterI.java +++ b/java/Ice/invoke/PrinterI.java @@ -119,11 +119,9 @@ else if(current.operation.equals("shutdown")) } else { - com.zeroc.Ice.OperationNotExistException ex = new com.zeroc.Ice.OperationNotExistException(); - ex.id = current.id; - ex.facet = current.facet; - ex.operation = current.operation; - throw ex; + // No need to specify the identity/facet/operation: Ice fills them in automatically + // using 'current'. + throw new com.zeroc.Ice.OperationNotExistException(); } // diff --git a/java/Ice/swing/Client.java b/java/Ice/swing/Client.java index f97af49947..6a8012a898 100644 --- a/java/Ice/swing/Client.java +++ b/java/Ice/swing/Client.java @@ -50,7 +50,7 @@ public static void main(final String[] args) 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); + initData.executor = (runnable, connection) -> SwingUtilities.invokeLater(runnable); _communicator = com.zeroc.Ice.Util.initialize(args, initData); Runtime.getRuntime().addShutdownHook(new Thread(() -> _communicator.destroy())); diff --git a/java/android/hello/src/main/java/com/zeroc/hello/HelloApp.java b/java/android/hello/src/main/java/com/zeroc/hello/HelloApp.java index 606c58d317..ac6ea563a1 100644 --- a/java/android/hello/src/main/java/com/zeroc/hello/HelloApp.java +++ b/java/android/hello/src/main/java/com/zeroc/hello/HelloApp.java @@ -81,7 +81,6 @@ else if(m.what == MSG_EXCEPTION || m.what == MSG_RESPONSE) WifiManager.MulticastLock lock = wifiManager.createMulticastLock("com.zeroc.hello"); lock.acquire(); - // SSL initialization can take some time. To avoid blocking the // calling thread, we perform the initialization in a separate thread. new Thread(() -> { @@ -89,8 +88,7 @@ else if(m.what == MSG_EXCEPTION || m.what == MSG_RESPONSE) { InitializationData initData = new InitializationData(); - initData.dispatcher = (Runnable runnable, Connection connection) -> - _uiHandler.post(runnable); + initData.executor = (Runnable runnable, Connection connection) -> _uiHandler.post(runnable); initData.properties = Util.createProperties(); initData.properties.setProperty("Ice.Trace.Network", "3");