Class 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 com.zeroc.Ice.ConnectionRefusedException,
com.zeroc.Ice.ConnectionLostException, com.zeroc.Ice.UnknownLocalException,
com.zeroc.Ice.RequestFailedException, or com.zeroc.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.
- See Also:
-
ApplicationRouterSessionCommunicatorLoggerrunWithSession(java.lang.String[])
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis exception is raised if the session should be restarted.Nested classes/interfaces inherited from class com.zeroc.Ice.Application
com.zeroc.Ice.Application.AppHook -
Field Summary
Fields inherited from class com.zeroc.Ice.Application
_appHook, _appName, _callbackInProgress, _communicator, _destroyed, _interrupted, _mutex, _signalPolicy -
Constructor Summary
ConstructorsConstructorDescriptionInitializes an instance that callsCommunicator.shutdown()if a signal is received.Application(com.zeroc.Ice.SignalPolicy signalPolicy) Initializes an instance that handles signals according to the signal policy. -
Method Summary
Modifier and TypeMethodDescriptionstatic com.zeroc.Ice.ObjectPrxaddWithUUID(com.zeroc.Ice.Object servant) Adds a servant to the callback object adapter's Active Servant Map with a UUID.static StringReturns the category to be used in the identities of all of the client's callback objects.static com.zeroc.Ice.IdentitycreateCallbackIdentity(String name) Create a new Ice identity for callback objects with the given identity name field.abstract SessionPrxCreates a new Glacier2 session.protected intstatic com.zeroc.Ice.ObjectAdapterCreates an object adapter for callback objects.static voidrestart()Called to restart the application's Glacier2 session.static RouterPrxrouter()Returns the Glacier2 router proxyfinal intRun should not be overridden for com.zeroc.Glacier2.Application.abstract intrunWithSession(String[] args) Called once the communicator has been initialized and the Glacier2 session has been established.static SessionPrxsession()Returns the Glacier2 session proxyvoidCalled when the session refresh thread detects that the session has been destroyed.Methods inherited from class com.zeroc.Ice.Application
appName, communicator, defaultInterrupt, destroyOnInterrupt, interrupted, main, main, main, setInterruptHook, shutdownOnInterrupt
-
Constructor Details
-
Application
public Application()Initializes an instance that callsCommunicator.shutdown()if a signal is received. -
Application
public Application(com.zeroc.Ice.SignalPolicy signalPolicy) Initializes an instance that handles signals according to the signal policy.- Parameters:
signalPolicy- Determines how to respond to signals.- See Also:
-
SignalPolicy
-
-
Method Details
-
createSession
Creates a new Glacier2 session. A call tocreateSessionalways precedes a call torunWithSession. Ifcom.zeroc.Ice.LocalExceptionis thrown from this method, the application is terminated.- Returns:
- The Glacier2 session.
-
runWithSession
Called once the communicator has been initialized and the Glacier2 session has been established. A derived class must implementrunWithSession, which is the application's starting method.- Parameters:
args- The argument vector for the application.Applicationscans the argument vector passed tomainfor options that are specific to the Ice run time and removes them; therefore, the vector passed torunis free from Ice-related options and contains only options and arguments that are application-specific.- Returns:
- The
runWithSessionmethod should return zero for successful termination, and non-zero otherwise.Application.mainreturns the value returned byrunWithSession. - Throws:
Application.RestartSessionException- If the session should be restarted.
-
sessionDestroyed
public void sessionDestroyed()Called when the session refresh thread detects that the session has been destroyed. A subclass can override this method to take action after the loss of connectivity with the Glacier2 router. This method is called according to the Ice invocation dipsatch rules (in other words, it uses the same rules as an servant upcall or AMI callback). -
run
Run should not be overridden for com.zeroc.Glacier2.Application. InsteadrunWithSessionshould be used.- Specified by:
runin classcom.zeroc.Ice.Application
-
restart
Called to restart the application's Glacier2 session. This method never returns. The exception produce an application restart when called from the Application main thread.- Throws:
Application.RestartSessionException- This exception is always thrown.
-
router
Returns the Glacier2 router proxy- Returns:
- The router proxy.
-
session
Returns the Glacier2 session proxy- Returns:
- The session proxy.
-
categoryForClient
Returns the category to be used in the identities of all of the client's callback objects. Clients must use this category for the router to forward callback requests to the intended client.- Returns:
- The category.
- Throws:
SessionNotExistException- No session exists.
-
createCallbackIdentity
public static com.zeroc.Ice.Identity createCallbackIdentity(String name) throws SessionNotExistException Create a new Ice identity for callback objects with the given identity name field.- Parameters:
name- The identity name.- Returns:
- The identity with the given name and a unique category.
- Throws:
SessionNotExistException- No session exists.
-
addWithUUID
public static com.zeroc.Ice.ObjectPrx addWithUUID(com.zeroc.Ice.Object servant) throws SessionNotExistException Adds a servant to the callback object adapter's Active Servant Map with a UUID.- Parameters:
servant- The servant to add.- Returns:
- The proxy for the servant.
- Throws:
SessionNotExistException- No session exists.
-
objectAdapter
Creates an object adapter for callback objects.- Returns:
- The object adapter.
- Throws:
SessionNotExistException- No session exists.
-
doMain
- Overrides:
doMainin classcom.zeroc.Ice.Application
-