All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lontime.exthttp.container.ServerContainer Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.github.lontime.exthttp.container;

import java.util.List;
import java.util.concurrent.ExecutorService;

import com.github.lontime.base.commonj.components.AbstractLifecycle;
import com.github.lontime.base.commonj.utils.CollectionHelper;
import com.github.lontime.base.commonj.utils.CommonManager;
import com.github.lontime.exthttp.configuration.ServerOption;
import com.github.lontime.exthttp.configuration.OptionResolver;

/**
 * ServerContainer.
 * @author lontime
 * @since 1.0
 */
public class ServerContainer extends AbstractLifecycle {

    private HttpServerService httpServerService;

    public ServerContainer() {
        this.httpServerService = new HttpServerService();
    }

    @Override
    public void initialize() {
        final List serverOptions = OptionResolver.getInstance().getServerOptions();
        if (CollectionHelper.isEmpty(serverOptions)) {
            return;
        }
        final ExecutorService executorService = CommonManager.getInstance()
                .getExecutorService("reactor-netty-http-service", serverOptions.size());
        httpServerService.setExecutorService(executorService);
        httpServerService.initialize();
    }

    @Override
    public void start() {
        httpServerService.start();
    }

    @Override
    public void stop() {
        httpServerService.stop();
    }

    public DisposableServerWrapper getServer(String name) {
        return httpServerService.getServer(name);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy