Package com.englishtown.vertx.jersey.examples

Source Code of com.englishtown.vertx.jersey.examples.StartupVerticle

package com.englishtown.vertx.jersey.examples;

import com.englishtown.vertx.jersey.promises.WhenJerseyServer;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;

import javax.inject.Inject;

/**
* {@link com.englishtown.vertx.jersey.promises.WhenJerseyServer} example
*/
public class StartupVerticle extends AbstractVerticle {

    private final WhenJerseyServer jerseyServer;

    @Inject
    public StartupVerticle(WhenJerseyServer jerseyServer) {
        this.jerseyServer = jerseyServer;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void start(Future<Void> startedResult) throws Exception {

        JsonObject jerseyConfig = vertx.context().config().getJsonObject("jersey");

        jerseyServer.createServer(jerseyConfig)
                .then(server -> {
                    startedResult.complete();
                    return null;
                })
                .otherwise(t -> {
                    startedResult.fail(t);
                    return null;
                });

    }
}
TOP

Related Classes of com.englishtown.vertx.jersey.examples.StartupVerticle

TOP
Copyright © 2018 www.massapi.com. 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.