# Class: Context

## vertx-js/context~ Context

#### new Context()

Source:
  - vertx-js/context.js, line 30

### Methods

#### config() → {Object}

If the context is associated with a Verticle deployment, this returns the configuration that was specified when the verticle was deployed.

Source:
  - vertx-js/context.js, line 112

##### Returns:

the configuration of the deployment or null if not a Verticle deployment

Type
  Object

#### deploymentID() → {string}

If the context is associated with a Verticle deployment, this returns the deployment ID of that deployment.

Source:
  - vertx-js/context.js, line 97

##### Returns:

the deployment ID of the deployment or null if not a Verticle deployment

Type
  string

#### exceptionHandler(handler) → {Context}

Set an exception handler called when the context runs an action throwing an uncaught throwable.

When this handler is called, Vertx#currentContext will return this context.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the exception handler

Source:
  - vertx-js/context.js, line 262

##### Returns:

a reference to this, so the API can be used fluently

Type
  Context

#### executeBlocking(blockingCodeHandler, ordered, resultHandler)

Safely execute some blocking code.

Executes the blocking code in the handler `blockingCodeHandler` using a thread from the worker pool.

When the code is complete the handler `resultHandler` will be called with the result on the original context (e.g. on the original event loop of the caller).

A `Future` instance is passed into `blockingCodeHandler`. When the blocking code successfully completes, the handler should call the Future#complete or Future#complete method, or the Future#fail method if it failed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`blockingCodeHandler` | function | handler representing the blocking code to run
`ordered` | boolean | if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guarantees
`resultHandler` | function | handler that will be called when the blocking code is complete

Source:
  - vertx-js/context.js, line 65

#### get(key) → {Object}

Get some data from the context.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | string | the key of the data

Source:
  - vertx-js/context.js, line 190

##### Returns:

the data

Type
  Object

#### getInstanceCount() → {number}

Source:
  - vertx-js/context.js, line 246

##### Returns:

the number of instances of the verticle that were deployed in the deployment (if any) related to this context

Type
  number

#### isEventLoopContext() → {boolean}

Is the current context an event loop context?

NOTE! when running blocking code using Vertx#executeBlocking from a standard (not worker) verticle, the context will still an event loop context and this will return true.

Source:
  - vertx-js/context.js, line 144

##### Returns:

true if false otherwise

Type
  boolean

#### isMultiThreadedWorkerContext() → {boolean}

Is the current context a multi-threaded worker context?

Source:
  - vertx-js/context.js, line 176

##### Returns:

true if the current context is a multi-threaded worker context, false otherwise

Type
  boolean

#### isWorkerContext() → {boolean}

Is the current context a worker context?

NOTE! when running blocking code using Vertx#executeBlocking from a standard (not worker) verticle, the context will still an event loop context and this will return false.

Source:
  - vertx-js/context.js, line 162

##### Returns:

true if the current context is a worker context, false otherwise

Type
  boolean

#### owner() → {Vertx}

Source:
  - vertx-js/context.js, line 233

##### Returns:

The Vertx instance that created the context

Type
  Vertx

#### processArgs() → {Array.<string>}

The process args

Source:
  - vertx-js/context.js, line 126

##### Returns:

Type
  Array.<string>

#### put(key, value)

Put some data in the context.

This can be used to share data between different handlers that share a context

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | string | the key of the data
`value` | Object | the data

Source:
  - vertx-js/context.js, line 206

#### remove(key) → {boolean}

Remove some data from the context.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | string | the key to remove

Source:
  - vertx-js/context.js, line 220

##### Returns:

true if removed successfully, false otherwise

Type
  boolean

#### runOnContext(action)

Run the specified action asynchronously on the same context, some time after the current execution has completed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`action` | function | the action to run

Source:
  - vertx-js/context.js, line 41