Skip to content

Instanciation Control

rfernandes edited this page Mar 9, 2013 · 1 revision

The instanciation control mecanism defines the strategy used over the instance of the object that performs the operation execution. The same programming model is used with either */RPC-SOAP and REST webservices.

SingleCall (Default)

For each request a new instance os the class that provides it is created.

Singleton

A single instance is used to answer multiple requests. This instance is construct as soon as the application server is up.

LazySingleton

Similar to singleton, but the instance is created only upon the first call of a operation it provides.

Choosing the instanciation strategy

To define the instantiation strategy define the InstantiationStrategyType typedef within the target class to one of the types in answer::instanciation. As an example we could define the calculator example as a singleton by declarating:

class MyService{
public:
	CalculatorResponse calculator(const CalculatorRequest &request);

	typedef answer::instanciation::LazySingleton InstantiationStrategyType;
};

Clone this wiki locally