本文整理匯總了Java中io.vertx.core.Vertx.getOrCreateContext方法的典型用法代碼示例。如果您正苦於以下問題:Java Vertx.getOrCreateContext方法的具體用法?Java Vertx.getOrCreateContext怎麽用?Java Vertx.getOrCreateContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.vertx.core.Vertx
的用法示例。
在下文中一共展示了Vertx.getOrCreateContext方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: BinlogClientImpl
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public BinlogClientImpl(Vertx vertx, BinlogClientOptions options) {
this.vertx = vertx;
this.context = vertx.getOrCreateContext();
this.host = options.getHost();
this.port = options.getPort();
this.connectTimeout = options.getConnectTimeout();
this.sqlClient = MySQLClient.createNonShared(vertx,
new JsonObject()
.put("host", options.getHost())
.put("port", options.getPort())
.put("database", "information_schema")
.put("maxPoolSize", 1)
.put("username", options.getUsername())
.put("password",
"".equals(options.getPassword()) ?
null : options.getPassword())
);
dispatcher = new EventDispatcher(vertx,
new SchemaResolver(sqlClient));
client = new BinaryLogClient(
host, port,
options.getUsername(),
Optional.ofNullable(
options.getPassword()
).orElse("")
);
if (options.getFilename() != null) {
client.setBinlogFilename(options.getFilename());
}
if (options.getPosition() != -1) {
client.setBinlogPosition(options.getPosition());
}
client.setHeartbeatInterval(options.getHeartbeatInterval());
client.setKeepAlive(options.isKeepAlive());
client.setKeepAliveInterval(options.getKeepAliveInterval());
client.registerEventListener(this::handle);
}