Kanzi Connect  1.1.10
Kanzi Connect C++ API
kanzi::connect::ServiceManager Class Reference

A class that manages all services in Kanzi Connect Server. More...

#include <service_manager.hpp>

Inheritance diagram for kanzi::connect::ServiceManager:
kanzi::connect::InterfaceDomainBase kanzi::connect::IncomingMessageInterface kanzi::connect::ConnectionManager::Observer kanzi::connect::LocalServiceDiscoveryInterface kanzi::connect::VirtualFileProvider

Classes

class  ServiceInfo
 Info and details for a running service. More...
 

Public Types

typedef function< void(vector< ServiceManager::ServiceInfo >)> InformationChangedCallbackFunction
 Function prototype to be invoked when information changes. More...
 
typedef shared_ptr< void > InformationChangedSubscriptionToken
 Handle given as return value to state callback registration. More...
 
- Public Types inherited from kanzi::connect::IncomingMessageInterface
enum  Status {
  Ok = 0, ErrorGeneric, ErrorInvalidMessage, ErrorUnknownDestination,
  ErrorNotRunning
}
 
typedef enum kanzi::connect::IncomingMessageInterface::Status Status
 

Public Member Functions

InformationChangedSubscriptionToken addInformationChangeSubscription (InformationChangedCallbackFunction callback)
 Adds observer to listen service information change messages. More...
 
void createDefinedServices ()
 Creates and registers an instance of each service (Connect.Service. More...
 
ServiceHostSharedPtr getRemoteServiceHost (AbstractSessionSharedPtr session)
 Tries to resolve a remote service host that is somehow bound to a given abstract session. More...
 
ServiceRuntimeDataRegistrySharedPtr getRuntimeDataRegistry ()
 Retrieve shared runtime data registry. More...
 
vector< ContentProviderSharedPtrgetServiceContentProviders (const string &service)
 Retrieve the content providers bound to a specific service. More...
 
ServiceHostSharedPtr getServiceHost (const string &id)
 Retrieves the service host associated with the provided interface identifier. More...
 
bool isCoreService (const string &name) const
 Determines whether specific service is a core service. More...
 
vector< ServiceInfolistServices ()
 retrieves list of services with information attached. More...
 
virtual AbstractServiceSharedPtr lookupLocalService (const string name) KZ_OVERRIDE
 Performs a lookup for local service that is registered with specific name. More...
 
void notifyInformationObservers ()
 Calls all registered information observers in a delayed manner through the mainloop. More...
 
bool registerService (AbstractServiceSharedPtr service)
 Registers service object to system. More...
 
void removeInformationChangeSubscription (InformationChangedSubscriptionToken token)
 Removes observer. More...
 
 ServiceManager (ConnectDomain *domain, DiagnosticsManagerSharedPtr diagnostics)
 Constructor. More...
 
void setPolicyMessageFilter (messagefilter::ServiceMessageFilterHandler handler)
 Configures a filter handler for incoming messages. More...
 
bool start (ConnectDomain *domain, ContentClientSharedPtr contentClient, WorkQueueInterface *workQueue)
 Starts and initializes all services. More...
 
bool stop ()
 Stops and uninitializes all services. More...
 
bool unregisterService (AbstractServiceSharedPtr service)
 Unregisters service object from server. More...
 
 ~ServiceManager ()
 Destructor. More...
 
- Public Member Functions inherited from kanzi::connect::InterfaceDomainBase
const string & getResourceDirectory () const
 Retrieves the content & resource directory of the system. More...
 
UriTranslatorgetUriTranslator ()
 Returns translator for Uris. More...
 
void setResourceDirectory (const string &path)
 Sets resource directory of the system. More...
 
virtual ~InterfaceDomainBase ()=default
 Destructor. More...
 
- Public Member Functions inherited from kanzi::connect::LocalServiceDiscoveryInterface
virtual ~LocalServiceDiscoveryInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from kanzi::connect::VirtualFileProvider
virtual void cancelAllPendingRequests ()
 
virtual ~VirtualFileProvider ()
 Virtual destructor for cleanup. More...
 

Protected Member Functions

bool acquireSession (ConnectedClientSharedPtr client, const string &interfaceId, int sessionId)
 Acquires a new session for a client for a particular service. More...
 
void automaticStartLocalServices ()
 Automatically starts all non-demand configured services. More...
 
bool canStartService (AbstractServiceSharedPtr service)
 Checks whether it is allowed to start specific service. More...
 
bool canStopService (AbstractServiceSharedPtr service)
 Checks whether it is allowed to stop specific service. More...
 
void configureService (AbstractServiceSharedPtr service)
 Configures service attributes. More...
 
void notifyInformationObserversImpl ()
 Calls all registered information observers. More...
 
virtual AbstractSessionSharedPtr onAcquireSession (int clientId, int sessionId, MessageDispatcher *dispatcher, const string &instanceName) KZ_OVERRIDE
 See AbstractService::onAcquireSession. More...
 
virtual void onReleaseSession (AbstractSessionSharedPtr session) KZ_OVERRIDE
 See AbstractService::onReleaseSession. More...
 
bool registerCoreService (AbstractServiceSharedPtr service)
 Registers a core service. More...
 
void registerServiceRuntimeDatas ()
 Register runtime data from all the services within the system. More...
 
bool releaseSession (int clientId, const string &interfaceId, int sessionId)
 Releases ongoing session. More...
 

Friends

class Server
 

Detailed Description

A class that manages all services in Kanzi Connect Server.

This class allows both local and remote services to register in to system and manages the lifetime, operation and connectivity of all registered services.

Member Typedef Documentation

◆ InformationChangedCallbackFunction

Function prototype to be invoked when information changes.

◆ InformationChangedSubscriptionToken

Handle given as return value to state callback registration.

Constructor & Destructor Documentation

◆ ServiceManager()

kanzi::connect::ServiceManager::ServiceManager ( ConnectDomain domain,
DiagnosticsManagerSharedPtr  diagnostics 
)

Constructor.

◆ ~ServiceManager()

kanzi::connect::ServiceManager::~ServiceManager ( )

Destructor.

Member Function Documentation

◆ acquireSession()

bool kanzi::connect::ServiceManager::acquireSession ( ConnectedClientSharedPtr  client,
const string &  interfaceId,
int  sessionId 
)
protected

Acquires a new session for a client for a particular service.

Parameters
clientthe client.
interfaceIdId of the interface.
sessionIdId of the session.
Returns
true if session successfully acquired. false on error

◆ addInformationChangeSubscription()

InformationChangedSubscriptionToken kanzi::connect::ServiceManager::addInformationChangeSubscription ( InformationChangedCallbackFunction  callback)

Adds observer to listen service information change messages.

Parameters
callbackfunction to call on change. Execution contenxt might vary.
Returns
token that can later on be used to remove subscription.

◆ automaticStartLocalServices()

void kanzi::connect::ServiceManager::automaticStartLocalServices ( )
protected

Automatically starts all non-demand configured services.

◆ canStartService()

bool kanzi::connect::ServiceManager::canStartService ( AbstractServiceSharedPtr  service)
protected

Checks whether it is allowed to start specific service.

Decision is based on the dependency information provided with the server configuration.

Parameters
servicethe service to be checked.
Returns
true if it is allowed to start service.

◆ canStopService()

bool kanzi::connect::ServiceManager::canStopService ( AbstractServiceSharedPtr  service)
protected

Checks whether it is allowed to stop specific service.

Decision is based on the dependency information provided with the server configuration.

Parameters
servicethe service to be checked.
Returns
true if it is allowed to stop service.

◆ configureService()

void kanzi::connect::ServiceManager::configureService ( AbstractServiceSharedPtr  service)
protected

Configures service attributes.

Parameters
servicepointer to service instance.

◆ createDefinedServices()

void kanzi::connect::ServiceManager::createDefinedServices ( )

Creates and registers an instance of each service (Connect.Service.

*) that is found from the metadata. Note: This functionality is likely to change in future.

◆ getRemoteServiceHost()

ServiceHostSharedPtr kanzi::connect::ServiceManager::getRemoteServiceHost ( AbstractSessionSharedPtr  session)

Tries to resolve a remote service host that is somehow bound to a given abstract session.

Parameters
sessionthe abstract session to resolve.
Returns
service host pointer that could be a null.

◆ getRuntimeDataRegistry()

ServiceRuntimeDataRegistrySharedPtr kanzi::connect::ServiceManager::getRuntimeDataRegistry ( )

Retrieve shared runtime data registry.

Returns
runtime data registry.

◆ getServiceContentProviders()

vector<ContentProviderSharedPtr> kanzi::connect::ServiceManager::getServiceContentProviders ( const string &  service)

Retrieve the content providers bound to a specific service.

Parameters
servicethe name of the service
Returns
vector of content providers bound to this particular service.

◆ getServiceHost()

ServiceHostSharedPtr kanzi::connect::ServiceManager::getServiceHost ( const string &  id)

Retrieves the service host associated with the provided interface identifier.

Parameters
ididentifies the interface
Returns
pointer to service host.

◆ isCoreService()

bool kanzi::connect::ServiceManager::isCoreService ( const string &  name) const

Determines whether specific service is a core service.

Parameters
namename of the service.
Returns
true if service is a core service.

◆ listServices()

vector<ServiceInfo> kanzi::connect::ServiceManager::listServices ( )

retrieves list of services with information attached.

Returns
list of service decriptors.

◆ lookupLocalService()

virtual AbstractServiceSharedPtr kanzi::connect::ServiceManager::lookupLocalService ( const string  name)
virtual

Performs a lookup for local service that is registered with specific name.

Parameters
namethe name of the service, usually something like Connect.Service.MyProService or just MyProService
Returns
pointer to service or null.

Implements kanzi::connect::LocalServiceDiscoveryInterface.

◆ notifyInformationObservers()

void kanzi::connect::ServiceManager::notifyInformationObservers ( )

Calls all registered information observers in a delayed manner through the mainloop.

◆ notifyInformationObserversImpl()

void kanzi::connect::ServiceManager::notifyInformationObserversImpl ( )
protected

Calls all registered information observers.

◆ onAcquireSession()

virtual AbstractSessionSharedPtr kanzi::connect::ServiceManager::onAcquireSession ( int  clientId,
int  sessionId,
MessageDispatcher dispatcher,
const string &  instanceName 
)
protectedvirtual

◆ onReleaseSession()

virtual void kanzi::connect::ServiceManager::onReleaseSession ( AbstractSessionSharedPtr  session)
protectedvirtual

◆ registerCoreService()

bool kanzi::connect::ServiceManager::registerCoreService ( AbstractServiceSharedPtr  service)
protected

Registers a core service.

Parameters
servicepointer to service instsance
Returns
true if succeeded, false otherwise.

◆ registerService()

bool kanzi::connect::ServiceManager::registerService ( AbstractServiceSharedPtr  service)

Registers service object to system.

Parameters
serviceService to register.
Returns
true if ok, false if registration failed, most likely due the fact service with same name already existed.

◆ registerServiceRuntimeDatas()

void kanzi::connect::ServiceManager::registerServiceRuntimeDatas ( )
protected

Register runtime data from all the services within the system.

◆ releaseSession()

bool kanzi::connect::ServiceManager::releaseSession ( int  clientId,
const string &  interfaceId,
int  sessionId 
)
protected

Releases ongoing session.

Parameters
clientIdId of the client.
interfaceIdId of the interface.
sessionIdId of the session.
Returns
true if session got released, false otherwise.

◆ removeInformationChangeSubscription()

void kanzi::connect::ServiceManager::removeInformationChangeSubscription ( InformationChangedSubscriptionToken  token)

Removes observer.

Parameters
tokenpreviously returned subscription token

◆ setPolicyMessageFilter()

void kanzi::connect::ServiceManager::setPolicyMessageFilter ( messagefilter::ServiceMessageFilterHandler  handler)

Configures a filter handler for incoming messages.

Parameters
handlerthe handler to set for incoming messages.

◆ start()

bool kanzi::connect::ServiceManager::start ( ConnectDomain domain,
ContentClientSharedPtr  contentClient,
WorkQueueInterface workQueue 
)

Starts and initializes all services.

Parameters
domaincontains setup data
contentClientinterface to content service
workQueueglobal work queue pointer
Returns
true if successfully started. false if unable to start services.

◆ stop()

bool kanzi::connect::ServiceManager::stop ( )

Stops and uninitializes all services.

Returns
true if succeeded. false on error.

◆ unregisterService()

bool kanzi::connect::ServiceManager::unregisterService ( AbstractServiceSharedPtr  service)

Unregisters service object from server.

Parameters
serviceService to unregister.
Returns
true if service got removed. false if service not found or passed arguments were invalid.

Friends And Related Function Documentation

◆ Server

friend class Server
friend

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