本文整理汇总了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();
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
示例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();
}
示例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");
}
示例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();
}
示例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);
}
}
示例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;
}