Java Code Examples for io.vertx.core.impl.ContextInternal#owner()
The following examples show how to use
io.vertx.core.impl.ContextInternal#owner() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestHttpClientPoolFactory.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@Test public void createClientPool(@Mocked VertxInternal vertx, @Mocked ContextInternal context, @Mocked HttpClient httpClient) { new Expectations(VertxImpl.class) { { context.owner(); result = vertx; vertx.createHttpClient(httpClientOptions); result = httpClient; } }; HttpClientWithContext pool = factory.createClientPool(context); Assert.assertSame(context, pool.context()); Assert.assertSame(httpClient, pool.getHttpClient()); }
Example 2
Source File: PgConnectionImpl.java From vertx-sql-client with Apache License 2.0 | 5 votes |
public static Future<PgConnection> connect(ContextInternal context, PgConnectOptions options) { if (options.isUsingDomainSocket() && !context.owner().isNativeTransportEnabled()) { return context.failedFuture("Native transport is not available"); } else { PgConnectionFactory client = new PgConnectionFactory(context.owner(), context, options); return client.connect() .map(conn -> { QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), options); PgConnectionImpl pgConn = new PgConnectionImpl(client, context, conn, tracer, null); conn.init(pgConn); return pgConn; }); } }
Example 3
Source File: PgPoolImpl.java From vertx-sql-client with Apache License 2.0 | 5 votes |
public static PgPoolImpl create(ContextInternal context, boolean closeVertx, PgConnectOptions connectOptions, PoolOptions poolOptions) { QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), connectOptions); VertxMetrics vertxMetrics = context.owner().metricsSPI(); ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(connectOptions.getSocketAddress(), "sql", connectOptions.getMetricsName()) : null; PgPoolImpl pool = new PgPoolImpl(context, new PgConnectionFactory(context.owner(), context, connectOptions), tracer, metrics, poolOptions); CloseFuture closeFuture = pool.closeFuture(); if (closeVertx) { closeFuture.onComplete(ar -> context.owner().close()); } else { context.addCloseHook(closeFuture); } return pool; }
Example 4
Source File: PoolBase.java From vertx-sql-client with Apache License 2.0 | 5 votes |
public PoolBase(ContextInternal context, ConnectionFactory factory, QueryTracer tracer, ClientMetrics metrics, PoolOptions poolOptions) { super(tracer, metrics); this.vertx = context.owner(); this.factory = factory; this.pool = new ConnectionPool(factory, context, poolOptions.getMaxSize(), poolOptions.getMaxWaitQueueSize()); this.closeFuture = new CloseFuture(this); }
Example 5
Source File: SubsOpSerializer.java From vertx-hazelcast with Apache License 2.0 | 5 votes |
public static SubsOpSerializer get(ContextInternal context) { ConcurrentMap<Object, Object> contextData = context.contextData(); SubsOpSerializer instance = (SubsOpSerializer) contextData.get(SubsOpSerializer.class); if (instance == null) { SubsOpSerializer candidate = new SubsOpSerializer(context.owner()); SubsOpSerializer previous = (SubsOpSerializer) contextData.putIfAbsent(SubsOpSerializer.class, candidate); instance = previous == null ? candidate : previous; } return instance; }