com.github.zhengframework.web.WebModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zheng-web Show documentation
Show all versions of zheng-web Show documentation
zheng framework module: web server
package com.github.zhengframework.web;
import com.github.zhengframework.configuration.ConfigurationAwareServletModule;
import com.github.zhengframework.configuration.ConfigurationBeanMapper;
import com.google.inject.TypeLiteral;
import com.google.inject.multibindings.OptionalBinder;
import java.util.Map;
import javax.websocket.server.ServerEndpointConfig;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@EqualsAndHashCode(callSuper = false, of = {})
public class WebModule extends ConfigurationAwareServletModule {
@Override
protected void configureServlets() {
Map configMap = ConfigurationBeanMapper
.resolve(getConfiguration(), WebConfig.class);
WebConfig webConfig = configMap.getOrDefault("", new WebConfig());
bind(WebConfig.class).toInstance(webConfig);
OptionalBinder
.newOptionalBinder(binder(), new TypeLiteral() {
});
OptionalBinder.newOptionalBinder(binder(), new TypeLiteral() {
});
requireBinding(WebServer.class);
bind(WebServerService.class).asEagerSingleton();
}
}