Retrieve a host service instance object

You can retrieve a host service instance for any component that can be configured to support high availability. Components that cannot be configured to support high availability have only a service instance. The following code sample retrieves a Dispatcher host service instance.
Before you begin: Retrieve the following variables:
  • serviceID integer for the service ID that you want to find a host service instance of
  • instanceName string for the name of the host service instance you want to find
  1. Create a DispatcherHostServiceInstance object to store the host service instance.
    DispatcherHostServiceInstance hostServiceInstance;
  2. Invoke findServiceInstancesByService().
    boolean includeStatus=false;
    boolean includeExtendedData=true;
    boolean loadServiceConsumerRelationships=false;
    boolean loadServiceProducerRelationships=false;
    FindServiceInstancesByServiceResult result=coreWebService.findServiceInstancesByService(serviceID, locale, includeStatus, includeExtendedData, loadServiceConsumerRelationships, loadServiceProducerRelationships);  
  3. Check the result for errors and handle any errors.
    if (result.getFindServiceInstancesByServiceReturnStatus().getCode()!= FindServiceInstancesByServiceReturnStatusEnumType.SUCCESS) 
    {    
    	    // handle any errors
    }  
  4. Loop through the result until you find the dispatcher host service instance object you want to find.
    List<ServiceInstanceType> serviceInstances = result.getServiceInstances();
    for (ServiceInstanceType itr:serviceInstances) 
    {
         if (itr instanceof DispatcherHostServiceInstance) 
         {
            if (itr.getName().equalsIgnoreCase(instanceName)) 
            {
                return itr;
            }
            
         } 
    }

Was this information helpful? Send us your comments.