public abstract class ContextImpl extends Object implements Context
| Modifier and Type | Field and Description |
|---|---|
protected JsonObject |
config |
protected io.vertx.core.impl.VertxThread |
contextThread |
protected String |
deploymentID |
protected Executor |
orderedInternalPoolExec |
protected VertxInternal |
owner |
protected Executor |
workerExec |
| Modifier | Constructor and Description |
|---|---|
protected |
ContextImpl(VertxInternal vertx,
Executor orderedInternalPoolExec,
Executor workerExec,
String deploymentID,
JsonObject config,
ClassLoader tccl) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCloseHook(Closeable hook) |
protected abstract void |
checkCorrectThread() |
JsonObject |
config()
If the context is associated with a Verticle deployment, this returns the configuration that was specified when
the verticle was deployed.
|
protected Map<String,Object> |
contextData() |
String |
deploymentID()
If the context is associated with a Verticle deployment, this returns the deployment ID of that deployment.
|
io.netty.channel.EventLoop |
eventLoop() |
protected abstract void |
executeAsync(Handler<Void> task) |
<T> void |
executeBlocking(Action<T> action,
Handler<AsyncResult<T>> resultHandler) |
<T> void |
executeBlocking(Handler<Future<T>> blockingCodeHandler,
boolean ordered,
Handler<AsyncResult<T>> resultHandler) |
void |
executeFromIO(ContextTask task) |
<T> T |
get(String key)
Get some data from the context.
|
Deployment |
getDeployment() |
int |
getInstanceCount() |
abstract boolean |
isEventLoopContext()
Is the current context an event loop context?
|
abstract boolean |
isMultiThreadedWorkerContext()
Is the current context a multi-threaded worker context?
|
static boolean |
isOnEventLoopThread()
Is the current thread an event thread?
|
static boolean |
isOnVertxThread()
Is the current thread a Vert.x thread? That's either a worker thread or an event loop thread
|
static boolean |
isOnWorkerThread()
Is the current thread a worker thread?
|
boolean |
isWorkerContext()
Is the current context a worker context?
|
Vertx |
owner() |
List<String> |
processArgs()
The process args
|
void |
put(String key,
Object value)
Put some data in the context.
|
boolean |
remove(String key)
Remove some data from the context.
|
void |
removeCloseHook(Closeable hook) |
void |
runCloseHooks(Handler<AsyncResult<Void>> completionHandler) |
void |
runOnContext(Handler<Void> task)
Run the specified action asynchronously on the same context, some time after the current execution has completed.
|
static void |
setContext(ContextImpl context) |
void |
setDeployment(Deployment deployment) |
protected Runnable |
wrapTask(ContextTask cTask,
Handler<Void> hTask,
boolean checkThread) |
protected final VertxInternal owner
protected final String deploymentID
protected final JsonObject config
protected final Executor orderedInternalPoolExec
protected final Executor workerExec
protected io.vertx.core.impl.VertxThread contextThread
protected ContextImpl(VertxInternal vertx, Executor orderedInternalPoolExec, Executor workerExec, String deploymentID, JsonObject config, ClassLoader tccl)
public static void setContext(ContextImpl context)
public void setDeployment(Deployment deployment)
public Deployment getDeployment()
public void addCloseHook(Closeable hook)
public void removeCloseHook(Closeable hook)
public void runCloseHooks(Handler<AsyncResult<Void>> completionHandler)
public abstract boolean isEventLoopContext()
Context
NOTE! when running blocking code using Vertx.executeBlocking(Handler, Handler) from a
standard (not worker) verticle, the context will still an event loop context and this this#isEventLoopContext()
will return true.
isEventLoopContext in interface Contextpublic abstract boolean isMultiThreadedWorkerContext()
ContextisMultiThreadedWorkerContext in interface Contextpublic <T> T get(String key)
Contextpublic void put(String key, Object value)
ContextThis can be used to share data between different handlers that share a context
public boolean remove(String key)
Contextpublic boolean isWorkerContext()
Context
NOTE! when running blocking code using Vertx.executeBlocking(Handler, Handler) from a
standard (not worker) verticle, the context will still an event loop context and this this#isWorkerContext()
will return false.
isWorkerContext in interface Contextpublic static boolean isOnWorkerThread()
Context
NOTE! This is not always the same as calling Context.isWorkerContext(). If you are running blocking code
from an event loop context, then this will return true but Context.isWorkerContext() will return false.
isOnWorkerThread in interface Contextpublic static boolean isOnEventLoopThread()
Context
NOTE! This is not always the same as calling Context.isEventLoopContext(). If you are running blocking code
from an event loop context, then this will return false but Context.isEventLoopContext() will return true.
isOnEventLoopThread in interface Contextpublic static boolean isOnVertxThread()
ContextisOnVertxThread in interface Contextpublic void executeFromIO(ContextTask task)
protected abstract void checkCorrectThread()
public void runOnContext(Handler<Void> task)
ContextrunOnContext in interface Contexttask - the action to runpublic String deploymentID()
ContextdeploymentID in interface Contextpublic JsonObject config()
Contextpublic List<String> processArgs()
ContextprocessArgs in interface Contextpublic io.netty.channel.EventLoop eventLoop()
public Vertx owner()
public <T> void executeBlocking(Action<T> action, Handler<AsyncResult<T>> resultHandler)
public <T> void executeBlocking(Handler<Future<T>> blockingCodeHandler, boolean ordered, Handler<AsyncResult<T>> resultHandler)
protected Runnable wrapTask(ContextTask cTask, Handler<Void> hTask, boolean checkThread)
public int getInstanceCount()
getInstanceCount in interface ContextCopyright © 2015. All Rights Reserved.