Class CompositeConnectionResolver

java.lang.Object
org.pipservices3.components.connect.CompositeConnectionResolver
All Implemented Interfaces:
org.pipservices3.commons.config.IConfigurable, org.pipservices3.commons.refer.IReferenceable

public class CompositeConnectionResolver extends Object implements org.pipservices3.commons.refer.IReferenceable, org.pipservices3.commons.config.IConfigurable
Helper class that resolves connection and credential parameters, validates them and generates connection options.

### Configuration parameters ###

  • - connection(s):
    • - discovery_key: (optional) a key to retrieve the connection from IDiscovery
    • - protocol: communication protocol
    • - host: host name or IP address
    • - port: port number
    • - uri: resource URI or connection string with all parameters in it
  • - credential(s):
    • - store_key: (optional) a key to retrieve the credentials from ICredentialStore
    • - username: user name
    • - password: user password

In addition to standard parameters CredentialParams may contain any number of custom parameters

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    The cluster support (multiple connections)
    The connections resolver.
    The credentials resolver.
    protected int
    The default port number
    protected String
    The default protocol
    protected org.pipservices3.commons.config.ConfigParams
    The connection options
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.pipservices3.commons.config.ConfigParams
    compose(String correlationId, List<ConnectionParams> connections, CredentialParams credential, org.pipservices3.commons.config.ConfigParams parameters)
    Composes Composite connection options from connection and credential parameters.
    void
    configure(org.pipservices3.commons.config.ConfigParams configParams)
    Configures component by passing configuration parameters.
    protected org.pipservices3.commons.config.ConfigParams
    finalizeOptions(org.pipservices3.commons.config.ConfigParams options)
    Finalize merged options This method can be overriden in child classes.
    protected org.pipservices3.commons.config.ConfigParams
    mergeConnection(org.pipservices3.commons.config.ConfigParams options, ConnectionParams connection)
    Merges connection options with connection parameters This method can be overriden in child classes.
    protected org.pipservices3.commons.config.ConfigParams
    mergeCredential(org.pipservices3.commons.config.ConfigParams options, CredentialParams credential)
    Merges connection options with credential parameters This method can be overriden in child classes.
    protected org.pipservices3.commons.config.ConfigParams
    mergeOptional(org.pipservices3.commons.config.ConfigParams options, org.pipservices3.commons.config.ConfigParams parameters)
    Merges connection options with optional parameters This method can be overriden in child classes.
    org.pipservices3.commons.config.ConfigParams
    resolve(String correlationId)
     
    void
    setReferences(org.pipservices3.commons.refer.IReferences references)
    Sets references to dependent components.
    protected void
    validateConnection(String correlationId, ConnectionParams connection)
     
    protected void
    validateCredential(String correlationId, CredentialParams credential)
    Validates credential parameters and throws an exception on error.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _options

      protected org.pipservices3.commons.config.ConfigParams _options
      The connection options
    • _connectionResolver

      protected ConnectionResolver _connectionResolver
      The connections resolver.
    • _credentialResolver

      protected CredentialResolver _credentialResolver
      The credentials resolver.
    • _clusterSupported

      protected boolean _clusterSupported
      The cluster support (multiple connections)
    • _defaultProtocol

      protected String _defaultProtocol
      The default protocol
    • _defaultPort

      protected int _defaultPort
      The default port number
  • Constructor Details

    • CompositeConnectionResolver

      public CompositeConnectionResolver()
  • Method Details

    • configure

      public void configure(org.pipservices3.commons.config.ConfigParams configParams) throws org.pipservices3.commons.errors.ConfigException
      Configures component by passing configuration parameters.
      Specified by:
      configure in interface org.pipservices3.commons.config.IConfigurable
      Parameters:
      configParams - configuration parameters to be set.
      Throws:
      org.pipservices3.commons.errors.ConfigException
    • setReferences

      public void setReferences(org.pipservices3.commons.refer.IReferences references) throws org.pipservices3.commons.refer.ReferenceException, org.pipservices3.commons.errors.ConfigException
      Sets references to dependent components.
      Specified by:
      setReferences in interface org.pipservices3.commons.refer.IReferenceable
      Parameters:
      references - references to locate the component dependencies.
      Throws:
      org.pipservices3.commons.refer.ReferenceException
      org.pipservices3.commons.errors.ConfigException
    • resolve

      public org.pipservices3.commons.config.ConfigParams resolve(String correlationId) throws org.pipservices3.commons.errors.ApplicationException
      Throws:
      org.pipservices3.commons.errors.ApplicationException
    • compose

      public org.pipservices3.commons.config.ConfigParams compose(String correlationId, List<ConnectionParams> connections, CredentialParams credential, org.pipservices3.commons.config.ConfigParams parameters) throws org.pipservices3.commons.errors.ConfigException
      Composes Composite connection options from connection and credential parameters.
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      connections - connection parameters
      credential - credential parameters
      parameters - optional parameters
      Returns:
      resolved options.
      Throws:
      org.pipservices3.commons.errors.ConfigException
    • validateConnection

      protected void validateConnection(String correlationId, ConnectionParams connection) throws org.pipservices3.commons.errors.ConfigException
      Throws:
      org.pipservices3.commons.errors.ConfigException
    • validateCredential

      protected void validateCredential(String correlationId, CredentialParams credential)
      Validates credential parameters and throws an exception on error. This method can be overriden in child classes.
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      credential - credential parameters to be validated
    • mergeConnection

      protected org.pipservices3.commons.config.ConfigParams mergeConnection(org.pipservices3.commons.config.ConfigParams options, ConnectionParams connection)
      Merges connection options with connection parameters This method can be overriden in child classes.
      Parameters:
      options - connection options
      connection - connection parameters to be merged
      Returns:
      merged connection options.
    • mergeCredential

      protected org.pipservices3.commons.config.ConfigParams mergeCredential(org.pipservices3.commons.config.ConfigParams options, CredentialParams credential)
      Merges connection options with credential parameters This method can be overriden in child classes.
      Parameters:
      options - connection options
      credential - credential parameters to be merged
      Returns:
      merged connection options.
    • mergeOptional

      protected org.pipservices3.commons.config.ConfigParams mergeOptional(org.pipservices3.commons.config.ConfigParams options, org.pipservices3.commons.config.ConfigParams parameters)
      Merges connection options with optional parameters This method can be overriden in child classes.
      Parameters:
      options - connection options
      parameters - optional parameters to be merged
      Returns:
      merged connection options.
    • finalizeOptions

      protected org.pipservices3.commons.config.ConfigParams finalizeOptions(org.pipservices3.commons.config.ConfigParams options)
      Finalize merged options This method can be overriden in child classes.
      Parameters:
      options - connection options
      Returns:
      finalized connection options