當前位置: 首頁>>代碼示例>>Java>>正文


Java Vertx.currentContext方法代碼示例

本文整理匯總了Java中io.vertx.core.Vertx.currentContext方法的典型用法代碼示例。如果您正苦於以下問題:Java Vertx.currentContext方法的具體用法?Java Vertx.currentContext怎麽用?Java Vertx.currentContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.vertx.core.Vertx的用法示例。


在下文中一共展示了Vertx.currentContext方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findByContext

import io.vertx.core.Vertx; //導入方法依賴的package包/類
protected CLIENT_POOL findByContext() {
  Context currentContext = Vertx.currentContext();
  if (currentContext != null
      && currentContext.owner() == vertx
      && currentContext.isEventLoopContext()) {
    // standard reactive mode
    CLIENT_POOL clientPool = currentContext.get(id);
    if (clientPool != null) {
      return clientPool;
    }

    // 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();
  }

  // not in correct context:
  // 1.normal thread
  // 2.vertx worker thread
  // 3.other vertx thread
  // select a existing context
  return nextPool();
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:24,代碼來源:ClientPoolManager.java

示例2: schedule

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Override
protected void schedule(CommandBase<?> cmd) {
  Context current = Vertx.currentContext();
  if (current == context) {
    pool.acquire(new CommandWaiter() {
      @Override
      protected void onSuccess(Connection conn) {
        // Work around stack over flow
        context.runOnContext(v -> {
          conn.schedule(cmd);
          conn.close(this);
        });
      }
      @Override
      protected void onFailure(Throwable cause) {
        cmd.fail(cause);
      }
    });
  } else {
    context.runOnContext(v -> schedule(cmd));
  }
}
 
開發者ID:vietj,項目名稱:reactive-pg-client,代碼行數:23,代碼來源:PgPoolImpl.java

示例3: createClientPool

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Override
public CLIENT_POOL createClientPool() {
  Context context = Vertx.currentContext();
  Vertx vertx = context.owner();

  NetClientWrapper netClientWrapper = new NetClientWrapper(vertx, normalClientConfig, sslClientConfig);
  return doCreateClientPool(context, netClientWrapper);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:9,代碼來源:AbstractTcpClientPoolFactory.java

示例4: TcpRequest

import io.vertx.core.Vertx; //導入方法依賴的package包/類
public TcpRequest(long msTimeout, TcpResponseCallback responseCallback) {
  callContext = Vertx.currentContext();
  threadId = Thread.currentThread().getId();
  this.begin = System.currentTimeMillis();
  this.msTimeout = msTimeout;
  this.responseCallback = responseCallback;
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:8,代碼來源:TcpRequest.java

示例5: createClientPool

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Override
public HttpClientWithContext createClientPool() {
  Context context = Vertx.currentContext();
  HttpClient httpClient = context.owner().createHttpClient(httpClientOptions);

  return new HttpClientWithContext(httpClient, context);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:8,代碼來源:HttpClientPoolFactory.java

示例6: currentVertx

import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static Vertx currentVertx() {
  Context context = Vertx.currentContext();
  if (context == null) {
    throw new RuntimeException("get currentVertx error, currentContext is null.");
  }

  return context.owner();
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:9,代碼來源:VertxUtils.java

示例7: runInContext

import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static <T> void runInContext(Context context, AsyncResultCallback<T> callback, T result, Throwable e) {
  if (context == Vertx.currentContext()) {
    complete(callback, result, e);
  } else {
    context.runOnContext(v -> complete(callback, result, e));
  }
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:8,代碼來源:VertxUtils.java

示例8: PgPoolImpl

import io.vertx.core.Vertx; //導入方法依賴的package包/類
public PgPoolImpl(Vertx vertx, boolean closeVertx, PgPoolOptions options) {
  int maxSize = options.getMaxSize();
  if (maxSize < 1) {
    throw new IllegalArgumentException("Pool max size must be > 0");
  }
  this.context = vertx.getOrCreateContext();
  this.factory = new PgConnectionFactory(context, Vertx.currentContext() != null, options);
  this.pool = new ConnectionPool(factory::connect, maxSize);
  this.closeVertx = closeVertx;
}
 
開發者ID:vietj,項目名稱:reactive-pg-client,代碼行數:11,代碼來源:PgPoolImpl.java

示例9: getConnection

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Override
public void getConnection(Handler<AsyncResult<PgConnection>> handler) {
  Context current = Vertx.currentContext();
  if (current == context) {
    pool.acquire(new ConnectionWaiter(handler));
  } else {
    context.runOnContext(v -> getConnection(handler));
  }
}
 
開發者ID:vietj,項目名稱:reactive-pg-client,代碼行數:10,代碼來源:PgPoolImpl.java

示例10: verticleDeployed

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Override
public void verticleDeployed(Verticle verticle) {
    Context context = Vertx.currentContext();
    dispatch("verticleDeployed", listener -> listener.verticleDeployed(verticle, context));
}
 
開發者ID:unbroken-dome,項目名稱:vertx-spring,代碼行數:6,代碼來源:VertxListenerAwareMetricsFactory.java

示例11: verticleUndeployed

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Override
public void verticleUndeployed(Verticle verticle) {
    Context context = Vertx.currentContext();
    dispatch("verticleUndeployed", listener -> listener.verticleUndeployed(verticle, context));
}
 
開發者ID:unbroken-dome,項目名稱:vertx-spring,代碼行數:6,代碼來源:VertxListenerAwareMetricsFactory.java

示例12: setupCloseHook

import io.vertx.core.Vertx; //導入方法依賴的package包/類
private void setupCloseHook() {
  Context ctx = Vertx.currentContext();
  if (ctx != null && ctx.owner() == vertx) {
    ctx.addCloseHook(holder::close);
  }
}
 
開發者ID:pflima92,項目名稱:vertx-jpa,代碼行數:7,代碼來源:EntityManagerProviderImpl.java


注:本文中的io.vertx.core.Vertx.currentContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。