List of usage examples for io.vertx.core Context get
<T> T get(String key);
From source file:examples.CoreExamples.java
License:Open Source License
public void runInContextWithData(Vertx vertx) { final Context context = vertx.getOrCreateContext(); context.put("data", "hello"); context.runOnContext((v) -> {/* w w w.j a v a 2 s . c om*/ String hello = context.get("data"); }); }
From source file:org.apache.servicecomb.foundation.vertx.client.ClientPoolManager.java
License:Apache License
protected CLIENT_POOL findByContext(Context targetContext) { Context currentContext = targetContext != null ? targetContext : Vertx.currentContext(); if (currentContext != null && currentContext.owner() == vertx && currentContext.isEventLoopContext()) { // standard reactive mode CLIENT_POOL clientPool = currentContext.get(id); if (clientPool != null) { return clientPool; }/* w w w . j a v a 2 s .co m*/ // this will make "client.thread-count" bigger than which in microservice.yaml // maybe it's better to remove "client.thread-count", just use "rest/highway.thread-count" return createClientPool(currentContext); } // not in correct context: // 1.normal thread // 2.vertx worker thread // 3.other vertx thread // select a existing context int idx = reactiveNextIndex.getAndIncrement() % pools.size(); if (idx < 0) { idx = -idx; } return pools.get(idx); }