Package org.vertx.java.core.impl

Examples of org.vertx.java.core.impl.DefaultFutureResult


     * method in order to provide special Vert.x instance.
     * @return
     */
    protected Vertx createVertx(VertxEndpointConfiguration endpointConfiguration) {
        final Vertx[] vertx = new Vertx[1];
        final Future loading = new DefaultFutureResult();

        Handler<AsyncResult<Vertx>> asyncLoadingHandler = new Handler<AsyncResult<Vertx>>() {
            @Override
            public void handle(AsyncResult<Vertx> event) {
                vertx[0] = event.result();
                loading.setResult(Boolean.TRUE);
                log.info("Vert.x instance successfully started");
            }
        };

        if (endpointConfiguration.getPort() > 0) {
            log.info(String.format("Creating new Vert.x instance '%s:%s' ...", endpointConfiguration.getHost(), endpointConfiguration.getPort()));
            VertxFactory.newVertx(endpointConfiguration.getPort(), endpointConfiguration.getHost(), asyncLoadingHandler);
        } else {
            log.info(String.format("Creating new Vert.x instance '%s:%s' ...", endpointConfiguration.getHost(), 0L));
            VertxFactory.newVertx(0, endpointConfiguration.getHost(), asyncLoadingHandler);
        }

        // Wait for full loading
        while (!loading.complete()) {
            try {
                log.debug("Waiting for Vert.x instance to startup");
                Thread.sleep(250L);
            } catch (InterruptedException e) {
                log.warn("Interrupted while waiting for Vert.x instance startup", e);
View Full Code Here

TOP

Related Classes of org.vertx.java.core.impl.DefaultFutureResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.