Package com.sas.services

# Class ServiceInitializationObject

java.lang.Object
com.sas.services.ServiceInitializationObject

All Implemented Interfaces:
  `InitializationObjectInterface`, `Serializable`

public class ServiceInitializationObject extends Object implements InitializationObjectInterface
Foundation service's configuration represented as an XML document.

A service's configuration is represented as a UTF-8 encoded XML document. Supported object types are:

- `String`
- `InputSource`

Since:
  1.0
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ServiceInitializationObject()`
  Constructs a default instance for a service which does not have a configuration.
  `ServiceInitializationObject(String configXML)`
  Constructs an initialization object initialized with the specified service factory.
  `ServiceInitializationObject(InputSource configXMLInputSource)`
  Constructs an initialization object initialized with the specified service factory.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final void`
  `addConfiguration(String configName, String configXML)`
  Adds a configuration.
  `final void`
  `addConfigurationDocument(String configName, Document document)`
  Adds a configuration.
  `final Document`
  `createDocument(Object config)`
  Deprecated.
  Use {`createDocumentFromInputSource(InputSource)` or `createDocumentFromString(String)` instead.
  `final Document`
  `createDocumentFromInputSource(InputSource config)`
  Creates an XML document representation of the service configuration.
  `final Document`
  `createDocumentFromString(String config)`
  Creates an XML document representation of the service configuration.
  `final AbstractServiceComponentConfig`
  `getConfiguration(DocumentServiceConfigAdapterInterface adapter)`
  Gets a service configuration using the specified adapter to convert XML document to a service configuration.
  `final List<ServiceConfigDocument>`
  `getConfigurations()`
  Gets a copy of the collection of the service's configurations.
  `final Object`
  `getInitializationObject()`
  Gets an object used to configure the service.
  `final void`
  `setInitializationObject(Object config)`
  Sets the initialization object.

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

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

- ## Constructor Details

  - ### ServiceInitializationObject

    public ServiceInitializationObject()
    Constructs a default instance for a service which does not have a configuration.

    Use `setInitializationObject(Object)` to specify the service's configuration data.

  - ### ServiceInitializationObject

    public ServiceInitializationObject(String configXML) throws ServiceException, IllegalArgumentException
    Constructs an initialization object initialized with the specified service factory.
    Parameters:
      `configXML` - Initialization data or `null` if the service does not have any configuration data.
    Throws:
      `ServiceException` - if unable to create a configuration.
      `IllegalArgumentException` - if invalid XML is specified.
    See Also:
      - `ServiceInitializationObject(InputSource)`

  - ### ServiceInitializationObject

    public ServiceInitializationObject(InputSource configXMLInputSource) throws ServiceException, IllegalArgumentException
    Constructs an initialization object initialized with the specified service factory.
    Parameters:
      `configXMLInputSource` - Initialization data or `null` if the service does not have any configuration data.
    Throws:
      `ServiceException` - if unable to create a configuration.
      `IllegalArgumentException` - if an invalid input source is specified.
    See Also:
      - `ServiceInitializationObject(String)`

- ## Method Details

  - ### createDocument

    public final Document createDocument(Object config) throws InitializationException
    Deprecated.
    Use {`createDocumentFromInputSource(InputSource)` or `createDocumentFromString(String)` instead.
    Creates an XML document representation of the service configuration.
    Parameters:
      `config` - A `String` or `InputSource` that represents a service's XML configuration.
    Returns:
      XML document representation of the service's configuration.
    Throws:
      `InitializationException`

  - ### createDocumentFromString

    public final Document createDocumentFromString(String config) throws InitializationException
    Creates an XML document representation of the service configuration.
    Parameters:
      `config` - A `String` that represents a service's XML configuration.
    Returns:
      XML document representation of the service's configuration.
    Throws:
      `InitializationException`

  - ### createDocumentFromInputSource

    public final Document createDocumentFromInputSource(InputSource config) throws InitializationException
    Creates an XML document representation of the service configuration.
    Parameters:
      `config` - An `InputSource` that represents a service's XML configuration.
    Returns:
      XML document representation of the service's configuration.
    Throws:
      `InitializationException`

  - ### setInitializationObject

    public final void setInitializationObject(Object config) throws InitializationException
    Sets the initialization object.
    Parameters:
      `config` - Configuration from which an XML document will be obtained that represents a service's configuration. A service's configuration is represented as a UTF-8 encoded XML document.

      Supported object types are:

      - `String`
      - `InputSource`
    Throws:
      `InitializationException` - if an invalid object is specified.

  - ### addConfiguration

    public final void addConfiguration(String configName, String configXML) throws InitializationException
    Adds a configuration.
    Parameters:
      `configName` - Service configuration's name.
      `configXML` - XML service configuration.
    Throws:
      `InitializationException`

  - ### addConfigurationDocument

    public final void addConfigurationDocument(String configName, Document document) throws InitializationException
    Adds a configuration.
    Parameters:
      `configName` - Service configuration's name.
      `document` - XML document that represents the service's configuration.
    Throws:
      `InitializationException`

  - ### getInitializationObject

    public final Object getInitializationObject()
    Gets an object used to configure the service.
    Specified by:
      `getInitializationObject` in interface `InitializationObjectInterface`
    Returns:
      Service's initialization data.

  - ### getConfigurations

    public final List<ServiceConfigDocument> getConfigurations()
    Gets a copy of the collection of the service's configurations.
    Returns:
      Collection of the service's configurations. Each list element will be of type `ServiceConfigDocument`.

  - ### getConfiguration

    public final AbstractServiceComponentConfig getConfiguration(DocumentServiceConfigAdapterInterface adapter) throws ServiceException
    Gets a service configuration using the specified adapter to convert XML document to a service configuration.
    Parameters:
      `adapter` - Adapter used to translate an XML document into a service configuration.
    Returns:
      Service configuration or `null` if a configuration is not defined.
    Throws:
      `ServiceException` - if unable to create a configuration.