11.2.2. Service status event handler
After the control channel is established, the site checks the connected service against the set of parameters provided by the endpoint as well as those set by the service owner on the site. If the service is eligible, it installs on the site. Then, the site assigns it an online status, and it is ready to serve clients. Otherwise, based on the reason for ineligibility, the site assigns it a status from the ServiceStatus enumeration. The whole process ends with a call to the following handler:
void onStatusChanged(ServiceEndpointEvent e)
To get the updated service status, follow these steps. In the handler’s body, call the getEndpoint method on the e parameter. It returns the endpoint, which is of type ServiceEndpoint, that invoked the handler. Then call the endpoint’s getStatus method. It has the following signature:
public ServiceStatus getStatus()
The example below demonstrates these steps:
public void onStatusChanged(ServiceEndpointEvent e)
{
ServiceEndpoint serviceEndpoint = e.getEndpoint();
ServiceStatus serviceStatus = serviceEndpoint.getStatus();
System.out.println(String.format("The service status: %s", serviceStatus));
}
Let’s consider the status names from the ServiceStatus enumeration and their interpretation.
public enum ServiceStatus
{
Offline,
Online,
ServiceTypeConflict,
SiteStructureMismatch,
OwnerDisabled,
SiteDisabled,
Disabled
}
- Offline – while the endpoint is not connected to the site, the service has this status;
- Online – the service is ready to serve clients;
- ServiceTypeConflict – the Service Type and Contract Author provided by the service are different from those declared on the site;
- SiteStructureMismatch – there is no conflict with Service Type and Contract Author but the site structure provided by the service is different from the structure that has been used to build the site;
- OwnerDisabled – the service owner is disabled by the Softnet MS administrator;
- SiteDisabled – the site on which the service is registered is disabled by the owner.
- Disabled – the service is disabled by the owner;