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


Java Context.owner方法代碼示例

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


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

示例1: findByContext

import io.vertx.core.Context; //導入方法依賴的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: createClientPool

import io.vertx.core.Context; //導入方法依賴的package包/類
@Test
public void createClientPool(@Mocked Vertx vertx, @Mocked Context context, @Mocked HttpClient httpClient) {
  new Expectations(VertxImpl.class) {
    {
      VertxImpl.context();
      result = context;
      context.owner();
      result = vertx;
      vertx.createHttpClient(httpClientOptions);
      result = httpClient;
    }
  };
  HttpClientWithContext pool = factory.createClientPool();

  Assert.assertSame(context, pool.context());
  Assert.assertSame(httpClient, pool.getHttpClient());
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:18,代碼來源:TestHttpClientPoolFactory.java

示例3: findByContext_otherVertx

import io.vertx.core.Context; //導入方法依賴的package包/類
@Test
public void findByContext_otherVertx(@Mocked Vertx otherVertx, @Mocked Context otherContext) {
  HttpClientWithContext pool = new HttpClientWithContext(null, null);
  pools.add(pool);

  new Expectations(VertxImpl.class) {
    {
      VertxImpl.context();
      result = otherContext;
      otherContext.owner();
      result = otherVertx;
    }
  };

  Assert.assertSame(pool, poolMgr.findByContext());
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:17,代碼來源:TestClientPoolManager.java

示例4: findByContext_woker

import io.vertx.core.Context; //導入方法依賴的package包/類
@Test
public void findByContext_woker(@Mocked Context workerContext) {
  HttpClientWithContext pool = new HttpClientWithContext(null, null);
  pools.add(pool);

  new Expectations(VertxImpl.class) {
    {
      VertxImpl.context();
      result = workerContext;
      workerContext.owner();
      result = vertx;
      workerContext.isEventLoopContext();
      result = false;
    }
  };

  Assert.assertSame(pool, poolMgr.findByContext());
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:19,代碼來源:TestClientPoolManager.java

示例5: createClientPool

import io.vertx.core.Context; //導入方法依賴的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

示例6: currentVertx

import io.vertx.core.Context; //導入方法依賴的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: createClientPool

import io.vertx.core.Context; //導入方法依賴的package包/類
@Test
public void createClientPool(@Mocked Vertx vertx, @Mocked Context context) {
  new Expectations(VertxImpl.class) {
    {
      VertxImpl.context();
      result = context;
      context.owner();
      result = vertx;
    }
  };
  TcpClientConnectionPool pool = factory.createClientPool();

  Assert.assertSame(normalClientConfig, pool.netClientWrapper.getClientConfig(false));
  Assert.assertSame(sslClientConfig, pool.netClientWrapper.getClientConfig(true));
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:16,代碼來源:TestAbstractTcpClientPoolFactory.java

示例8: init

import io.vertx.core.Context; //導入方法依賴的package包/類
public static void init(Context vertxContext) {
    Constants.vertx = vertxContext.owner();
    Constants.vertxContext = vertxContext;
    JsonObject config = vertxContext.config();
    PROJ_URL = config.getString("projectUrl", "http://itq46u.natappfree.cc/");
    CERT_DIR = config.getString("certDir", "/home/leibniz/");
    JDBC_URL = config.getString("jdbcUrl", "jdbc:mysql://127.0.0.1:3306/fission?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false");
    JDBC_USER = config.getString("jdbcUser", "root");
    JDBC_PSWD = config.getString("jdbcPassword", "turingdi");
    JDBC_DRIVER = config.getString("jdbcDriver", "com.mysql.cj.jdbc.Driver");
}
 
開發者ID:Leibnizhu,項目名稱:AlipayWechatPlatform,代碼行數:12,代碼來源:Constants.java

示例9: getVertxFromContextOrNew

import io.vertx.core.Context; //導入方法依賴的package包/類
/**
 * Return the Vertx of the current context; if there isn't a current context
 * create and return a new Vertx using getVertxWithExceptionHandler().
 * @return the Vertx
 */
public static Vertx getVertxFromContextOrNew() {
  Context context = Vertx.currentContext();

  if (context == null) {
    return getVertxWithExceptionHandler();
  }

  return context.owner();
}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:15,代碼來源:VertxUtils.java

示例10: setupCloseHook

import io.vertx.core.Context; //導入方法依賴的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

示例11: ContextScheduler

import io.vertx.core.Context; //導入方法依賴的package包/類
public ContextScheduler(Context context, boolean blocking, boolean ordered) {
    this.vertx = context.owner();
    this.context = context;
    this.blocking = blocking;
    this.ordered = ordered;
}
 
開發者ID:pitchpoint-solutions,項目名稱:sfs,代碼行數:7,代碼來源:ContextScheduler.java


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