A class that manages all services in Kanzi Connect Server. More...
#include <service_manager.hpp>
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. | |
typedef shared_ptr< void > | InformationChangedSubscriptionToken |
Handle given as return value to state callback registration. | |
![]() | |
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. | |
void | createDefinedServices () |
Creates and registers an instance of each service (Connect.Service. | |
ServiceHostSharedPtr | getRemoteServiceHost (AbstractSessionSharedPtr session) |
Tries to resolve a remote service host that is somehow bound to a given abstract session. | |
ServiceRuntimeDataRegistrySharedPtr | getRuntimeDataRegistry () |
Retrieve shared runtime data registry. | |
vector< ContentProviderSharedPtr > | getServiceContentProviders (const string &service) |
Retrieve the content providers bound to a specific service. | |
ServiceHostSharedPtr | getServiceHost (const string &id) |
Retrieves the service host associated with the provided interface identifier. | |
bool | isCoreService (const string &name) const |
Determines whether specific service is a core service. | |
vector< ServiceInfo > | listServices () |
retrieves list of services with information attached. | |
virtual AbstractServiceSharedPtr | lookupLocalService (const string name) override |
Performs a lookup for local service that is registered with specific name. | |
void | notifyInformationObservers () |
Calls all registered information observers in a delayed manner through the mainloop. | |
void | queueServiceForStartup (string serviceName) |
Store service name in vector queue for startup. | |
bool | registerService (AbstractServiceSharedPtr service) |
Registers service object to system. | |
void | removeInformationChangeSubscription (InformationChangedSubscriptionToken token) |
Removes observer. | |
ServiceManager (ConnectDomainSharedPtr domain, DiagnosticsManagerSharedPtr diagnostics) | |
Constructor. | |
void | setHttpServer (shared_ptr< CivetServer > httpServer) |
Set HTTP server to handle HTTP requests. | |
void | setPolicyMessageFilter (messagefilter::ServiceMessageFilterHandler handler) |
Configures a filter handler for incoming messages. | |
bool | start (ConnectDomainSharedPtr domain, ContentClientSharedPtr contentClient, WorkQueueInterface *workQueue) |
Starts and initializes all services. | |
bool | stop () |
Stops and uninitializes all services. | |
bool | unregisterService (AbstractServiceSharedPtr service) |
Unregisters service object from server. | |
~ServiceManager () | |
Destructor. | |
![]() | |
const string & | getResourceDirectory () const |
Retrieves the content & resource directory of the system. | |
UriTranslator & | getUriTranslator () |
Returns translator for Uris. | |
void | setResourceDirectory (const string &path) |
Sets resource directory of the system. | |
virtual | ~InterfaceDomainBase ()=default |
Destructor. | |
![]() | |
virtual | ~LocalServiceDiscoveryInterface () |
Virtual destructor. | |
![]() | |
virtual void | cancelAllPendingRequests () |
virtual | ~VirtualFileProvider () |
Virtual destructor for cleanup. | |
Protected Member Functions | |
bool | acquireSession (ConnectedClientSharedPtr client, const string &interfaceId, int sessionId) |
Acquires a new session for a client for a particular service. | |
void | automaticStartLocalServices () |
Automatically starts all non-demand configured services. | |
bool | canStartService (AbstractServiceSharedPtr service) |
Checks whether it is allowed to start specific service. | |
bool | canStopService (AbstractServiceSharedPtr service) |
Checks whether it is allowed to stop specific service. | |
void | configureService (AbstractServiceSharedPtr service) |
Configures service attributes. | |
void | notifyInformationObserversImpl () |
Calls all registered information observers. | |
virtual AbstractSessionSharedPtr | onAcquireSession (int clientId, int sessionId, MessageDispatcher *dispatcher, const string &instanceName) override |
See AbstractService::onAcquireSession. | |
virtual void | onReleaseSession (AbstractSessionSharedPtr session) override |
See AbstractService::onReleaseSession. | |
bool | registerCoreService (AbstractServiceSharedPtr service) |
Registers a core service. | |
void | registerServiceRuntimeDatas () |
Register runtime data from all the services within the system. | |
bool | releaseSession (int clientId, const string &interfaceId, int sessionId) |
Releases ongoing session. | |
Friends | |
class | Server |
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.
typedef function<void(vector<ServiceManager::ServiceInfo>)> kanzi::connect::ServiceManager::InformationChangedCallbackFunction |
Function prototype to be invoked when information changes.
typedef shared_ptr<void> kanzi::connect::ServiceManager::InformationChangedSubscriptionToken |
Handle given as return value to state callback registration.
kanzi::connect::ServiceManager::ServiceManager | ( | ConnectDomainSharedPtr | domain, |
DiagnosticsManagerSharedPtr | diagnostics ) |
Constructor.
kanzi::connect::ServiceManager::~ServiceManager | ( | ) |
Destructor.
|
protected |
Acquires a new session for a client for a particular service.
client | the client. |
interfaceId | Id of the interface. |
sessionId | Id of the session. |
InformationChangedSubscriptionToken kanzi::connect::ServiceManager::addInformationChangeSubscription | ( | InformationChangedCallbackFunction | callback | ) |
Adds observer to listen service information change messages.
callback | function to call on change. Execution contenxt might vary. |
|
protected |
Automatically starts all non-demand configured services.
|
protected |
Checks whether it is allowed to start specific service.
Decision is based on the dependency information provided with the server configuration.
service | the service to be checked. |
|
protected |
Checks whether it is allowed to stop specific service.
Decision is based on the dependency information provided with the server configuration.
service | the service to be checked. |
|
protected |
Configures service attributes.
service | pointer to service instance. |
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.
ServiceHostSharedPtr kanzi::connect::ServiceManager::getRemoteServiceHost | ( | AbstractSessionSharedPtr | session | ) |
Tries to resolve a remote service host that is somehow bound to a given abstract session.
session | the abstract session to resolve. |
ServiceRuntimeDataRegistrySharedPtr kanzi::connect::ServiceManager::getRuntimeDataRegistry | ( | ) |
Retrieve shared runtime data registry.
vector< ContentProviderSharedPtr > kanzi::connect::ServiceManager::getServiceContentProviders | ( | const string & | service | ) |
Retrieve the content providers bound to a specific service.
service | the name of the service |
ServiceHostSharedPtr kanzi::connect::ServiceManager::getServiceHost | ( | const string & | id | ) |
Retrieves the service host associated with the provided interface identifier.
id | identifies the interface |
bool kanzi::connect::ServiceManager::isCoreService | ( | const string & | name | ) | const |
Determines whether specific service is a core service.
name | name of the service. |
vector< ServiceInfo > kanzi::connect::ServiceManager::listServices | ( | ) |
retrieves list of services with information attached.
|
overridevirtual |
Performs a lookup for local service that is registered with specific name.
name | the name of the service, usually something like Connect.Service.MyProService or just MyProService |
Implements kanzi::connect::LocalServiceDiscoveryInterface.
void kanzi::connect::ServiceManager::notifyInformationObservers | ( | ) |
Calls all registered information observers in a delayed manner through the mainloop.
|
protected |
Calls all registered information observers.
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
void kanzi::connect::ServiceManager::queueServiceForStartup | ( | string | serviceName | ) |
Store service name in vector queue for startup.
serviceName | to be stored |
|
protected |
Registers a core service.
service | pointer to service instsance |
bool kanzi::connect::ServiceManager::registerService | ( | AbstractServiceSharedPtr | service | ) |
Registers service object to system.
service | Service to register. |
|
protected |
Register runtime data from all the services within the system.
|
protected |
Releases ongoing session.
clientId | Id of the client. |
interfaceId | Id of the interface. |
sessionId | Id of the session. |
void kanzi::connect::ServiceManager::removeInformationChangeSubscription | ( | InformationChangedSubscriptionToken | token | ) |
Removes observer.
token | previously returned subscription token |
void kanzi::connect::ServiceManager::setHttpServer | ( | shared_ptr< CivetServer > | httpServer | ) |
Set HTTP server to handle HTTP requests.
httpServer | HTTP server to handle HTTP requests. |
void kanzi::connect::ServiceManager::setPolicyMessageFilter | ( | messagefilter::ServiceMessageFilterHandler | handler | ) |
Configures a filter handler for incoming messages.
handler | the handler to set for incoming messages. |
bool kanzi::connect::ServiceManager::start | ( | ConnectDomainSharedPtr | domain, |
ContentClientSharedPtr | contentClient, | ||
WorkQueueInterface * | workQueue ) |
Starts and initializes all services.
domain | contains setup data |
contentClient | interface to content service |
workQueue | global work queue pointer |
bool kanzi::connect::ServiceManager::stop | ( | ) |
Stops and uninitializes all services.
bool kanzi::connect::ServiceManager::unregisterService | ( | AbstractServiceSharedPtr | service | ) |
Unregisters service object from server.
service | Service to unregister. |
|
friend |