public abstract class Application extends Ice.Application
Applications must create a derived class that implements the
createSession() and runWithSession(java.lang.String[]) methods.
The base class invokes createSession() to create a new
Glacier2 session and then invokes runWithSession(java.lang.String[]) in
which the subclass performs its application logic. The base class
automatically destroys the session when runWithSession(java.lang.String[])
returns.
If runWithSession(java.lang.String[]) calls restart() or raises any of
the exceptions Ice.ConnectionRefusedException,
Ice.ConnectionLostException, Ice.UnknownLocalException,
Ice.RequestFailedException, or Ice.TimeoutException, the base
class destroys the current session and restarts the application
with another call to createSession() followed by
runWithSession(java.lang.String[]).
The application can optionally override the sessionDestroyed()
callback method if it needs to take action when connectivity with
the Glacier2 router is lost.
A program can contain only one instance of this class.
Application,
Router,
Session,
Communicator,
Logger,
runWithSession(java.lang.String[])| Modifier and Type | Class and Description |
|---|---|
class |
Application.RestartSessionException
This exception is raised if the session should be restarted.
|
Ice.Application.AppHook_appHook, _appName, _callbackInProgress, _communicator, _destroyed, _interrupted, _mutex, _signalPolicy| Constructor and Description |
|---|
Application()
Initializes an instance that calls
Communicator.shutdown() if
a signal is received. |
Application(Ice.SignalPolicy signalPolicy)
Initializes an instance that handles signals according to the signal
policy.
|
| Modifier and Type | Method and Description |
|---|---|
Ice.ObjectPrx |
addWithUUID(Ice.Object servant)
Adds a servant to the callback object adapter's Active Servant Map with a UUID.
|
java.lang.String |
categoryForClient()
Returns the category to be used in the identities of all of the client's
callback objects.
|
Ice.Identity |
createCallbackIdentity(java.lang.String name)
Create a new Ice identity for callback objects with the given
identity name field.
|
abstract SessionPrx |
createSession()
Creates a new Glacier2 session.
|
protected int |
doMain(Ice.StringSeqHolder argHolder,
Ice.InitializationData initData) |
Ice.ObjectAdapter |
objectAdapter()
Creates an object adapter for callback objects.
|
void |
restart()
Called to restart the application's Glacier2 session.
|
static RouterPrx |
router()
Returns the Glacier2 router proxy
|
int |
run(java.lang.String[] args)
Run should not be overridden for Glacier2.Application.
|
abstract int |
runWithSession(java.lang.String[] args)
Called once the communicator has been initialized and the Glacier2 session
has been established.
|
static SessionPrx |
session()
Returns the Glacier2 session proxy
|
void |
sessionDestroyed()
Called when the session refresh thread detects that the session has been
destroyed.
|
appName, communicator, defaultInterrupt, destroyOnInterrupt, interrupted, main, main, main, setInterruptHook, shutdownOnInterruptpublic Application()
Communicator.shutdown() if
a signal is received.public Application(Ice.SignalPolicy signalPolicy)
signalPolicy - Determines how to respond to signals.SignalPolicypublic abstract int runWithSession(java.lang.String[] args)
throws Application.RestartSessionException
runWithSession,
which is the application's starting method.args - The argument vector for the application. Application
scans the argument vector passed to main for options that are
specific to the Ice run time and removes them; therefore, the vector passed
to run is free from Ice-related options and contains only options
and arguments that are application-specific.runWithSession method should return zero for successful
termination, and non-zero otherwise. Application.main returns the
value returned by runWithSession.Application.RestartSessionException - If the session should be restarted.public final int run(java.lang.String[] args)
runWithSession should be used.run in class Ice.Applicationpublic void restart()
throws Application.RestartSessionException
Application.RestartSessionException - This exception is always thrown.public abstract SessionPrx createSession()
createSession always precedes a call to
runWithSession. If Ice.LocalException
is thrown from this method, the application is terminated.public void sessionDestroyed()
public static RouterPrx router()
public static SessionPrx session()
public java.lang.String categoryForClient()
throws SessionNotExistException
SessionNotExistException - No session exists.public Ice.Identity createCallbackIdentity(java.lang.String name) throws SessionNotExistException
name - The identity name.SessionNotExistException - No session exists.public Ice.ObjectPrx addWithUUID(Ice.Object servant) throws SessionNotExistException
servant - The servant to add.SessionNotExistException - No session exists.public Ice.ObjectAdapter objectAdapter() throws SessionNotExistException
SessionNotExistException - No session exists.protected int doMain(Ice.StringSeqHolder argHolder, Ice.InitializationData initData)
doMain in class Ice.Application