/** * Takes the event bus off the provided vert.x instance * * @param vertx the vertx instance with the event bus to wrap * @param container the container instance */ @Inject public DefaultWhenEventBus(Vertx vertx, Container container, When when) { this(vertx.eventBus(), when); }
/** Create HttpServer */ public RxHttpServer createHttpServer() { return new RxHttpServer(core.createHttpServer()); }
/** * Creates an HTTP/HTTPS client. */ public static HttpClient createHttpClient(Env env) { return new HttpClient(PhpVerticleFactory.vertx.createHttpClient()); }
public StaticFileHandler(Vertx vertx, String webRootPrefix, String indexPage, boolean gzipFiles, boolean caching) { super(); this.filePropsModified = vertx.sharedData().getMap("webserver.fileProps.modified"); this.fileSystem = vertx.fileSystem(); this.webRootPrefix = webRootPrefix; this.indexPage = indexPage; this.gzipFiles = gzipFiles; this.caching = caching; }
/** * {@inheritDoc} */ @Override public boolean suspend(long timeOut, TimeUnit timeUnit, TimeoutHandler timeoutHandler) { // TODO: If already suspended should return false according to documentation // Store the timeout handler this.timeoutHandler = timeoutHandler; // Cancel any existing timer if (suspendTimerId != 0) { vertx.cancelTimer(suspendTimerId); suspendTimerId = 0; } // If timeout <= 0, then it suspends indefinitely if (timeOut <= 0) { return true; } // Get milliseconds long ms = timeUnit.toMillis(timeOut); // Schedule timeout on the event loop this.suspendTimerId = vertx.setTimer(ms, new Handler<Long>() { @Override public void handle(Long id) { if (id == suspendTimerId) { VertxResponseWriter.this.timeoutHandler.onTimeout(VertxResponseWriter.this); } } }); return true; }
public static void main(String[] args) throws Exception { Vertx vertx = Vertx.newVertx(); HttpServer httpServer = vertx.createHttpServer(); DefaultSockJSServer sjsServer = (DefaultSockJSServer)vertx.createSockJSServer(httpServer); sjsServer.installTestApplications(); httpServer.listen(8081); Thread.sleep(Long.MAX_VALUE); }
/** * Constructor. * * @param httpPort The HTTP port on which the emulator should run. */ public EmulatorLaunchpad(int httpPort) { vertx = VertxFactory.newVertx(); // Static files HttpServer httpServer = vertx.createHttpServer(); httpServer.requestHandler(new WebResourceHandler()); // Eventbus bridge JsonObject bridgeConfig = new JsonObject().putString("prefix", EVENTBUS_ADDRESS); JsonArray credentialsPermitAll = new JsonArray().add(new JsonObject()); vertx.createSockJSServer(httpServer).bridge(bridgeConfig, credentialsPermitAll, credentialsPermitAll); vertx.eventBus().registerLocalHandler(EVENTBUS_SERVER_HANDLER_ID, eventBusHandler); System.out.println("Launchpad emulator is ready on http://localhost:" + httpPort + "/"); httpServer.listen(httpPort); }
Auth(final String sessionID, final SockJSSocket sock) { timerID = vertx.setTimer(authTimeout, new Handler<Long>() { public void handle(Long id) { uncacheAuthorisation(sessionID, sock); } }); }
/** * Creates a TCP/SSL server. */ public static NetServer createNetServer(Env env) { return new NetServer(PhpVerticleFactory.vertx.createNetServer()); }
manager = new HazelcastClusterManager(getHazelcastInstance()); } else { manager = new SharedDataClusterManager(vertx.sharedData()); vertx.eventBus().registerHandler(address, internalHandler, new Handler<AsyncResult<Void>>() { @Override public void handle(AsyncResult<Void> result) {
@Override public Subscription schedulePeriodically(final Action0 action, long initialDelay, final long delayTime, final TimeUnit unit) { // Use a bootstrap handler to start the periodic timer after initialDelay Handler bootstrap=new Handler<Long>() { public void handle(Long id) { action.call(); // Ensure still active if (innerSubscription.isUnsubscribed()) return; // Start the repeating timer timers.add(vertx.setPeriodic(unit.toMillis(delayTime),new Handler<Long>() { public void handle(Long nestedId) { if (innerSubscription.isUnsubscribed()) return; action.call(); } })); } }; long bootDelay=unit.toMillis(initialDelay); // If initialDelay is 0 then fire bootstrap immediately if (bootDelay<1) { vertx.runOnContext(bootstrap); } else { timers.add(vertx.setTimer(bootDelay,bootstrap)); } return this.innerSubscription; }
start(); HttpServer server = vertx.createHttpServer(); SockJSServer sjsServer = vertx.createSockJSServer(server); JsonArray inboundPermitted = getOptionalArrayConfig("inbound_permitted", new JsonArray()); JsonArray outboundPermitted = getOptionalArrayConfig("outbound_permitted", new JsonArray());
private void cancelTimer() { if (timeoutTimerID != -1) { vertx.cancelTimer(timeoutTimerID); } }
/** * Creates a TCP/SSL client. */ public static NetClient createNetClient(Env env) { return new NetClient(PhpVerticleFactory.vertx.createNetClient()); }
/** * Returns the Vertx FileSystem instance. */ public static FileSystem fileSystem(Env env) { return new FileSystem(PhpVerticleFactory.vertx.fileSystem()); }
/** * Creates a SockJS server. */ public static SockJSServer createSockJSServer(Env env, HttpServer server) { return new SockJSServer(PhpVerticleFactory.vertx.createSockJSServer(server.getVertxServer())); }
@Override public void execute() { timerRef.set(RxTimer.this.core.setTimer(delay,this)); } @Override public void handle(Long res) {
/** Create NetServer */ public RxNetServer createNetServer() { return new RxNetServer(core.createNetServer()); }
void cancel() { vertx.cancelTimer(timerID); }
/** Create NetClient */ public RxNetClient createNetClient() { return new RxNetClient(core.createNetClient()); }