summaryrefslogtreecommitdiff
path: root/java/demo
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
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')
-rw-r--r--java/demo/Glacier2/chat/Client.java71
-rw-r--r--java/demo/Ice/applet/HelloApplet.java50
-rw-r--r--java/demo/Ice/async/Client.java13
-rw-r--r--java/demo/Ice/invoke/Client.java145
-rw-r--r--java/demo/Ice/swing/Client.java78
5 files changed, 191 insertions, 166 deletions
diff --git a/java/demo/Glacier2/chat/Client.java b/java/demo/Glacier2/chat/Client.java
index 78bee7b1799..fbd3aa7c8a1 100644
--- a/java/demo/Glacier2/chat/Client.java
+++ b/java/demo/Glacier2/chat/Client.java
@@ -85,7 +85,6 @@ public class Client extends JFrame
});
}
-
Client(String[] args)
{
// Build the JTextArea that shows the chat conversation.
@@ -113,7 +112,7 @@ public class Client extends JFrame
_input = new JTextArea("");
_input.setLineWrap(true);
_input.setEditable(true);
- _input.addKeyListener( new KeyListener()
+ _input.addKeyListener(new KeyListener()
{
public void
keyTyped(KeyEvent e)
@@ -126,11 +125,17 @@ public class Client extends JFrame
String msg = doc.getText(0, doc.getLength()).trim();
if(msg.length() > 0)
{
- _chat.say_async(new Demo.AMI_ChatSession_say()
+ _chat.begin_say(msg, new Demo.Callback_ChatSession_say()
{
@Override
public void
- ice_exception(final LocalException ex)
+ response()
+ {
+ }
+
+ @Override
+ public void
+ exception(final LocalException ex)
{
SwingUtilities.invokeLater(new Runnable() {
@@ -141,13 +146,7 @@ public class Client extends JFrame
}
});
}
-
- @Override
- public void
- ice_response()
- {
- }
- }, msg);
+ });
}
}
catch(BadLocationException e1)
@@ -353,46 +352,42 @@ public class Client extends JFrame
_session.addWithUUID(servant));
_chat = Demo.ChatSessionPrxHelper.uncheckedCast(_session.session());
- _chat.setCallback_async(new Demo.AMI_ChatSession_setCallback()
- {
+ _chat.begin_setCallback(callback, new Demo.Callback_ChatSession_setCallback()
+ {
@Override
public void
- ice_exception(LocalException ex)
+ response()
{
SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
{
+ assert _loginDialog != null;
+ _loginDialog.dispose();
+
+ _login.setEnabled(false);
+ _logout.setEnabled(true);
- public void
- run()
- {
- destroySession();
- }
- });
+ _input.setEnabled(true);
+
+ _status.setText("Connected with " + _hostField.getText());
+ }
+ });
}
@Override
public void
- ice_response()
+ exception(LocalException ex)
{
- SwingUtilities.invokeLater(new Runnable()
- {
- public void
- run()
+ SwingUtilities.invokeLater(new Runnable()
{
- assert _loginDialog != null;
- _loginDialog.dispose();
-
- _login.setEnabled(false);
- _logout.setEnabled(true);
-
- _input.setEnabled(true);
-
- _status.setText("Connected with " + _hostField.getText());
- }
- });
+ public void run()
+ {
+ destroySession();
+ }
+ });
}
-
- }, callback);
+ });
}
public void
diff --git a/java/demo/Ice/applet/HelloApplet.java b/java/demo/Ice/applet/HelloApplet.java
index 7f7100cf668..21a936a1223 100644
--- a/java/demo/Ice/applet/HelloApplet.java
+++ b/java/demo/Ice/applet/HelloApplet.java
@@ -343,11 +343,26 @@ public class HelloApplet extends JApplet
return Demo.HelloPrxHelper.uncheckedCast(prx);
}
- class SayHelloI extends Demo.AMI_Hello_sayHello implements Ice.AMISentCallback
+ class SayHelloI extends Demo.Callback_Hello_sayHello
{
private boolean _response = false;
- synchronized public void ice_exception(final Ice.LocalException ex)
+ @Override
+ synchronized public void response()
+ {
+ assert (!_response);
+ _response = true;
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _status.setText("Ready");
+ }
+ });
+ }
+
+ @Override
+ synchronized public void exception(final Ice.LocalException ex)
{
assert (!_response);
_response = true;
@@ -361,7 +376,8 @@ public class HelloApplet extends JApplet
});
}
- synchronized public void ice_sent()
+ @Override
+ synchronized public void sent()
{
if(_response)
{
@@ -383,19 +399,6 @@ public class HelloApplet extends JApplet
}
});
}
-
- synchronized public void ice_response()
- {
- assert (!_response);
- _response = true;
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _status.setText("Ready");
- }
- });
- }
}
private void sayHello()
@@ -411,7 +414,8 @@ public class HelloApplet extends JApplet
{
if(!_deliveryMode.isBatch())
{
- if(hello.sayHello_async(new SayHelloI(), delay))
+ Ice.AsyncResult r = hello.begin_sayHello(delay, new SayHelloI());
+ if(r.sentSynchronously())
{
if(_deliveryMode == DeliveryMode.TWOWAY || _deliveryMode == DeliveryMode.TWOWAY_SECURE)
{
@@ -448,26 +452,28 @@ public class HelloApplet extends JApplet
{
if(!_deliveryMode.isBatch())
{
- hello.shutdown_async(new Demo.AMI_Hello_shutdown()
+ hello.begin_shutdown(new Demo.Callback_Hello_shutdown()
{
- public void ice_exception(final Ice.LocalException ex)
+ @Override
+ public void response()
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
- handleException(ex);
+ _status.setText("Ready");
}
});
}
- public void ice_response()
+ @Override
+ public void exception(final Ice.LocalException ex)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
- _status.setText("Ready");
+ handleException(ex);
}
});
}
diff --git a/java/demo/Ice/async/Client.java b/java/demo/Ice/async/Client.java
index 3d3632edb3d..73727a388a5 100644
--- a/java/demo/Ice/async/Client.java
+++ b/java/demo/Ice/async/Client.java
@@ -27,19 +27,22 @@ public class Client extends Ice.Application
}
}
- public class AMI_Hello_sayHelloI extends AMI_Hello_sayHello
+ public class Callback_Hello_sayHelloI extends Callback_Hello_sayHello
{
- public void ice_response()
+ @Override
+ public void response()
{
}
- public void ice_exception(Ice.LocalException ex)
+ @Override
+ public void exception(Ice.LocalException ex)
{
System.err.println("sayHello AMI call failed:");
ex.printStackTrace();
}
- public void ice_exception(Ice.UserException ex)
+ @Override
+ public void exception(Ice.UserException ex)
{
if(ex instanceof Demo.RequestCanceledException)
{
@@ -109,7 +112,7 @@ public class Client extends Ice.Application
}
else if(line.equals("d"))
{
- hello.sayHello_async(new AMI_Hello_sayHelloI(), 5000);
+ hello.begin_sayHello(5000, new Callback_Hello_sayHelloI());
}
else if(line.equals("s"))
{
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
{
diff --git a/java/demo/Ice/swing/Client.java b/java/demo/Ice/swing/Client.java
index 0333548d285..be30eba5629 100644
--- a/java/demo/Ice/swing/Client.java
+++ b/java/demo/Ice/swing/Client.java
@@ -29,7 +29,7 @@ public class Client extends JFrame
}
catch(Ice.LocalException e)
{
- JOptionPane.showMessageDialog(null, e.toString(), "Initialization failed",
+ JOptionPane.showMessageDialog(null, e.toString(), "Initialization failed",
JOptionPane.ERROR_MESSAGE);
}
}
@@ -392,9 +392,24 @@ public class Client extends JFrame
return Demo.HelloPrxHelper.uncheckedCast(prx);
}
- class SayHelloI extends Demo.AMI_Hello_sayHello implements Ice.AMISentCallback
+ class SayHelloI extends Demo.Callback_Hello_sayHello
{
- synchronized public void ice_exception(final Ice.LocalException ex)
+ @Override
+ synchronized public void response()
+ {
+ assert (!_response);
+ _response = true;
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _status.setText("Ready");
+ }
+ });
+ }
+
+ @Override
+ synchronized public void exception(final Ice.LocalException ex)
{
assert (!_response);
_response = true;
@@ -408,7 +423,8 @@ public class Client extends JFrame
});
}
- synchronized public void ice_sent()
+ @Override
+ synchronized public void sent()
{
if(_response)
{
@@ -431,19 +447,6 @@ public class Client extends JFrame
});
}
- synchronized public void ice_response()
- {
- assert (!_response);
- _response = true;
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _status.setText("Ready");
- }
- });
- }
-
private boolean _response = false;
}
@@ -460,7 +463,8 @@ public class Client extends JFrame
{
if(!_deliveryMode.isBatch())
{
- if(hello.sayHello_async(new SayHelloI(), delay))
+ Ice.AsyncResult r = hello.begin_sayHello(delay, new SayHelloI());
+ if(r.sentSynchronously())
{
if(_deliveryMode == DeliveryMode.TWOWAY || _deliveryMode == DeliveryMode.TWOWAY_SECURE)
{
@@ -497,30 +501,32 @@ public class Client extends JFrame
{
if(!_deliveryMode.isBatch())
{
- hello.shutdown_async(new Demo.AMI_Hello_shutdown()
+ hello.begin_shutdown(new Demo.Callback_Hello_shutdown()
+ {
+ @Override
+ public void response()
{
- public void ice_exception(final Ice.LocalException ex)
+ SwingUtilities.invokeLater(new Runnable()
{
- SwingUtilities.invokeLater(new Runnable()
+ public void run()
{
- public void run()
- {
- handleException(ex);
- }
- });
- }
+ _status.setText("Ready");
+ }
+ });
+ }
- public void ice_response()
+ @Override
+ public void exception(final Ice.LocalException ex)
+ {
+ SwingUtilities.invokeLater(new Runnable()
{
- SwingUtilities.invokeLater(new Runnable()
+ public void run()
{
- public void run()
- {
- _status.setText("Ready");
- }
- });
- }
- });
+ handleException(ex);
+ }
+ });
+ }
+ });
if(_deliveryMode == DeliveryMode.TWOWAY || _deliveryMode == DeliveryMode.TWOWAY_SECURE)
{
_status.setText("Waiting for response");