MongoDbConnectionResolver

MongoDbConnectionResolver implementation. Helper class that resolves MongoDB connection and credential parameters, validates them and generates a connection URI.

Implements: IReferenceable, IConfigurable

Description

The MongoDbConnectionResolver class allows you to create a MongoDB connection resolver that resolves MongoDB connection and credential parameters, validates them, and generates a connection URI.

Important points

  • It is able to process multiple connections to MongoDB cluster nodes.

Configuration parameters

connection(s):

  • discovery_key: (optional) key to retrieve the connection from IDiscovery
  • host: host name or IP address
  • port: port number (default: 27017)
  • database: database name
  • uri: resource URI or connection string with all parameters in it

credential(s):

  • store_key: (optional) key to retrieve the credentials from ICredentialStore
  • username: username
  • password: user’s password

References

  • *:discovery:*:*:1.0 - (optional) IDiscovery services
  • *:credential-store:*:*:1.0 - (optional) credential stores to resolve credentials

Fields

_connectionResolver

MongoDB connection resolver.

protected ConnectionResolver _connectionResolver = new ConnectionResolver();

_credentialResolver

MongoDB credential resolver.

protected CredentialResolver _credentialResolver = new CredentialResolver();

Instance methods

configure

Configures the component by passing its configuration parameters.

public void configure(ConfigParams config)

  • config: ConfigParams - configuration parameters to be set.

resolve

Resolves a MongoDB connection URI from connection and credential parameters.

public String resolve(IContext context) throws ApplicationException

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

setReferences

Sets references to dependent components.

public void setReferences(IReferences references)

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