Retrieve a core service instance object

You can retrieve a core 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 DispatcherCoreServiceInstance object
Before you begin: Retrieve the following variables:
  • serviceID integer for the service that you want to find the core service instance ID of
  • instanceName string for the name of the core service instance that you want to find
  1. Create a DispatcherCoreServiceInstance object to store the core service instance.
    DispatcherCoreServiceInstance coreServiceInstance;
  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 core service instance object that you want to find.
    List<ServiceInstanceType> serviceInstances = result.getServiceInstances();
    for (ServiceInstanceType itr:serviceInstances) 
    {
         if (itr instanceof DispatcherCoreServiceInstance) 
         {
            if (itr.getName().equalsIgnoreCase(instanceName)) 
            {
                return itr;
            }
            
         } 
    }

Was this information helpful? Send us your comments.