lib/application.js
function Application (configDir, appConfigFileName) {
  /**
   * The DXL client to use for communication with the fabric.
   * @private
   * @type {external.DxlClient}
   * @name Application#_dxlClient
   */
  this._dxlClient = null
  /**
   * The directory containing the application configuration files.
   * @private
   * @type {String}
   * @name Application#_configDir
   */
  this._configDir = configDir
  /**
   * Full path to the file used to configure the DXL client.
   * @private
   * @type {String}
   * @name Application#_dxlClientConfigPath
   */
  this._dxlClientConfigPath = path.join(configDir, DXL_CLIENT_CONFIG_FILE)
  /**
   * Full path to the application-specifie configuration file.
   * @private
   * @type {String}
   * @name Application#_appConfigPath
   */
  this._appConfigPath = path.join(configDir, appConfigFileName)
  /**
   * Whether or not the application is currently running.
   * @private
   * @type {boolean}
   * @name Application#_running
   */
  this._running = false

  /**
   * Loads the configuration settings from the application-specific
   * configuration file
   * @private
   */
  this._loadConfiguration = function () {
    var configData
    try {
      configData = fs.readFileSync(this._appConfigPath, 'utf-8')
    } catch (err) {
      throw new Error('Unable to read configuration file: ' + err.message)
    }

    var parsedConfig
    try {
      parsedConfig = ini.parse(configData)
    } catch (err) {
      throw new Error('Unable to parse config file: ' + err.message)
    }

    this.onLoadConfiguration(parsedConfig)
  }

  /**
   * Attempts to connect to the DXL fabric.
   * @private
   * @param {Function} [callback=null] - Callback function which should be
   *   invoked after the client has been connected.
   */
  this._dxlConnect = function (callback) {
    var that = this
    var config = Config.createDxlConfigFromFile(this._dxlClientConfigPath)
    this._dxlClient = new Client(config)
    this._dxlClient.connect(function () {
      that.onRegisterEventHandlers()
      that.onRegisterServices()
      that.onDxlConnect()
      if (callback) {
        callback()
      }
    })
  }
}
function Application (configDir, appConfigFileName) {
  /**
   * The DXL client to use for communication with the fabric.
   * @private
   * @type {external.DxlClient}
   * @name Application#_dxlClient
   */
  this._dxlClient = null
  /**
   * The directory containing the application configuration files.
   * @private
   * @type {String}
   * @name Application#_configDir
   */
  this._configDir = configDir
  /**
   * Full path to the file used to configure the DXL client.
   * @private
   * @type {String}
   * @name Application#_dxlClientConfigPath
   */
  this._dxlClientConfigPath = path.join(configDir, DXL_CLIENT_CONFIG_FILE)
  /**
   * Full path to the application-specifie configuration file.
   * @private
   * @type {String}
   * @name Application#_appConfigPath
   */
  this._appConfigPath = path.join(configDir, appConfigFileName)
  /**
   * Whether or not the application is currently running.
   * @private
   * @type {boolean}
   * @name Application#_running
   */
  this._running = false

  /**
   * Loads the configuration settings from the application-specific
   * configuration file
   * @private
   */
  this._loadConfiguration = function () {
    var configData
    try {
      configData = fs.readFileSync(this._appConfigPath, 'utf-8')
    } catch (err) {
      throw new Error('Unable to read configuration file: ' + err.message)
    }

    var parsedConfig
    try {
      parsedConfig = ini.parse(configData)
    } catch (err) {
      throw new Error('Unable to parse config file: ' + err.message)
    }

    this.onLoadConfiguration(parsedConfig)
  }

  /**
   * Attempts to connect to the DXL fabric.
   * @private
   * @param {Function} [callback=null] - Callback function which should be
   *   invoked after the client has been connected.
   */
  this._dxlConnect = function (callback) {
    var that = this
    var config = Config.createDxlConfigFromFile(this._dxlClientConfigPath)
    this._dxlClient = new Client(config)
    this._dxlClient.connect(function () {
      that.onRegisterEventHandlers()
      that.onRegisterServices()
      that.onDxlConnect()
      if (callback) {
        callback()
      }
    })
  }
}
function Application ( configDir , appConfigFileName ) { /**
   * The DXL client to use for communication with the fabric.
   * @private
   * @type {external.DxlClient}
   * @name Application#_dxlClient
   */ this . _dxlClient = null /**
   * The directory containing the application configuration files.
   * @private
   * @type {String}
   * @name Application#_configDir
   */ this . _configDir = configDir /**
   * Full path to the file used to configure the DXL client.
   * @private
   * @type {String}
   * @name Application#_dxlClientConfigPath
   */ this . _dxlClientConfigPath = path . join ( configDir , DXL_CLIENT_CONFIG_FILE ) /**
   * Full path to the application-specifie configuration file.
   * @private
   * @type {String}
   * @name Application#_appConfigPath
   */ this . _appConfigPath = path . join ( configDir , appConfigFileName ) /**
   * Whether or not the application is currently running.
   * @private
   * @type {boolean}
   * @name Application#_running
   */ this . _running = false /**
   * Loads the configuration settings from the application-specific
   * configuration file
   * @private
   */ this . _loadConfiguration = function ( ) { var configData try { configData = fs . readFileSync ( this . _appConfigPath , 'utf-8' ) } catch ( err ) { throw new Error ( 'Unable to read configuration file: ' + err . message ) } var parsedConfig try { parsedConfig = ini . parse ( configData ) } catch ( err ) { throw new Error ( 'Unable to parse config file: ' + err . message ) } this . onLoadConfiguration ( parsedConfig ) } /**
   * Attempts to connect to the DXL fabric.
   * @private
   * @param {Function} [callback=null] - Callback function which should be
   *   invoked after the client has been connected.
   */ this . _dxlConnect = function ( callback ) { var that = this var config = Config . createDxlConfigFromFile ( this . _dxlClientConfigPath ) this . _dxlClient = new Client ( config ) this . _dxlClient . connect ( function ( ) { that . onRegisterEventHandlers ( ) that . onRegisterServices ( ) that . onDxlConnect ( ) if ( callback ) { callback ( ) } } ) } }
Service registration instances are used to register and expose services onto
a DXL fabric.
@external ServiceRegistrationInfo
@see {@link https://opendxl.github.io/opendxl-client-javascript/jsdoc/ServiceRegistrationInfo.html}
 
@classdesc Base class used for DXL applications.
@param {String} configDir - The directory containing the application
configuration files.
@param {String} appConfigFileName - The name of the application-specific
configuration file.
@constructor
Service registration instances are used to register and expose services onto a DXL fabric .