Ice 3.7 C++11 API Reference
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Glacier2::Application Class Referenceabstract

An extension of Ice::Application that makes it easy to write Glacier2 applications. More...

#include <Glacier2/Glacier2.h>

Inheritance diagram for Glacier2::Application:
Inheritance graph
[legend]
Collaboration diagram for Glacier2::Application:
Collaboration graph
[legend]

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...
 
Applicationoperator= (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Application() [1/2]

Glacier2::Application::Application ( Ice::SignalPolicy  = Ice::SignalPolicy ::HandleSignals)

Initializes an instance that calls Ice::Communicator::shutdown if a signal is received.

◆ Application() [2/2]

Glacier2::Application::Application ( const Application )
delete

Member Function Documentation

◆ addWithUUID()

static Ice::ObjectPrxPtr Glacier2::Application::addWithUUID ( const Ice::ObjectPtr &  servant)
static

Adds a servant to the callback object adapter's Active Servant Map with a UUID.

Parameters
servantThe servant to add.
Returns
The proxy for the servant.

◆ categoryForClient()

static std::string Glacier2::Application::categoryForClient ( )
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.

Returns
The category.
Exceptions
SessionNotExistExceptionNo session exists.

◆ createCallbackIdentity()

static Ice::Identity Glacier2::Application::createCallbackIdentity ( const std::string &  )
static

Create a new Ice identity for callback objects with the given identity name field.

Returns
The identity.

◆ createSession()

virtual Glacier2::SessionPrxPtr Glacier2::Application::createSession ( )
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.

Returns
The Glacier2 session.

◆ doMain()

virtual int Glacier2::Application::doMain ( int  argc,
char *  argv[],
const Ice::InitializationData initData,
int  version 
)
protectedvirtual

Helper function that implements the application logic.

Reimplemented from Ice::Application.

◆ objectAdapter()

static Ice::ObjectAdapterPtr Glacier2::Application::objectAdapter ( )
static

Creates an object adapter for callback objects.

Returns
The object adapter.

◆ operator=()

Application& Glacier2::Application::operator= ( const Application )
delete

◆ restart()

static void Glacier2::Application::restart ( )
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.

Exceptions
RestartSessionExceptionThis exception is always thrown.

◆ router()

static Glacier2::RouterPrxPtr Glacier2::Application::router ( )
static

Returns the Glacier2 router proxy.

Returns
The router proxy.

◆ runWithSession()

virtual int Glacier2::Application::runWithSession ( int  argc,
char *  argv[] 
)
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.

Parameters
argcThe number of elements in argv.
argvThe 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.
Returns
The runWithSession method should return zero for successful termination, and non-zero otherwise. Application.main returns the value returned by runWithSession.

◆ session()

static Glacier2::SessionPrxPtr Glacier2::Application::session ( )
static

Returns the Glacier2 session proxy.

Returns
The session proxy.

◆ sessionDestroyed()

virtual void Glacier2::Application::sessionDestroyed ( )
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).


The documentation for this class was generated from the following file: