ServiceManager¶
-
class
kanzi::connect::ServiceManager: public ServiceServiceConcept, public InterfaceDomainBase, public IncomingMessageInterface, public ConnectionManager::Observer, public LocalServiceDiscoveryInterface, public VirtualFileProvider¶ 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.
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.
Public Functions
Constructor.
-
~ServiceManager()¶ Destructor.
-
InformationChangedSubscriptionToken
addInformationChangeSubscription(InformationChangedCallbackFunction callback)¶ Adds observer to listen service information change messages.
- Parameters
callback – function to call on change. Execution contenxt might vary.
- Returns
token that can later on be used to remove subscription.
-
void
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.
Tries to resolve a remote service host that is somehow bound to a given abstract session.
- Parameters
session – the abstract session to resolve.
- Returns
service host pointer that could be a null.
-
ServiceRuntimeDataRegistrySharedPtr
getRuntimeDataRegistry()¶ Retrieve shared runtime data registry.
- Returns
runtime data registry.
-
vector<ContentProviderSharedPtr>
getServiceContentProviders(const string &service)¶ Retrieve the content providers bound to a specific service.
- Parameters
service – the name of the service
- Returns
vector of content providers bound to this particular service.
-
ServiceHostSharedPtr
getServiceHost(const string &id)¶ Retrieves the service host associated with the provided interface identifier.
- Parameters
id – identifies the interface
- Returns
pointer to service host.
-
bool
isCoreService(const string &name) const¶ Determines whether specific service is a core service.
- Parameters
name – name of the service.
- Returns
true if service is a core service.
-
vector<ServiceInfo>
listServices()¶ retrieves list of services with information attached.
- Returns
list of service decriptors.
-
virtual AbstractServiceSharedPtr lookupLocalService (const string name) KZ_OVERRIDE Performs a lookup for local service that is registered with specific name.
- Parameters
name – the name of the service, usually something like Connect.Service.MyProService or just MyProService
- Returns
pointer to service or null.
-
void
notifyInformationObservers()¶ Calls all registered information observers in a delayed manner through the mainloop.
Registers service object to system.
- Parameters
service – Service to register.
- Returns
true if ok, false if registration failed, most likely due the fact service with same name already existed.
-
void
removeInformationChangeSubscription(InformationChangedSubscriptionToken token)¶ Removes observer.
- Parameters
token – previously returned subscription token
-
void
setPolicyMessageFilter(messagefilter::ServiceMessageFilterHandler handler)¶ Configures a filter handler for incoming messages.
- Parameters
handler – the handler to set for incoming messages.
Starts and initializes all services.
- Parameters
domain – contains setup data
contentClient – interface to content service
workQueue – global work queue pointer
- Returns
true if successfully started. false if unable to start services.
-
bool
stop()¶ Stops and uninitializes all services.
- Returns
true if succeeded. false on error.
Unregisters service object from server.
- Parameters
service – Service to unregister.
- Returns
true if service got removed. false if service not found or passed arguments were invalid.
-
class
ServiceInfo¶ Info and details for a running service.
Public Types
Public Members
-
string
m_address¶ Address of the service. Empty for locally running service(s).
-
AbstractService::ServiceDescription
m_description¶ Service description.
-
int
m_instances¶ Amount of references to this service.
-
string
m_interface¶ Name of the service interface.
-
string
m_serviceDescriptionHash¶ Running number to identify when service info has changed.
-
AbstractService::ServiceState
m_state¶ State information regarding the service.
-
string
-
typedef function<void(vector<ServiceManager::ServiceInfo>)>