private DefaultQueryCompiler createQueryCompiler() { JsonObject config = vertx.getOrCreateContext().config(); String cls = config.getString(ConfigConstants.QUERY_COMPILER_CLASS, DefaultQueryCompiler.class.getName()); try { return (DefaultQueryCompiler)Class.forName(cls).newInstance(); } catch (ReflectiveOperationException e) { throw new RuntimeException("Could not create a DefaultQueryCompiler", e); } }
public static Context newInstance(io.vertx.core.Context arg) { return arg != null ? new Context(arg) : null; } }
/** * Create a scheduler for a {@link Context}, actions are executed on the event loop of this context. * * @param context the context object * @return the scheduler */ public static Scheduler scheduler(Context context) { return new ContextScheduler(context.getDelegate(), false); }
/** * Invoke {@link io.vertx.rxjava.core.Context#executeBlocking} with order = true. * @param blockingCodeHandler handler representing the blocking code to run * @return * @deprecated use {@link #rxExecuteBlocking} instead */ @Deprecated() public <T> Observable<T> executeBlockingObservable(Handler<io.vertx.rxjava.core.Future<T>> blockingCodeHandler) { io.vertx.rx.java.ObservableFuture<T> resultHandler = io.vertx.rx.java.RxHelper.observableFuture(); executeBlocking(blockingCodeHandler, resultHandler.toHandler()); return resultHandler; }
/** * Gets the current context * @return The current context or null if no current context */ public static io.vertx.rxjava.core.Context currentContext() { io.vertx.rxjava.core.Context ret = io.vertx.rxjava.core.Context.newInstance(io.vertx.core.Vertx.currentContext()); return ret; }
/** * Invoke {@link io.vertx.rxjava.core.Context#executeBlocking} with order = true. * @param blockingCodeHandler handler representing the blocking code to run * @return */ public <T> Single<T> rxExecuteBlocking(Handler<io.vertx.rxjava.core.Future<T>> blockingCodeHandler) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { executeBlocking(blockingCodeHandler, fut); })); }
/** * Gets the current context, or creates one if there isn't one * @return The current context (created if didn't exist) */ public io.vertx.rxjava.core.Context getOrCreateContext() { io.vertx.rxjava.core.Context ret = io.vertx.rxjava.core.Context.newInstance(delegate.getOrCreateContext()); return ret; }
private DefaultQueryCompiler createQueryCompiler() { JsonObject config = vertx.getOrCreateContext().config(); String cls = config.getString(ConfigConstants.QUERY_COMPILER_CLASS, DefaultQueryCompiler.class.getName()); try { return (DefaultQueryCompiler)Class.forName(cls).newInstance(); } catch (ReflectiveOperationException e) { throw new RuntimeException("Could not create a DefaultQueryCompiler", e); } }
/** * Invoke {@link io.vertx.rxjava.core.Context#executeBlocking} with order = true. * @param blockingCodeHandler handler representing the blocking code to run * @return */ public <T> Single<T> rxExecuteBlocking(Handler<io.vertx.rxjava.core.Future<T>> blockingCodeHandler) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { executeBlocking(blockingCodeHandler, fut); })); }
/** * Create a scheduler hook for a {@link io.vertx.rxjava.core.Context} object. * * @param context the context object * @return the scheduler hook */ public static RxJavaSchedulersHook schedulerHook(Context context) { return io.vertx.rx.java.RxHelper.schedulerHook(context.getDelegate()); }
/** * Gets the current context, or creates one if there isn't one * @return The current context (created if didn't exist) */ public io.vertx.rxjava.core.Context getOrCreateContext() { io.vertx.rxjava.core.Context ret = io.vertx.rxjava.core.Context.newInstance(delegate.getOrCreateContext()); return ret; }
public static Context newInstance(io.vertx.core.Context arg) { return arg != null ? new Context(arg) : null; } }
private static Observable<HttpServer> setupMockEndpoint() { JsonObject config = vertx.getOrCreateContext().config(); String host = config.getString(ConfigConstants.HOST, ConfigConstants.DEFAULT_HOST); int port = config.getInteger(ConfigConstants.PORT, ConfigConstants.DEFAULT_PORT); HttpServerOptions serverOptions = new HttpServerOptions().setCompressionSupported(true); HttpServer server = vertxCore.createHttpServer(serverOptions); ObservableFuture<HttpServer> observable = RxHelper.observableFuture(); server.requestHandler(getStoreEndpointRouter()::accept).listen(port, host, observable.toHandler()); return observable; }
public <T> Observable<T> executeBlockingObservable(Handler<io.vertx.rxjava.core.Future<T>> blockingCodeHandler, boolean ordered) { io.vertx.rx.java.ObservableFuture<T> resultHandler = io.vertx.rx.java.RxHelper.observableFuture(); executeBlocking(blockingCodeHandler, ordered, resultHandler.toHandler()); return resultHandler;
/** * Create a scheduler for a {@link Context}, actions are executed on the event loop of this context. * * @param context the context object * @return the scheduler */ public static Scheduler scheduler(Context context) { return new ContextScheduler(context.getDelegate(), false); }
/** * Gets the current context * @return The current context or null if no current context */ public static io.vertx.rxjava.core.Context currentContext() { io.vertx.rxjava.core.Context ret = io.vertx.rxjava.core.Context.newInstance(io.vertx.core.Vertx.currentContext()); return ret; }
/** * Creates a HttpClient to do requests against the server. No SSL is used. * @return a client that's preconfigured for requests to the server. */ private static HttpClient createHttpClient() { HttpClientOptions options = new HttpClientOptions() .setDefaultHost(vertx.getOrCreateContext().config().getString(ConfigConstants.HOST)) .setDefaultPort(vertx.getOrCreateContext().config().getInteger(ConfigConstants.PORT)) .setSsl(false); return vertxCore.createHttpClient(options); }
/** * Safely execute some blocking code. * <p> * Executes the blocking code in the handler <code>blockingCodeHandler</code> using a thread from the worker pool. * <p> * When the code is complete the handler <code>resultHandler</code> will be called with the result on the original context * (e.g. on the original event loop of the caller). * <p> * A <code>Future</code> instance is passed into <code>blockingCodeHandler</code>. When the blocking code successfully completes, * the handler should call the {@link io.vertx.rxjava.core.Future#complete} or {@link io.vertx.rxjava.core.Future#complete} method, or the {@link io.vertx.rxjava.core.Future#fail} * method if it failed. * <p> * The blocking code should block for a reasonable amount of time (i.e no more than a few seconds). Long blocking operations * or polling operations (i.e a thread that spin in a loop polling events in a blocking fashion) are precluded. * <p> * When the blocking operation lasts more than the 10 seconds, a message will be printed on the console by the * blocked thread checker. * <p> * Long blocking operations should use a dedicated thread managed by the application, which can interact with * verticles using the event-bus or {@link io.vertx.rxjava.core.Context#runOnContext} * @param blockingCodeHandler handler representing the blocking code to run * @param ordered if true then if executeBlocking is called several times on the same context, the executions for that context will be executed serially, not in parallel. if false then they will be no ordering guarantees * @return */ public <T> Single<T> rxExecuteBlocking(Handler<io.vertx.rxjava.core.Future<T>> blockingCodeHandler, boolean ordered) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { executeBlocking(blockingCodeHandler, ordered, fut); })); }
/** * Create a scheduler hook for a {@link io.vertx.rxjava.core.Context} object. * * @param context the context object * @return the scheduler hook */ public static RxJavaSchedulersHook schedulerHook(Context context) { return io.vertx.rx.java.RxHelper.schedulerHook(context.getDelegate()); }
JsonObject config = vertx.getOrCreateContext().config();