HttpConnectionResolver

Helper class to retrieve connections for HTTP-based services and clients.

Implements: IReferenceable, IConfigurable

Description

The HttpConnectionResolver class is used to retrieve connections for HTTP-based services and clients.

Important points

  • In addition to its regular functions, ConnectionResolver is able to parse http:// URIs and validate connection parameters before returning them.

Configuration parameters

  • connection:
    • discovery_key: (optional) key to retrieve the connection from IDiscovery
    • : other connection parameters
  • connections: alternative to connection
    • [connection params 1]: first connection parameters
    • [connection params N]: Nth connection parameters

References

  • *:discovery:*:*:1.0 - (optional) IDiscovery services to resolve a connection

Fields

_connectionResolver

Creates a connection resolver.

protected ConnectionResolver _connectionResolver = new ConnectionResolver()

_credentialResolver

The base credential resolver.

protected CredentialResolver _credentialResolver = new CredentialResolver()

Instance methods

configure

Configures component by passing configuration parameters.

public void configure(ConfigParams config)

  • config: ConfigParams - configuration parameters to be set.

register

Registers the given connection in all referenced discovery services. This method can be used for dynamic service discovery.

public void register(IContext context) throws ApplicationException

  • context: IContext - (optional) a context to trace execution through a call chain.

resolve

Resolves a single component connection. If the connections are configured to be retrieved from Discovery service, it finds a IDiscovery and resolves the connection there.

public ConnectionParams resolve(context: IContext)

  • context: IContext - (optional) a context to trace execution through a call chain.
  • returns: ConnectionParams - resolved connection.

resolveAll

Resolves all component connections. If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there.

ConnectionParams resolveAll(IContext context) throws ApplicationException

  • context: IContext - (optional) a context to trace execution through a call chain.
  • returns: ConnectionParams - resolved connections.

setReferences

Sets references to dependent components.

public void setReferences(IReferences references)

  • references: IReferences - references to locate the component dependencies.

Examples

{
  ConfigParams config = ConfigParams.fromTuples(
       "connection.host", "10.1.1.100",
       "connection.port", 8080
  );
  
  HttpConnectionResolver connectionResolver = new HttpConnectionResolver();
  connectionResolver.configure(config);
  connectionResolver.setReferences(references);
  
  ConnectionParams params = connectionResolver.resolve("123");
  }

See also