当前位置: 首页>>代码示例>>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;未经允许,请勿转载。