Retrieve a service instance object

You can retrieve a service instance object for a component that cannot be configured for high availability. Components that can be configured for high availability have a core service instance and a host service instance. The following code sample retrieves an AttachmentConnector service instance object.
Before you begin: Retrieve the serviceID integer for the service that you want to find the instance of.
  1. Create the AttachmentConnectorServiceInstance object to store the service instance.
    AttachmentConnectorServiceInstance serviceInstance;
  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 and since there is only one AttachmentConnector service instance, store the object for the first one that is found.
    List<ServiceInstanceType> serviceInstances = result.getServiceInstances();
    for (ServiceInstanceType itr:serviceInstances) 
    {
         if (itr2 instanceof AttachmentConnectorServiceInstance) 
         {
              serviceInstance = itr2;
              break;
         }
    }

Was this information helpful? Send us your comments.