summaryrefslogtreecommitdiff
path: root/java/demo/Ice/invoke/Client.java
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2009-11-23 13:28:08 +0100
committerBenoit Foucher <benoit@zeroc.com>2009-11-23 13:28:08 +0100
commit2c578015edcb36cdc0acd0227295de1dcca1b995 (patch)
treee163980b5dabb43a40089a29fdf8ff47a3e07f1c /java/demo/Ice/invoke/Client.java
parentno longer generating inspect method for each Ruby exception (diff)
downloadice-2c578015edcb36cdc0acd0227295de1dcca1b995.tar.bz2
ice-2c578015edcb36cdc0acd0227295de1dcca1b995.tar.xz
ice-2c578015edcb36cdc0acd0227295de1dcca1b995.zip
New AMI mapping
Diffstat (limited to 'java/demo/Ice/invoke/Client.java')
-rw-r--r--java/demo/Ice/invoke/Client.java145
1 files changed, 80 insertions, 65 deletions
diff --git a/java/demo/Ice/invoke/Client.java b/java/demo/Ice/invoke/Client.java
index bd01e321545..50664b8931e 100644
--- a/java/demo/Ice/invoke/Client.java
+++ b/java/demo/Ice/invoke/Client.java
@@ -11,77 +11,97 @@ import Demo.*;
public class Client extends Ice.Application
{
- private class AMI_Object_ice_invokeI extends Ice.AMI_Object_ice_invoke
+ private class CallbackI extends Ice.AsyncCallback
{
- public void ice_response(boolean ok, byte[] outParams)
+ @Override
+ public void completed(Ice.AsyncResult r)
{
- if(!ok)
+ Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder();
+ try
{
- System.out.println("Unknown user exception");
+ if(!r.getProxy().end_ice_invoke(outParams, r))
+ {
+ System.out.println("Unknown user exception");
+ }
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
}
- }
-
- public void ice_exception(Ice.LocalException ex)
- {
- ex.printStackTrace();
}
}
- private class AMI_Object_ice_invokeGetValuesI extends Ice.AMI_Object_ice_invoke
+ private class Callback_getValuesI extends Ice.AsyncCallback
{
- public void ice_response(boolean ok, byte[] outParams)
+ @Override
+ public void completed(Ice.AsyncResult r)
{
- if(!ok)
+ Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder();
+ try
{
- System.out.println("Unknown user exception");
+ if(r.getProxy().end_ice_invoke(outParams, r))
+ {
+ //
+ // Unmarshal the results.
+ //
+ Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams.value);
+ Demo.CHolder c = new Demo.CHolder();
+ Demo.CHelper.read(in, c);
+ String str = in.readString();
+ in.readPendingObjects();
+ in.destroy();
+ System.out.println("Got string `" + str + "' and class: s.name=" + c.value.s.name +
+ ", s.value=" + c.value.s.value);
+ }
+ else
+ {
+ System.out.println("Unknown user exception");
+ }
}
- else
+ catch(Ice.LocalException ex)
{
- //
- // Unmarshal the results.
- //
- Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams);
- Demo.CHolder c = new Demo.CHolder();
- Demo.CHelper.read(in, c);
- String str = in.readString();
- in.readPendingObjects();
- in.destroy();
- System.out.println("Got string `" + str + "' and class: s.name=" + c.value.s.name +
- ", s.value=" + c.value.s.value);
+ ex.printStackTrace();
}
}
-
- public void ice_exception(Ice.LocalException ex)
- {
- ex.printStackTrace();
- }
}
- private class AMI_Object_ice_invokeThrowPrintFailureI extends Ice.AMI_Object_ice_invoke
+ private class Callback_throwPrintFailureI extends Ice.AsyncCallback
{
- public void ice_response(boolean ok, byte[] outParams)
+ @Override
+ public void completed(Ice.AsyncResult r)
{
- Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams);
+ Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder();
try
{
- in.throwException();
- }
- catch(Demo.PrintFailure ex)
- {
- // Expected.
+ if(!r.getProxy().end_ice_invoke(outParams, r))
+ {
+ Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams.value);
+ try
+ {
+ in.throwException();
+ }
+ catch(Demo.PrintFailure ex)
+ {
+ // Expected.
+ }
+ catch(Ice.UserException ex)
+ {
+ System.out.println("Unknown user exception");
+ }
+ in.destroy();
+ }
+ else
+ {
+ System.out.println("Expected user exception");
+ }
}
- catch(Ice.UserException ex)
+ catch(Ice.LocalException ex)
{
- System.out.println("Unknown user exception");
+ ex.printStackTrace();
}
- in.destroy();
- }
-
- public void ice_exception(Ice.LocalException ex)
- {
- ex.printStackTrace();
}
}
+
private static void
menu()
{
@@ -169,8 +189,7 @@ public class Client extends Ice.Application
//
if(async)
{
- obj.ice_invoke_async(new AMI_Object_ice_invokeI(), "printString", Ice.OperationMode.Normal,
- out.finished());
+ obj.begin_ice_invoke("printString", Ice.OperationMode.Normal, out.finished(), new CallbackI());
}
else
{
@@ -196,8 +215,8 @@ public class Client extends Ice.Application
//
if(async)
{
- obj.ice_invoke_async(new AMI_Object_ice_invokeI(), "printStringSequence",
- Ice.OperationMode.Normal, out.finished());
+ obj.begin_ice_invoke("printStringSequence", Ice.OperationMode.Normal, out.finished(),
+ new CallbackI());
}
else
{
@@ -225,8 +244,8 @@ public class Client extends Ice.Application
//
if(async)
{
- obj.ice_invoke_async(new AMI_Object_ice_invokeI(), "printDictionary", Ice.OperationMode.Normal,
- out.finished());
+ obj.begin_ice_invoke("printDictionary", Ice.OperationMode.Normal, out.finished(),
+ new CallbackI());
}
else
{
@@ -251,8 +270,7 @@ public class Client extends Ice.Application
//
if(async)
{
- obj.ice_invoke_async(new AMI_Object_ice_invokeI(), "printEnum", Ice.OperationMode.Normal,
- out.finished());
+ obj.begin_ice_invoke("printEnum", Ice.OperationMode.Normal, out.finished(), new CallbackI());
}
else
{
@@ -280,8 +298,7 @@ public class Client extends Ice.Application
//
if(async)
{
- obj.ice_invoke_async(new AMI_Object_ice_invokeI(), "printStruct", Ice.OperationMode.Normal,
- out.finished());
+ obj.begin_ice_invoke("printStruct", Ice.OperationMode.Normal, out.finished(), new CallbackI());
}
else
{
@@ -316,8 +333,8 @@ public class Client extends Ice.Application
//
if(async)
{
- obj.ice_invoke_async(new AMI_Object_ice_invokeI(), "printStructSequence",
- Ice.OperationMode.Normal, out.finished());
+ obj.begin_ice_invoke("printStructSequence", Ice.OperationMode.Normal, out.finished(),
+ new CallbackI());
}
else
{
@@ -347,8 +364,7 @@ public class Client extends Ice.Application
//
if(async)
{
- obj.ice_invoke_async(new AMI_Object_ice_invokeI(), "printClass", Ice.OperationMode.Normal,
- out.finished());
+ obj.begin_ice_invoke("printClass", Ice.OperationMode.Normal, out.finished(), new CallbackI());
}
else
{
@@ -368,8 +384,7 @@ public class Client extends Ice.Application
Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder();
if(async)
{
- obj.ice_invoke_async(new AMI_Object_ice_invokeGetValuesI(), "getValues",
- Ice.OperationMode.Normal, null);
+ obj.begin_ice_invoke("getValues", Ice.OperationMode.Normal, null, new Callback_getValuesI());
}
else
{
@@ -400,8 +415,8 @@ public class Client extends Ice.Application
Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder();
if(async)
{
- obj.ice_invoke_async(new AMI_Object_ice_invokeThrowPrintFailureI(), "throwPrintFailure",
- Ice.OperationMode.Normal, null);
+ obj.begin_ice_invoke("throwPrintFailure", Ice.OperationMode.Normal, null,
+ new Callback_throwPrintFailureI());
}
else
{
@@ -431,7 +446,7 @@ public class Client extends Ice.Application
{
if(async)
{
- obj.ice_invoke_async(new AMI_Object_ice_invokeI(), "shutdown", Ice.OperationMode.Normal, null);
+ obj.begin_ice_invoke("shutdown", Ice.OperationMode.Normal, null, new CallbackI());
}
else
{