diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2014-09-18 09:51:22 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2014-09-18 09:51:22 -0230 |
commit | 4723f7bbd3ea2ffb241df26e5736fa5c04589e7b (patch) | |
tree | 1fb506dbb4f76a5e6ce7e9eada7489e19a0560e4 /java | |
parent | ICE-4891 some minor improvements (diff) | |
download | ice-4723f7bbd3ea2ffb241df26e5736fa5c04589e7b.tar.bz2 ice-4723f7bbd3ea2ffb241df26e5736fa5c04589e7b.tar.xz ice-4723f7bbd3ea2ffb241df26e5736fa5c04589e7b.zip |
ICE-5661 add proxy->begin_ice_getConnection
Diffstat (limited to 'java')
-rw-r--r-- | java/src/Ice/Callback_Object_ice_getConnection.java | 31 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrx.java | 40 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrxHelperBase.java | 127 | ||||
-rw-r--r-- | java/src/IceInternal/ConnectRequestHandler.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/GetConnectionOutgoingAsync.java | 108 | ||||
-rw-r--r-- | java/src/IceInternal/OutgoingAsync.java | 32 | ||||
-rw-r--r-- | java/src/IceInternal/QueueRequestHandler.java | 6 | ||||
-rw-r--r-- | java/test/Ice/ami/AMI.java | 127 | ||||
-rw-r--r-- | java/test/Ice/ami/AllTests.java | 18 | ||||
-rw-r--r-- | java/test/Ice/ami/Client.java | 2 | ||||
-rw-r--r-- | java/test/Ice/ami/Collocated.java | 2 | ||||
-rw-r--r-- | java/test/Ice/ami/lambda/AMI.java | 117 |
12 files changed, 542 insertions, 70 deletions
diff --git a/java/src/Ice/Callback_Object_ice_getConnection.java b/java/src/Ice/Callback_Object_ice_getConnection.java new file mode 100644 index 00000000000..14b5de10939 --- /dev/null +++ b/java/src/Ice/Callback_Object_ice_getConnection.java @@ -0,0 +1,31 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Callback object for {@link ObjectPrx#.begin_ice_getConnection}. + **/ +public abstract class Callback_Object_ice_getConnection extends IceInternal.TwowayCallback + implements Ice.TwowayCallbackArg1<Ice.Connection> +{ + /** + * Called when the invocation completes successfully. + * + * @param __ret The connection being used by the proxy. + **/ + @Override + public abstract void response(Ice.Connection __ret); + + @Override + public final void __completed(AsyncResult __result) + { + ObjectPrxHelperBase.__ice_getConnection_completed(this, __result); + } +} diff --git a/java/src/Ice/ObjectPrx.java b/java/src/Ice/ObjectPrx.java index eddfec7e8f7..b3af5ef6eb8 100644 --- a/java/src/Ice/ObjectPrx.java +++ b/java/src/Ice/ObjectPrx.java @@ -1136,6 +1136,46 @@ public interface ObjectPrx Connection ice_getConnection(); /** + * Asynchronously gets the connection for this proxy. The call does not block. + * + * @return The asynchronous result object. + **/ + AsyncResult begin_ice_getConnection(); + + /** + * Asynchronously gets the connection for this proxy. The call does not block. + * + * @return The asynchronous result object. + **/ + AsyncResult begin_ice_getConnection(Callback __cb); + + /** + * Asynchronously gets the connection for this proxy. The call does not block. + * + * @param cb The callback object to notify the application when the operation is complete. + * @return The asynchronous result object. + **/ + AsyncResult begin_ice_getConnection(Callback_Object_ice_getConnection __cb); + + /** + * Asynchronously gets the connection for this proxy. The call does not block. + * + * @param __responseCb The callback object to notify the application when the there is a response available. + * @param __exceptionCb The callback object to notify the application when the there is an exception getting + * connection. + * @return The asynchronous result object. + **/ + AsyncResult begin_ice_getConnection(IceInternal.Functional_GenericCallback1<Ice.Connection> __responseCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb); + + /** + * Completes the asynchronous get connection. + * + * @param __result The asynchronous result. + **/ + Ice.Connection end_ice_getConnection(AsyncResult __result); + + /** * Returns the cached {@link Connection} for this proxy. If the proxy does not yet have an established * connection, it does not attempt to create a connection. * diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java index edda748ea7a..72d3d99f150 100644 --- a/java/src/Ice/ObjectPrxHelperBase.java +++ b/java/src/Ice/ObjectPrxHelperBase.java @@ -2392,6 +2392,129 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable } /** + * Asynchronously gets the connection for this proxy. The call does not block. + * + * @return The asynchronous result object. + **/ + @Override + public AsyncResult + begin_ice_getConnection() + { + AsyncResult result = begin_ice_getConnectionInternal(null); + return result; + } + + /** + * Asynchronously gets the connection for this proxy. The call does not block. + * + * @param __cb The callback object to notify the application when the flush is complete. + * @return The asynchronous result object. + **/ + @Override + public AsyncResult + begin_ice_getConnection(Callback __cb) + { + AsyncResult result = begin_ice_getConnectionInternal(__cb); + return result; + } + + /** + * Asynchronously gets the connection for this proxy. The call does not block. + * + * @param __cb The callback object to notify the application when the flush is complete. + * @return The asynchronous result object. + **/ + @Override + public AsyncResult + begin_ice_getConnection(Callback_Object_ice_getConnection __cb) + { + AsyncResult result = begin_ice_getConnectionInternal(__cb); + return result; + } + + private class FunctionalCallback_Object_ice_getConnection + extends IceInternal.Functional_TwowayCallbackArg1<Ice.Connection> + { + FunctionalCallback_Object_ice_getConnection( + IceInternal.Functional_GenericCallback1<Ice.Connection> __responseCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb) + { + super(__responseCb, __exceptionCb, null); + } + + @Override + public final void __completed(AsyncResult __result) + { + ObjectPrxHelperBase.__ice_getConnection_completed(this, __result); + } + } + + /** + * Asynchronously gets the connection for this proxy. The call does not block. + * + * @param __responseCb The callback object to notify the application when the there is a response available. + * @param __exceptionCb The callback object to notify the application when the there is an exception getting + * connection. + * @return The asynchronous result object. + **/ + @Override + public AsyncResult + begin_ice_getConnection(IceInternal.Functional_GenericCallback1<Ice.Connection> __responseCb, + IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb) + { + return begin_ice_getConnectionInternal( + new FunctionalCallback_Object_ice_getConnection(__responseCb, __exceptionCb)); + } + + private static final String __ice_getConnection_name = "ice_getConnection"; + + private AsyncResult + begin_ice_getConnectionInternal(IceInternal.CallbackBase __cb) + { + IceInternal.GetConnectionOutgoingAsync __result = + new IceInternal.GetConnectionOutgoingAsync(this, __ice_getConnection_name, __cb); + try + { + __result.__invoke(); + } + catch(Exception __ex) + { + __result.invokeExceptionAsync(__ex); + } + return __result; + } + + @Override + public Ice.Connection + end_ice_getConnection(AsyncResult __iresult) + { + IceInternal.AsyncResultI __result = (IceInternal.AsyncResultI)__iresult; + IceInternal.AsyncResultI.check(__result, this, __ice_getConnection_name); + __result.__wait(); + return ice_getCachedConnection(); + } + + static public final void __ice_getConnection_completed(TwowayCallbackArg1<Ice.Connection> __cb, AsyncResult __result) + { + Ice.Connection __ret = null; + try + { + __ret = __result.getProxy().end_ice_getConnection(__result); + } + catch(LocalException __ex) + { + __cb.exception(__ex); + return; + } + catch(SystemException __ex) + { + __cb.exception(__ex); + return; + } + __cb.response(__ret); + } + + /** * Returns the cached {@link Connection} for this proxy. If the proxy does not yet have an established * connection, it does not attempt to create a connection. * @@ -2531,7 +2654,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable public void end_ice_flushBatchRequests(AsyncResult __iresult) { - IceInternal.AsyncResultI __result = (IceInternal.AsyncResultI)__iresult; + IceInternal.AsyncResultI __result = (IceInternal.AsyncResultI)__iresult; IceInternal.AsyncResultI.check(__result, this, __ice_flushBatchRequests_name); __result.__wait(); } @@ -2767,7 +2890,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable } } } - + public void cacheMessageBuffers(IceInternal.BasicStream is, IceInternal.BasicStream os) { diff --git a/java/src/IceInternal/ConnectRequestHandler.java b/java/src/IceInternal/ConnectRequestHandler.java index 25d9859b997..60881c35c6d 100644 --- a/java/src/IceInternal/ConnectRequestHandler.java +++ b/java/src/IceInternal/ConnectRequestHandler.java @@ -201,7 +201,7 @@ public class ConnectRequestHandler return _connection; } } - + @Override synchronized public ConnectionI waitForConnection() diff --git a/java/src/IceInternal/GetConnectionOutgoingAsync.java b/java/src/IceInternal/GetConnectionOutgoingAsync.java new file mode 100644 index 00000000000..95878b90709 --- /dev/null +++ b/java/src/IceInternal/GetConnectionOutgoingAsync.java @@ -0,0 +1,108 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceInternal; + +public class GetConnectionOutgoingAsync extends IceInternal.OutgoingAsync +{ + public GetConnectionOutgoingAsync(Ice.ObjectPrxHelperBase prx, String operation, CallbackBase callback) + { + super(prx, operation, callback); + _observer = ObserverHelper.get(prx, operation); + } + + public void __invoke() + { + while(true) + { + try + { + _handler = _proxy.__getRequestHandler(); + _handler.sendAsyncRequest(this); + } + catch(RetryException ex) + { + _proxy.__setRequestHandler(_handler, null); + } + catch(Ice.Exception ex) + { + handleException(ex); + } + break; + } + } + + @Override + public int send(Ice.ConnectionI conection, boolean compress, boolean response) + throws RetryException + { + sent(); + return 0; + } + + @Override + public int invokeCollocated(CollocatedRequestHandler handler) + { + sent(); + return 0; + } + + @Override + public boolean sent() + { + synchronized(_monitor) + { + _state |= StateDone; + _monitor.notifyAll(); + } + invokeCompleted(); + return false; + } + + @Override + public void invokeSent() + { + // No sent callback + } + + @Override + public void finished(Ice.Exception exc) + { + try + { + handleException(exc); + } + catch(Ice.Exception ex) + { + invokeExceptionAsync(ex); + } + } + + private void handleException(Ice.Exception exc) + { + try + { + Ice.Holder<Integer> interval = new Ice.Holder<Integer>(); + _cnt = _proxy.__handleException(exc, _handler, Ice.OperationMode.Idempotent, false, interval, _cnt); + if(_observer != null) + { + _observer.retried(); // Invocation is being retried + } + _instance.retryQueue().add(this, interval.value); + } + catch(Ice.Exception ex) + { + if(_observer != null) + { + _observer.failed(ex.ice_name()); + } + throw ex; + } + } +} diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java index 84bfc477768..992b9ca6265 100644 --- a/java/src/IceInternal/OutgoingAsync.java +++ b/java/src/IceInternal/OutgoingAsync.java @@ -17,7 +17,7 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC _proxy = (Ice.ObjectPrxHelperBase) prx; _encoding = Protocol.getCompatibleEncoding(_proxy.__reference().getEncoding()); } - + public OutgoingAsync(Ice.ObjectPrx prx, String operation, CallbackBase cb, IceInternal.BasicStream is, IceInternal.BasicStream os) { @@ -26,8 +26,8 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC _proxy = (Ice.ObjectPrxHelperBase) prx; _encoding = Protocol.getCompatibleEncoding(_proxy.__reference().getEncoding()); } - - public void prepare(String operation, Ice.OperationMode mode, java.util.Map<String, String> ctx, + + public void prepare(String operation, Ice.OperationMode mode, java.util.Map<String, String> ctx, boolean explicitCtx, boolean synchronous) { _handler = null; @@ -200,7 +200,7 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC _monitor.notifyAll(); // Don't call the sent call is already sent. - return !alreadySent && _callback != null && _callback.__hasSentCallback(); + return !alreadySent && _callback != null && _callback.__hasSentCallback(); } } @@ -264,7 +264,7 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC // with the connection locked. Therefore, it must not invoke // any user callbacks. // - + assert (_proxy.ice_isTwoway()); // Can only be called for twoways. byte replyStatus; @@ -279,14 +279,14 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC _childObserver.detach(); _childObserver = null; } - + if(_timeoutRequestHandler != null) { _future.cancel(false); _future = null; _timeoutRequestHandler = null; } - + // _is can already be initialized if the invocation is retried if(_is == null) { @@ -294,7 +294,7 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC } _is.swap(is); replyStatus = _is.readByte(); - + switch(replyStatus) { case ReplyStatus.replyOK: @@ -422,7 +422,7 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC } _state |= StateDone; _monitor.notifyAll(); - + if(_callback == null) { if(_observer != null) @@ -579,7 +579,7 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC _os.writeEncaps(encaps); } } - + public void cacheMessageBuffers() { if(_proxy.__reference().getInstance().cacheMessageBuffers() > 0) @@ -597,11 +597,11 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC _is.reset(); } _os.reset(); - + _proxy.cacheMessageBuffers(_is, _os); } } - + @Override public void invokeExceptionAsync(final Ice.Exception ex) { @@ -621,7 +621,7 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC super.invokeExceptionAsync(ex); } - + private void handleException(Ice.Exception exc) { try @@ -632,7 +632,7 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC { _observer.retried(); // Invocation is being retried. } - + // // Schedule the retry. Note that we always schedule the retry // on the retry queue even if the invocation can be retried @@ -654,10 +654,10 @@ public class OutgoingAsync extends AsyncResultI implements OutgoingAsyncMessageC } protected Ice.ObjectPrxHelperBase _proxy; + protected RequestHandler _handler; + protected int _cnt; - private RequestHandler _handler; private Ice.EncodingVersion _encoding; - private int _cnt; private Ice.OperationMode _mode; private boolean _sent; // diff --git a/java/src/IceInternal/QueueRequestHandler.java b/java/src/IceInternal/QueueRequestHandler.java index f9d90e3e72e..6709c2f7ab3 100644 --- a/java/src/IceInternal/QueueRequestHandler.java +++ b/java/src/IceInternal/QueueRequestHandler.java @@ -21,7 +21,7 @@ import Ice.ConnectionI; public class QueueRequestHandler implements RequestHandler { public - QueueRequestHandler(Instance instance, RequestHandler delegate) + QueueRequestHandler(Instance instance, RequestHandler delegate) { _executor = instance.getQueueExecutor(); assert(delegate != null); @@ -34,7 +34,7 @@ public class QueueRequestHandler implements RequestHandler { try { - Future<Void> future = _executor.submit(new Callable<Void>() + Future<Void> future = _executor.submit(new Callable<Void>() { @Override public Void call() throws RetryException @@ -81,7 +81,7 @@ public class QueueRequestHandler implements RequestHandler { try { - Future<Void> future = _executor.submit(new Callable<Void>() + Future<Void> future = _executor.submit(new Callable<Void>() { @Override public Void call() diff --git a/java/test/Ice/ami/AMI.java b/java/test/Ice/ami/AMI.java index 67c6920d142..aa3f9c9b328 100644 --- a/java/test/Ice/ami/AMI.java +++ b/java/test/Ice/ami/AMI.java @@ -100,6 +100,13 @@ public class AMI } public void + connection(Ice.AsyncResult result) + { + test(result.getProxy().end_ice_getConnection(result) != null); + called(); + } + + public void op(Ice.AsyncResult result) { TestIntfPrxHelper.uncheckedCast(result.getProxy()).end_op(result); @@ -204,6 +211,24 @@ public class AMI } public void + connectionEx(Ice.AsyncResult result) + { + try + { + result.getProxy().end_ice_getConnection(result); + test(false); + } + catch(Ice.NoEndpointException ex) + { + called(); + } + catch(Ice.LocalException ex) + { + test(false); + } + } + + public void opEx(Ice.AsyncResult result) { try @@ -256,6 +281,13 @@ public class AMI } public void + connection(Ice.Connection conn) + { + test(conn != null); + called(); + } + + public void op() { called(); @@ -317,6 +349,12 @@ public class AMI } public void + connection(Ice.Connection conn) + { + test(false); + } + + public void op() { test(false); @@ -548,11 +586,12 @@ public class AMI } public static void - run(Application app, Ice.Communicator communicator, TestIntfPrx p, TestIntfControllerPrx testController) + run(Application app, Ice.Communicator communicator, boolean collocated, TestIntfPrx p, + TestIntfControllerPrx testController) { - + PrintWriter out = app.getWriter(); - + out.print("testing begin/end invocation... "); out.flush(); { @@ -579,6 +618,12 @@ public class AMI result = p.begin_ice_ids(ctx); test(p.end_ice_ids(result).length == 2); + if(!collocated) + { + result = p.begin_ice_getConnection(); + test(p.end_ice_getConnection(result) != null); + } + result = p.begin_op(); p.end_op(result); result = p.begin_op(ctx); @@ -701,6 +746,20 @@ public class AMI }); cb.check(); + if(!collocated) + { + p.begin_ice_getConnection(new Ice.Callback() + { + @Override + public void + completed(Ice.AsyncResult r) + { + cb.connection(r); + } + }); + cb.check(); + } + p.begin_op(new Ice.Callback() { @Override @@ -912,6 +971,27 @@ public class AMI }); cb.check(); + if(!collocated) + { + p.begin_ice_getConnection(new Ice.Callback_Object_ice_getConnection() + { + @Override + public void + response(Ice.Connection conn) + { + cb.connection(conn); + } + + @Override + public void + exception(Ice.LocalException ex) + { + test(false); + } + }); + cb.check(); + } + p.begin_op(new Callback_TestIntf_op() { @Override @@ -1131,6 +1211,20 @@ public class AMI }); cb.check(); + if(!collocated) + { + i.begin_ice_getConnection(new Ice.Callback() + { + @Override + public void + completed(Ice.AsyncResult r) + { + cb.connectionEx(r); + } + }); + cb.check(); + } + i.begin_op(new Ice.Callback() { @Override @@ -1222,6 +1316,27 @@ public class AMI }); cb.check(); + if(!collocated) + { + i.begin_ice_getConnection(new Ice.Callback_Object_ice_getConnection() + { + @Override + public void + response(Ice.Connection conn) + { + test(false); + } + + @Override + public void + exception(Ice.LocalException ex) + { + cb.ex(ex); + } + }); + cb.check(); + } + i.begin_op(new Callback_TestIntf_op() { @Override @@ -2198,7 +2313,7 @@ public class AMI { test(r1.sentSynchronously() && r1.isSent() && !r1.isCompleted() || !r1.sentSynchronously() && !r1.isCompleted()); - + test(!r2.sentSynchronously() && !r2.isCompleted()); } } @@ -2298,9 +2413,9 @@ public class AMI // // Send multiple opWithPayload, followed by a close and followed by multiple opWithPaylod. - // The goal is to make sure that none of the opWithPayload fail even if the server closes + // The goal is to make sure that none of the opWithPayload fail even if the server closes // the connection gracefully in between. - // + // int maxQueue = 2; boolean done = false; while(!done && maxQueue < 50) diff --git a/java/test/Ice/ami/AllTests.java b/java/test/Ice/ami/AllTests.java index 8e98a2e7667..ffe95450b2c 100644 --- a/java/test/Ice/ami/AllTests.java +++ b/java/test/Ice/ami/AllTests.java @@ -27,9 +27,9 @@ public class AllTests throw new RuntimeException(); } } - + public static void - allTests(Application app) + allTests(Application app, boolean collocated) { Ice.Communicator communicator = app.communicator(); PrintWriter out = app.getWriter(); @@ -47,22 +47,22 @@ public class AllTests TestIntfControllerPrx testController = TestIntfControllerPrxHelper.uncheckedCast(obj); out.println("testing with new AMI mapping... "); - test.Ice.ami.AMI.run(app, communicator, p, testController); - + test.Ice.ami.AMI.run(app, communicator, collocated, p, testController); + // // Use reflection to load TwowaysLambdaAMI as that is only supported with Java >= 1.8 - // + // try { Class<?> cls = IceInternal.Util.findClass("test.Ice.ami.lambda.AMI", null); if(cls != null) { - java.lang.reflect.Method run = cls.getDeclaredMethod("run", - new Class<?>[]{test.Util.Application.class, Ice.Communicator.class, TestIntfPrx.class, + java.lang.reflect.Method run = cls.getDeclaredMethod("run", + new Class<?>[]{test.Util.Application.class, Ice.Communicator.class, boolean.class, TestIntfPrx.class, TestIntfControllerPrx.class}); out.println("testing with lambda AMI mapping... "); out.flush(); - run.invoke(null, app, communicator, p, testController); + run.invoke(null, app, communicator, collocated, p, testController); } } catch(java.lang.NoSuchMethodException ex) @@ -77,7 +77,7 @@ public class AllTests { throw new RuntimeException(ex); } - + p.shutdown(); } } diff --git a/java/test/Ice/ami/Client.java b/java/test/Ice/ami/Client.java index e95e0e9bfb6..3e547a17ec0 100644 --- a/java/test/Ice/ami/Client.java +++ b/java/test/Ice/ami/Client.java @@ -14,7 +14,7 @@ public class Client extends test.Util.Application @Override public int run(String[] args) { - AllTests.allTests(this); + AllTests.allTests(this, false); return 0; } diff --git a/java/test/Ice/ami/Collocated.java b/java/test/Ice/ami/Collocated.java index 765c8944413..3385facc305 100644 --- a/java/test/Ice/ami/Collocated.java +++ b/java/test/Ice/ami/Collocated.java @@ -22,7 +22,7 @@ public class Collocated extends test.Util.Application adapter2.add(new TestControllerI(adapter), communicator().stringToIdentity("testController")); adapter2.activate(); - AllTests.allTests(this); + AllTests.allTests(this, true); return 0; } diff --git a/java/test/Ice/ami/lambda/AMI.java b/java/test/Ice/ami/lambda/AMI.java index b89a51ae0f5..0e013b97435 100644 --- a/java/test/Ice/ami/lambda/AMI.java +++ b/java/test/Ice/ami/lambda/AMI.java @@ -101,6 +101,13 @@ public class AMI } public void + connection(Ice.AsyncResult result) + { + test(result.getProxy().end_ice_getConnection(result) != null); + called(); + } + + public void op(Ice.AsyncResult result) { TestIntfPrxHelper.uncheckedCast(result.getProxy()).end_op(result); @@ -205,6 +212,24 @@ public class AMI } public void + connectionEx(Ice.AsyncResult result) + { + try + { + result.getProxy().end_ice_getConnection(result); + test(false); + } + catch(Ice.NoEndpointException ex) + { + called(); + } + catch(Ice.Exception ex) + { + test(false); + } + } + + public void opEx(Ice.AsyncResult result) { try @@ -257,6 +282,13 @@ public class AMI } public void + connection(Ice.Connection conn) + { + test(conn != null); + called(); + } + + public void op() { called(); @@ -318,6 +350,12 @@ public class AMI } public void + connection(Ice.Connection conn) + { + test(false); + } + + public void op() { test(false); @@ -549,9 +587,10 @@ public class AMI } public static void - run(Application app, Ice.Communicator communicator, TestIntfPrx p, TestIntfControllerPrx testController) + run(Application app, Ice.Communicator communicator, boolean collocated, TestIntfPrx p, + TestIntfControllerPrx testController) { - + PrintWriter out = app.getWriter(); out.print("testing response callback... "); @@ -560,12 +599,12 @@ public class AMI final ResponseCallback cb = new ResponseCallback(); java.util.Map<String, String> ctx = new java.util.HashMap<String, String>(); - p.begin_ice_isA("::Test::TestIntf", + p.begin_ice_isA("::Test::TestIntf", (boolean r) -> cb.isA(r), (Ice.Exception ex) -> test(false)); cb.check(); - - p.begin_ice_isA("::Test::TestIntf", + + p.begin_ice_isA("::Test::TestIntf", (boolean r) -> cb.isA(r), (Ice.Exception ex) -> test(false)); cb.check(); @@ -574,8 +613,8 @@ public class AMI () -> cb.ping(), (Ice.Exception ex) -> test(false)); cb.check(); - - p.begin_ice_ping(ctx, + + p.begin_ice_ping(ctx, () -> cb.ping(), (Ice.Exception ex) -> test(false)); cb.check(); @@ -584,8 +623,8 @@ public class AMI (String id) -> cb.id(id), (Ice.Exception ex) -> test(false)); cb.check(); - - p.begin_ice_id(ctx, + + p.begin_ice_id(ctx, (String id) -> cb.id(id), (Ice.Exception ex) -> test(false)); cb.check(); @@ -594,18 +633,26 @@ public class AMI (String[] ids) -> cb.ids(ids), (Ice.Exception ex) -> test(false)); cb.check(); - + p.begin_ice_ids(ctx, (String[] ids) -> cb.ids(ids), (Ice.Exception ex) -> test(false)); cb.check(); + if(!collocated) + { + p.begin_ice_getConnection( + (Ice.Connection conn) -> cb.connection(conn), + (Ice.Exception ex) -> test(false)); + cb.check(); + } + p.begin_op( () -> cb.op(), (Ice.Exception ex) -> test(false)); cb.check(); - - p.begin_op(ctx, + + p.begin_op(ctx, () -> cb.op(), (Ice.Exception ex) -> test(false)); cb.check(); @@ -614,8 +661,8 @@ public class AMI (int r) -> cb.opWithResult(r), (Ice.Exception ex) -> test(false)); cb.check(); - - p.begin_opWithResult(ctx, + + p.begin_opWithResult(ctx, (int r) -> cb.opWithResult(r), (Ice.Exception ex) -> test(false)); cb.check(); @@ -625,8 +672,8 @@ public class AMI (Ice.UserException ex) -> cb.opWithUE(ex), (Ice.Exception ex) -> test(false)); cb.check(); - - p.begin_opWithUE(ctx, + + p.begin_opWithUE(ctx, () -> test(false), (Ice.UserException ex) -> cb.opWithUE(ex), (Ice.Exception ex) -> test(false)); @@ -640,7 +687,7 @@ public class AMI TestIntfPrx i = TestIntfPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); final ExceptionCallback cb = new ExceptionCallback(); - i.begin_ice_isA("::Test::TestIntf", + i.begin_ice_isA("::Test::TestIntf", (boolean r) -> test(false), (Ice.Exception ex) -> cb.ex(ex)); cb.check(); @@ -660,6 +707,14 @@ public class AMI (Ice.Exception ex) -> cb.ex(ex)); cb.check(); + if(!collocated) + { + i.begin_ice_getConnection( + (Ice.Connection conn) -> test(false), + (Ice.Exception ex) -> cb.ex(ex)); + cb.check(); + } + i.begin_op( () -> test(false), (Ice.Exception ex) -> cb.ex(ex)); @@ -672,7 +727,7 @@ public class AMI { final SentCallback cb = new SentCallback(); - p.begin_ice_isA("", + p.begin_ice_isA("", (boolean r) -> cb.isA(r), (Ice.Exception ex) -> cb.ex(ex), (boolean ss) -> cb.sent(ss)); @@ -965,7 +1020,7 @@ public class AMI } out.println("ok"); } - + out.print("testing null callbacks..."); try { @@ -978,27 +1033,27 @@ public class AMI { // Excepted when response and exception callback are both null. } - + try { p.begin_ice_ping(() -> {}, null); - + } catch(IllegalArgumentException ex) { test(false); } - + try { p.begin_ice_ping(null, (Ice.Exception ex) -> {}); - + } catch(IllegalArgumentException ex) { test(false); } - + try { IceInternal.Functional_BoolCallback response = null; @@ -1010,27 +1065,27 @@ public class AMI { // Excepted when response and exception callback are both null. } - + try { p.begin_ice_isA("::Test::TestIntf", (boolean v) -> {}, null); - + } catch(IllegalArgumentException ex) { test(false); } - + try { p.begin_ice_isA("::Test::TestIntf", null, (Ice.Exception ex) -> {}); - + } catch(IllegalArgumentException ex) { test(false); } - + try { IceInternal.Functional_VoidCallback response = null; @@ -1043,7 +1098,7 @@ public class AMI // an operation that throws user exceptions both user exception callback // an local exception callback must be present. } - + try { IceInternal.Functional_VoidCallback response = null; @@ -1056,7 +1111,7 @@ public class AMI // an operation that throws user exceptions both user exception callback // an local exception callback must be present. } - + try { IceInternal.Functional_VoidCallback response = null; |