本文整理匯總了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;
}