Ice 3.7 C++11 API Reference
|
An extension of Ice::Application that makes it easy to write Glacier2 applications. More...
#include <Glacier2/Glacier2.h>
Public Member Functions | |
Application (const Application &)=delete | |
Application (Ice::SignalPolicy=Ice::SignalPolicy ::HandleSignals) | |
Initializes an instance that calls Ice::Communicator::shutdown if a signal is received. More... | |
virtual Glacier2::SessionPrxPtr | createSession ()=0 |
Creates a new Glacier2 session. More... | |
Application & | operator= (const Application &)=delete |
virtual int | runWithSession (int argc, char *argv[])=0 |
Called once the communicator has been initialized and the Glacier2 session has been established. More... | |
virtual void | sessionDestroyed () |
Called when the session refresh thread detects that the session has been destroyed. More... | |
Public Member Functions inherited from Ice::Application | |
Application (SignalPolicy policy=SignalPolicy ::HandleSignals) | |
The constructor configures the signal handling behavior. More... | |
virtual void | interruptCallback (int signal) |
Override this method to provide a custom application interrupt hook. More... | |
int | main (const StringSeq &args, const InitializationData &initData=InitializationData(), int version=30710) |
Call this main() from the global main(). More... | |
int | main (const StringSeq &args, const std::string &configFile, int version=30710) |
Call this main() from the global main(). More... | |
int | main (int argc, const char *const argv[], const InitializationData &initData=InitializationData(), int version=30710) |
Call this main() from the global main(). More... | |
int | main (int argc, const char *const argv[], const std::string &configFile, int version=30710) |
Call this main() from the global main(). More... | |
virtual | ~Application () |
Static Public Member Functions | |
static Ice::ObjectPrxPtr | addWithUUID (const Ice::ObjectPtr &servant) |
Adds a servant to the callback object adapter's Active Servant Map with a UUID. More... | |
static std::string | categoryForClient () |
Returns the category to be used in the identities of all of the client's callback objects. More... | |
static Ice::Identity | createCallbackIdentity (const std::string &) |
Create a new Ice identity for callback objects with the given identity name field. More... | |
static Ice::ObjectAdapterPtr | objectAdapter () |
Creates an object adapter for callback objects. More... | |
static void | restart () |
Called to restart the application's Glacier2 session. More... | |
static Glacier2::RouterPrxPtr | router () |
Returns the Glacier2 router proxy. More... | |
static Glacier2::SessionPrxPtr | session () |
Returns the Glacier2 session proxy. More... | |
Static Public Member Functions inherited from Ice::Application | |
static const char * | appName () |
Obtains the application name, i.e., argv[0]. More... | |
static void | callbackOnInterrupt () |
Configures the application to invoke interruptCallback when a signal occurs, thereby giving the subclass responsibility for handling the signal. More... | |
static CommunicatorPtr | communicator () |
Obtains the application's Communicator instance. More... | |
static void | destroyOnInterrupt () |
Configures the application to destroy the communicator when one of the monitored signals is raised. More... | |
static void | holdInterrupt () |
Configures the application to ignore (but remember) a signal. More... | |
static void | ignoreInterrupt () |
Configures the application to ignore signals. More... | |
static bool | interrupted () |
Indicates whether a signal handler was triggered. More... | |
static void | releaseInterrupt () |
Processes a stored signal (if any) using the current signal handling configuration. More... | |
static void | shutdownOnInterrupt () |
Configures the application to shut down the communicator when one of the monitored signals is raised. More... | |
Protected Member Functions | |
virtual int | doMain (int argc, char *argv[], const Ice::InitializationData &initData, int version) |
Helper function that implements the application logic. More... | |
Additional Inherited Members | |
Static Protected Attributes inherited from Ice::Application | |
static Application * | _application |
The singleton instance. More... | |
static std::string | _appName |
The application's name. More... | |
static bool | _callbackInProgress |
True if a signal handling callback is currently executing. More... | |
static CommunicatorPtr | _communicator |
The application's communicator. More... | |
static IceUtil::Cond | _condVar |
Used to synchronize the main thread and the CtrlCHandler thread. More... | |
static bool | _destroyed |
True if the communicator has been destroyed. More... | |
static bool | _interrupted |
True if an interrupt signal was received. More... | |
static IceUtil::Mutex | _mutex |
Used to synchronize the main thread and the CtrlCHandler thread. More... | |
static SignalPolicy | _signalPolicy |
The signal-handling policy specified at construction. More... | |
An extension of Ice::Application that makes it easy to write Glacier2 applications.
Applications must create a derived class that implements the createSession and runWithSession methods.
The base class invokes createSession to create a new Glacier2 session and then invokes runWithSession in which the subclass performs its application logic. The base class automatically destroys the session when runWithSession returns.
If runWithSession 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.
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.
Glacier2::Application::Application | ( | Ice::SignalPolicy | = Ice::SignalPolicy ::HandleSignals | ) |
Initializes an instance that calls Ice::Communicator::shutdown if a signal is received.
|
delete |
|
static |
Adds a servant to the callback object adapter's Active Servant Map with a UUID.
servant | The servant to add. |
|
static |
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.
SessionNotExistException | No session exists. |
|
static |
Create a new Ice identity for callback objects with the given identity name field.
|
pure virtual |
Creates a new Glacier2 session.
A call to createSession
always precedes a call to runWithSession
. If Ice::LocalException
is thrown from this method, the application is terminated.
|
protectedvirtual |
Helper function that implements the application logic.
Reimplemented from Ice::Application.
|
static |
Creates an object adapter for callback objects.
|
delete |
|
static |
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.
RestartSessionException | This exception is always thrown. |
|
static |
Returns the Glacier2 router proxy.
|
pure virtual |
Called once the communicator has been initialized and the Glacier2 session has been established.
A derived class must implement runWithSession
, which is the application's starting method.
argc | The number of elements in argv. |
argv | 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
.
|
static |
Returns the Glacier2 session proxy.
|
virtual |
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).