You may already be familiar with the Ice::Application
class, which encapsulates some basic Ice functionality such as communicator initialization, communicator destruction, and proper handling of signals and exceptions. The Glacier2::Application
extends Ice::Application
to add functionality that is commonly needed by Glacier2 clients:
Glacier2 Application is defined as follows :
|
The intent of this class is that you specialize Glacier2 Application
and implement the pure virtual functions or abstract methods createSession
and runWithSession
in your derived class.
This Application class provides the following functions or methods:
createSession
createSession
is followed by a call to runWithSession
. The application terminates if createSession
throws an Ice LocalException
.runWithSession
This pure virtual function or abstract method must be overridden by a subclass and represents the "main loop" of the application. It is called after the communicator has been initialized and the Glacier2 session has been established. The arguments passed to runWithSession
contain the arguments passed to main
on Application
with all Ice-related options removed. The implementation of runWithSession
must return zero to indicate success and non-zero to indicate failure; the value returned by runWithSession
becomes the return value of main
. runWithSession
can call restart
to restart the session. This destroys the current session, creates a new session (by calling createSession
), and calls runWithSession
again. The Application
base class also restarts the session if runWithSession
throws any of the following Ice exceptions:
|
All other exceptions cause the current session to be destroyed without restarting.
sessionDestroyed
router
session
Application
to destroy the current session, create a new session (by calling createSession
), and start a new main loop (in runWithSession
). This function or method does not return but rather throws a RestartSessionException
, later caught by Application
.categoryForClient
SessionNotExistException
if no session is currently active.createCallbackIdentity
addWithUUID
objectAdapter
Just like Ice The thread you use to call |