### *** This class provides Binary Compatibility only, not Source Compatibility ***

Package com.sas.services.deployment

# Class ServiceLoader

java.lang.Object
com.sas.services.deployment.ServiceLoader

@SASScope("ALL") @BinaryCompatibilityOnly public class ServiceLoader extends Object
Service deployment utility that loads services based upon an Open Metadata Architecture (OMA) schema. This loader may be used to deploy services or to look up remote discovery services to which previously deployed services may be registered.

In the case of service deployment, if a discovery service is specified then deployed services will be registered with the discovery service to facilitate future lookup based upon their service types and optionally service attributes.

Once services are deployed they can be discovered using the `DiscoveryService`.

Since:
  1.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static final List<RemoteServiceInterface>`
  `deployServices(MetadataSourceInterface metadataSource)`
  Gets a set of services from the specified metadata source and registers instantiated services with the `local discovery service`.
  `static final List<RemoteServiceInterface>`
  `deployServices(MetadataSourceInterface metadataSource, Environment environment, DiscoveryServiceInterface discoveryService)`
  Gets a set of services from the specified metadata source.
  `static final List<RemoteServiceInterface>`
  `deployServices(MetadataSourceInterface metadataSource, DiscoveryServiceInterface discoveryService)`
  Gets a set of deployable services from the specified metadata source.
  `static final List<FindServiceInterface>`
  `lookupRemoteDiscoveryServices(MetadataSourceInterface metadataSource)`
  Gets a set of `DeployableService` elements representing remote discovery services that may be available if previously deployed by foundation bootstrap process and binds them to the local discovery service.
  `static final List<FindServiceInterface>`
  `lookupRemoteDiscoveryServices(MetadataSourceInterface metadataSource, DiscoveryServiceInterface discoveryService)`
  Gets a set of `DeployableService` elements representing remote discovery services that may be available if previously deployed by foundation bootstrap process.
  `static final List<FindServiceInterface>`
  `lookupRemoteDiscoveryServices(MetadataSourceInterface metadataSourceLookup, DiscoveryServiceInterface discoveryService, LookupPolicyInterface lookupPolicy)`
  Gets a set of `DeployableService` elements representing remote discovery services that may be available if previously deployed by foundation bootstrap process.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### lookupRemoteDiscoveryServices

    public static final List<FindServiceInterface> lookupRemoteDiscoveryServices(MetadataSourceInterface metadataSource, DiscoveryServiceInterface discoveryService) throws ServiceException, ServiceLookupFailedException
    Gets a set of `DeployableService` elements representing remote discovery services that may be available if previously deployed by foundation bootstrap process.

    1. Query OMR for all `ServiceComponent` elements associated with the specified `SoftwareComponent` that are RMI registries.
    2. Query OMR to obtain `NamedService` name bindings associated with each RMI registry.
    3. Determine `ServiceComponent` elements bound to the RMI registry that satisfy service type `com.sas.services.discovery.FindServiceInterface`
    Parameters:
      `metadataSource` - A source for the metadata such as an initialized instance of an OMRMetadataSource or URLMetadataSource. Note that if an OMR metadata source is specified that its connection will be closed by this method unless the metadata source's preference to be closed has been toggled off.
      `discoveryService` - A discovery service to which deployed services will be registered.
    Returns:
      List of services which implement `FindServiceInterface` that can be used to locate other services.
    Throws:
      `ServiceException` - if unable to lookup remote discovery services.
      `ServiceLookupFailedException` - if 1..* remote discovery service lookups fail.

  - ### lookupRemoteDiscoveryServices

    public static final List<FindServiceInterface> lookupRemoteDiscoveryServices(MetadataSourceInterface metadataSource) throws ServiceException, ServiceLookupFailedException
    Gets a set of `DeployableService` elements representing remote discovery services that may be available if previously deployed by foundation bootstrap process and binds them to the local discovery service.

    1. Query OMR for all `ServiceComponent` elements associated with the specified `SoftwareComponent` that are RMI registries.
    2. Query OMR to obtain `NamedService` name bindings associated with each RMI registry.
    3. Determine `ServiceComponent` elements bound to the RMI registry that satisfy service type `com.sas.services.discovery.FindServiceInterface`
    Parameters:
      `metadataSource` - A source for the metadata such as an initialized instance of an OMRMetadataSource or URLMetadataSource. Note that if an OMR metadata source is specified that its connection will be closed by this method unless the metadata source's preference to be closed has been toggled off.
    Returns:
      List of services which implement `FindServiceInterface` that can be used to locate other services.
    Throws:
      `ServiceException` - if unable to lookup remote discovery services.
      `ServiceLookupFailedException` - if 1..* remote discovery service lookups fail.

  - ### lookupRemoteDiscoveryServices

    public static final List<FindServiceInterface> lookupRemoteDiscoveryServices(MetadataSourceInterface metadataSourceLookup, DiscoveryServiceInterface discoveryService, LookupPolicyInterface lookupPolicy) throws ServiceException, ServiceLookupFailedException
    Gets a set of `DeployableService` elements representing remote discovery services that may be available if previously deployed by foundation bootstrap process.

    1. Query OMR for all `ServiceComponent` elements associated with the specified `SoftwareComponent` that are RMI registries.
    2. Query OMR to obtain `NamedService` name bindings associated with each RMI registry.
    3. Determine `ServiceComponent` elements bound to the RMI registry that satisfy service type `com.sas.services.discovery.FindServiceInterface`

    The caller is responsible for destroying the deployed services by calling the `destroy()` method on {`DiscoveryService.defaultInstance()` when the application is terminated.

    Parameters:
      `metadataSourceLookup` - A source for the metadata such as an initialized instance of an OMRMetadataSource or URLMetadataSource. Note that if an OMR metadata source is specified that its connection will be closed by this method unless the metadata source's preference to be closed has been toggled off.
      `discoveryService` - A discovery service to which deployed services will be registered.
      `lookupPolicy` - `null` if the lookup should not be re-attempted in the event that it fails or an implementation of a lookup policy that will be used to specify whether or not subsequent attempts occur. Lookup policy implementations include `LookupPolicyAttempts` and `LookupPolicyTimeout`.
    Returns:
      List of services which implement `FindServiceInterface` that can be used to locate other services.
    Throws:
      `ServiceException` - if unable to lookup remote discovery services.
      `ServiceLookupFailedException` - if 1..* remote discovery service lookups fail.

  - ### deployServices

    public static final List<RemoteServiceInterface> deployServices(MetadataSourceInterface metadataSource) throws ServiceDeploymentException, ServiceException
    Gets a set of services from the specified metadata source and registers instantiated services with the `local discovery service`.

    The caller is responsible for destroying the deployed services by calling the `destroy()` method on {`DiscoveryService.defaultInstance()` when the application is terminated.

    Parameters:
      `metadataSource` - Metadata source from which services will be queried.
    Returns:
      List of `RemoteServiceInterface` objects representing foundation services which were successfully deployed.
    Throws:
      `ServiceDeploymentException` - if unable to deploy services. This exception will cite the cause of the failure and provide a list of services which were successfully deployed. This exception is a subclass of ServiceException.
      `ServiceException` - if unable to deploy the services.

  - ### deployServices

    public static final List<RemoteServiceInterface> deployServices(MetadataSourceInterface metadataSource, DiscoveryServiceInterface discoveryService) throws ServiceDeploymentException, ServiceException
    Gets a set of deployable services from the specified metadata source.

    The caller is responsible for destroying the deployed services by calling the `destroy()` method on the discovery service when the application is terminated.

    Parameters:
      `metadataSource` - Metadata source from which services will be queried.
      `discoveryService` - The discovery service to which loaded services will be registered. As services are deployed they will be registered with this discovery service.
    Returns:
      List of `RemoteServiceInterface` objects representing foundation services which were successfully deployed.
    Throws:
      `ServiceDeploymentException` - if unable to deploy services. This exception will cite the cause of the failure and provide a list of services which were successfully deployed. This exception is a subclass of ServiceException.
      `ServiceException` - if unable to deploy the services.

  - ### deployServices

    public static final List<RemoteServiceInterface> deployServices(MetadataSourceInterface metadataSource, Environment environment, DiscoveryServiceInterface discoveryService) throws ServiceDeploymentException, ServiceException
    Gets a set of services from the specified metadata source.

    The caller is responsible for destroying the deployed services by calling the `destroy()` method on the discovery service when the application is terminated.

    Parameters:
      `metadataSource` - Metadata source from which services will be queried.
      `environment` - The Environment object encapsulates resources provided by the container. It is made available to the services as they are deployed.
      `discoveryService` - The discovery service to which loaded services will be registered. As services are deployed they will be registered with this discovery service.
    Returns:
      List of `RemoteServiceInterface` objects representing foundation services which were successfully deployed.
    Throws:
      `ServiceDeploymentException` - if unable to deploy services. This exception will cite the cause of the failure and provide a list of services which were successfully deployed. This exception is a subclass of ServiceException.
      `ServiceException` - if unable to deploy the services.