本文整理汇总了Java中org.springframework.boot.context.embedded.EmbeddedServletContainer类的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedServletContainer类的具体用法?Java EmbeddedServletContainer怎么用?Java EmbeddedServletContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EmbeddedServletContainer类属于org.springframework.boot.context.embedded包,在下文中一共展示了EmbeddedServletContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
Tomcat tomcat = new Tomcat();
File baseDir = (this.baseDirectory != null ? this.baseDirectory
: createTempDir("tomcat"));
tomcat.setBaseDir(baseDir.getAbsolutePath());
Connector connector = new Connector(this.protocol);
tomcat.getService().addConnector(connector);
customizeConnector(connector);
tomcat.setConnector(connector);
tomcat.getHost().setAutoDeploy(false);
tomcat.getEngine().setBackgroundProcessorDelay(-1);
for (Connector additionalConnector : this.additionalTomcatConnectors) {
tomcat.getService().addConnector(additionalConnector);
}
prepareContext(tomcat.getHost(), initializers);
return getTomcatEmbeddedServletContainer(tomcat);
}
示例2: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers) {
ClassLoader parentClassLoader = resourceLoader != null ? resourceLoader.getClassLoader() : ClassUtils.getDefaultClassLoader();
Package nettyPackage = Bootstrap.class.getPackage();
String title = nettyPackage.getImplementationTitle();
String version = nettyPackage.getImplementationVersion();
logger.info("Running with " + title + " " + version);
NettyEmbeddedContext context = new NettyEmbeddedContext(getContextPath(), new URLClassLoader(new URL[]{}, parentClassLoader), SERVER_INFO);
if (isRegisterDefaultServlet()) {
logger.warn("This container does not support a default servlet");
}
/*if (isRegisterJspServlet()) {
logger.warn("This container does not support a JSP servlet");
}*/
for (ServletContextInitializer initializer : initializers) {
try {
initializer.onStartup(context);
} catch (ServletException e) {
throw new RuntimeException(e);
}
}
int port = getPort() > 0 ? getPort() : new Random().nextInt(65535 - 1024) + 1024;
InetSocketAddress address = new InetSocketAddress(port);
logger.info("Server initialized with port: " + port);
return new NettyEmbeddedServletContainer(address, context);
}
示例3: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers) {
ClassLoader parentClassLoader = resourceLoader != null ? resourceLoader.getClassLoader() : ClassUtils.getDefaultClassLoader();
Package nettyPackage = Bootstrap.class.getPackage();
String title = nettyPackage.getImplementationTitle();
String version = nettyPackage.getImplementationVersion();
logger.info("Running with " + title + " " + version);
NettyEmbeddedContext context = new NettyEmbeddedContext(getContextPath(), new URLClassLoader(new URL[]{}, parentClassLoader), SERVER_INFO);
if (isRegisterDefaultServlet()) {
logger.warn("This container does not support a default servlet");
}
for (ServletContextInitializer initializer : initializers) {
try {
initializer.onStartup(context);
} catch (ServletException e) {
throw new RuntimeException(e);
}
}
int port = getPort() > 0 ? getPort() : new Random().nextInt(65535 - 1024) + 1024;
InetSocketAddress address = new InetSocketAddress(port);
logger.info("Server initialized with port: " + port);
return new NettyEmbeddedServletContainer(address, context);
}
示例4: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
Tomcat tomcat = new Tomcat();
File baseDir = (this.baseDirectory != null ? this.baseDirectory
: createTempDir("tomcat"));
tomcat.setBaseDir(baseDir.getAbsolutePath());
Connector connector = new Connector(this.protocol);
tomcat.getService().addConnector(connector);
customizeConnector(connector);
tomcat.setConnector(connector);
tomcat.getHost().setAutoDeploy(false);
configureEngine(tomcat.getEngine());
for (Connector additionalConnector : this.additionalTomcatConnectors) {
tomcat.getService().addConnector(additionalConnector);
}
prepareContext(tomcat.getHost(), initializers);
return getTomcatEmbeddedServletContainer(tomcat);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:TomcatEmbeddedServletContainerFactory.java
示例5: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
JettyEmbeddedWebAppContext context = new JettyEmbeddedWebAppContext();
int port = (getPort() >= 0 ? getPort() : 0);
InetSocketAddress address = new InetSocketAddress(getAddress(), port);
Server server = createServer(address);
configureWebAppContext(context, initializers);
server.setHandler(addHandlerWrappers(context));
this.logger.info("Server initialized with port: " + port);
if (getSsl() != null && getSsl().isEnabled()) {
SslContextFactory sslContextFactory = new SslContextFactory();
configureSsl(sslContextFactory, getSsl());
AbstractConnector connector = getSslServerConnectorFactory()
.getConnector(server, sslContextFactory, port);
server.setConnectors(new Connector[] { connector });
}
for (JettyServerCustomizer customizer : getServerCustomizers()) {
customizer.customize(server);
}
if (this.useForwardHeaders) {
new ForwardHeadersCustomizer().customize(server);
}
return getJettyEmbeddedServletContainer(server);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:JettyEmbeddedServletContainerFactory.java
示例6: getServicePort
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
private Integer getServicePort(EmbeddedWebApplicationContext webContext)
{
Integer port = null;
if (webContext != null)
{
final EmbeddedServletContainer container = webContext.getEmbeddedServletContainer();
if (container instanceof TomcatEmbeddedServletContainer)
{
// Work around an issue with the tomcat container, which uses the local port
// as the port (-1) instead of the registered port
port = ((TomcatEmbeddedServletContainer) container).getTomcat().getConnector().getPort();
}
else
{
port = container.getPort();
}
}
return port;
}
示例7: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers) {
ClassLoader parentClassLoader = resourceLoader != null ? resourceLoader.getClassLoader() : ClassUtils.getDefaultClassLoader();
Package nettyPackage = Bootstrap.class.getPackage();
String title = nettyPackage.getImplementationTitle();
String version = nettyPackage.getImplementationVersion();
logger.info("Running with " + title + " " + version);
NettyEmbeddedContext context = new NettyEmbeddedContext(getContextPath(), new URLClassLoader(new URL[]{}, parentClassLoader), SERVER_INFO);
if (isRegisterDefaultServlet()) {
logger.warn("This container does not support a default servlet");
}
if (isRegisterJspServlet()) {
logger.warn("This container does not support a JSP servlet");
}
for (ServletContextInitializer initializer : initializers) {
try {
initializer.onStartup(context);
} catch (ServletException e) {
throw new RuntimeException(e);
}
}
int port = getPort() > 0 ? getPort() : new Random().nextInt(65535 - 1024) + 1024;
InetSocketAddress address = new InetSocketAddress(port);
logger.info("Server initialized with port: " + port);
return new NettyEmbeddedServletContainer(address, context);
}
开发者ID:DanielThomas,项目名称:spring-boot-starter-netty,代码行数:27,代码来源:NettyEmbeddedServletContainerFactory.java
示例8: getManagerFromContext
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
private Manager getManagerFromContext(EmbeddedWebApplicationContext applicationContext) {
EmbeddedServletContainer embeddedServletContainer = applicationContext.getEmbeddedServletContainer();
if (embeddedServletContainer instanceof TomcatEmbeddedServletContainer) {
return getManagerFromContainer((TomcatEmbeddedServletContainer) embeddedServletContainer);
}
return null;
}
示例9: embeddedServletContainerMetricsInitializer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
/**
* Initialise the embedded servlet container metrics reporting.
*
* @return An ApplicationListener which will register a MetricsPublisher when the Servlet container is
* initialised
*/
@Bean
public ApplicationListener<EmbeddedServletContainerInitializedEvent> embeddedServletContainerMetricsInitializer() {
final MetricRegistry registry = codahaleMetricsRegistry();
return new ApplicationListener<EmbeddedServletContainerInitializedEvent>() {
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent embeddedServletContainerInitializedEvent) {
EmbeddedServletContainer initializedServletContainer = embeddedServletContainerInitializedEvent.getEmbeddedServletContainer();
if (initializedServletContainer == null) {
LOGGER.error("The EmbeddedServletContainer obtained from the EmbeddedServletContainerInitializedEvent was null; metrics will not be published");
return;
}
int serverPort = initializedServletContainer.getPort();
LOGGER.info("Initialising MetricsPublisher on port {}", serverPort);
TomcatMetricsPublisher.forRegistry(registry)
.serverPortIs(serverPort)
.start();
// register the graphite reporter
Statsd statsd = new Statsd(metricsReporterHost, metricsReporterPort);
StatsdReporter statsdReporter = StatsdReporter.forRegistry(registry)
.prefixedWith(metricsPrefix + serverPort)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.convertRatesTo(TimeUnit.SECONDS)
.filter(new ConfigurableCodaHaleMetricFilter(DynamicPropertyFactory.getInstance()))
.build(statsd);
statsdReporter.start(pollingPeriodInSeconds, TimeUnit.SECONDS);
}
};
}
开发者ID:andrewharmellaw,项目名称:springboot-camel-metrics-publisher,代码行数:45,代码来源:MetricsServletConfiguration.java
示例10: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
DeploymentManager manager = createDeploymentManager(initializers);
int port = getPort();
Builder builder = createBuilder(port);
return getUndertowEmbeddedServletContainer(builder, manager, port);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:UndertowEmbeddedServletContainerFactory.java
示例11: getManager
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
private Manager getManager(EmbeddedWebApplicationContext applicationContext) {
EmbeddedServletContainer embeddedServletContainer = applicationContext
.getEmbeddedServletContainer();
if (embeddedServletContainer instanceof TomcatEmbeddedServletContainer) {
return getManager((TomcatEmbeddedServletContainer) embeddedServletContainer);
}
return null;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:TomcatPublicMetrics.java
示例12: mockEvent
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
private EmbeddedServletContainerInitializedEvent mockEvent(String name, int port) {
EmbeddedWebApplicationContext applicationContext = mock(
EmbeddedWebApplicationContext.class);
EmbeddedServletContainer source = mock(EmbeddedServletContainer.class);
given(applicationContext.getNamespace()).willReturn(name);
given(source.getPort()).willReturn(port);
EmbeddedServletContainerInitializedEvent event = new EmbeddedServletContainerInitializedEvent(
applicationContext, source);
return event;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:EmbeddedServerPortFileWriterTests.java
示例13: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
this.container = new MockEmbeddedServletContainer(
mergeInitializers(initializers), getPort());
return this.container;
}
示例14: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
DeploymentManager manager = createDeploymentManager(initializers);
int port = getPort();
Builder builder = createBuilder(port);
return new UndertowEmbeddedServletContainer(builder, manager, getContextPath(),
port, this.useForwardHeaders, port >= 0, getCompression());
}
示例15: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainer; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
ServletContextInitializer... initializers) {
JettyEmbeddedWebAppContext context = new JettyEmbeddedWebAppContext();
int port = (getPort() >= 0 ? getPort() : 0);
Server server = new Server(new InetSocketAddress(getAddress(), port));
configureWebAppContext(context, initializers);
if (getCompression() != null && getCompression().getEnabled()) {
HandlerWrapper gzipHandler = createGzipHandler();
gzipHandler.setHandler(context);
server.setHandler(gzipHandler);
}
else {
server.setHandler(context);
}
this.logger.info("Server initialized with port: " + port);
if (getSsl() != null && getSsl().isEnabled()) {
SslContextFactory sslContextFactory = new SslContextFactory();
configureSsl(sslContextFactory, getSsl());
AbstractConnector connector = getSslServerConnectorFactory()
.getConnector(server, sslContextFactory, port);
server.setConnectors(new Connector[] { connector });
}
for (JettyServerCustomizer customizer : getServerCustomizers()) {
customizer.customize(server);
}
if (this.useForwardHeaders) {
new ForwardHeadersCustomizer().customize(server);
}
return getJettyEmbeddedServletContainer(server);
}