當前位置: 首頁>>代碼示例>>Java>>正文


Java EmbeddedServletContainerCustomizer類代碼示例

本文整理匯總了Java中org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer的典型用法代碼示例。如果您正苦於以下問題:Java EmbeddedServletContainerCustomizer類的具體用法?Java EmbeddedServletContainerCustomizer怎麽用?Java EmbeddedServletContainerCustomizer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EmbeddedServletContainerCustomizer類屬於org.springframework.boot.context.embedded包,在下文中一共展示了EmbeddedServletContainerCustomizer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: purgeAccessLogCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
/**
 * Purge access log customizer embedded servlet container customizer.
 *
 * @param serverProperties the server properties
 * @param purgeProperties  the purge properties
 * @return the embedded servlet container customizer
 */
@Bean
public EmbeddedServletContainerCustomizer purgeAccessLogCustomizer(
        final ServerProperties serverProperties,
        final PurgeProperties purgeProperties) {
    return container -> {
        final UndertowEmbeddedServletContainerFactory factory = (UndertowEmbeddedServletContainerFactory)
                container;
        final Undertow.Accesslog accesslog = serverProperties.getUndertow()
                .getAccesslog();
        final UndertowPurgeAccessLogHolder accessLogHolder = new UndertowPurgeAccessLogHolder(
                purgeProperties, accesslog.getDir().toPath(),
                accesslog.getPrefix(), accesslog.getSuffix());
        factory.addDeploymentInfoCustomizers(accessLogHolder);
    };
}
 
開發者ID:marcosbarbero,項目名稱:spring-boot-starter-purge-accesslog,代碼行數:23,代碼來源:PurgeAccessLogAutoConfiguration.java

示例2: containerCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {

    return (container -> {
        ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
        ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
        ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");

        container.addErrorPages(error401Page, error404Page, error500Page);
    });
}
 
開發者ID:ChinaLHR,項目名稱:JavaQuarkBBS,代碼行數:12,代碼來源:AdminApplication.java

示例3: cookieProcessorCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer cookieProcessorCustomizer() {
    return new EmbeddedServletContainerCustomizer() {
        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            if (container instanceof TomcatEmbeddedServletContainerFactory) {
                TomcatEmbeddedServletContainerFactory factory = (TomcatEmbeddedServletContainerFactory) container;
                factory.addContextCustomizers(new TomcatContextCustomizer() {
                    @Override
                    public void customize(Context context) {
                        context.setCookieProcessor(new LegacyCookieProcessor());
                    }                        
                });
            }
        }

    };
}
 
開發者ID:intuit,項目名稱:karate,代碼行數:19,代碼來源:TomcatConfig.java

示例4: embeddedServletContainerCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
@Profile("!docker")
public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer() {
    return (container -> {

        container.setContextPath(lyreProperties.getContextPath());

        if (!lyreProperties.isEnableRemoteConnections()) {
            try {
                InetAddress inetAddress = InetAddress.getByAddress(new byte[]{127, 0, 0, 1});
                container.setAddress(inetAddress);
            } catch (UnknownHostException e) {
                //supressed exception
            }
        }

        container.setPort(lyreProperties.getPort());
    });
}
 
開發者ID:groovylabs,項目名稱:lyre,代碼行數:20,代碼來源:Lyre.java

示例5: embeddedServletContainerTest

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer embeddedServletContainerTest() {
    return (container -> {

        lyreProperties.setPort(8080);

        container.setContextPath(lyreProperties.getContextPath());

        if (!lyreProperties.isEnableRemoteConnections()) {
            try {
                InetAddress inetAddress = InetAddress.getByAddress(new byte[]{127, 0, 0, 1});
                container.setAddress(inetAddress);
            } catch (UnknownHostException e) {
                //supressed exception
            }
        }

        container.setPort(lyreProperties.getPort());
    });
}
 
開發者ID:groovylabs,項目名稱:lyre,代碼行數:21,代碼來源:DockerConfiguration.java

示例6: containerCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
    public EmbeddedServletContainerCustomizer containerCustomizer() {
        return new EmbeddedServletContainerCustomizer() {
            @Override
            public void customize(ConfigurableEmbeddedServletContainer container) {
                ErrorPage page404 = new ErrorPage(HttpStatus.NOT_FOUND,"/404");
                container.addErrorPages(page404);
            }
        };
//        return (container -> {
//            ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
//            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
//            ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
//
//            container.addErrorPages(error401Page, error404Page, error500Page);
//        });
    }
 
開發者ID:baidao,項目名稱:tinker-manager,代碼行數:18,代碼來源:WebAppConfig.java

示例7: embeddedServletContainerCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer() {
    return new EmbeddedServletContainerCustomizer() {
        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            if (container instanceof TomcatEmbeddedServletContainerFactory) {
                TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory = (TomcatEmbeddedServletContainerFactory) container;
                
                
                RedisSessionHandlerValve valve = new RedisSessionHandlerValve();
                List<RedisSessionHandlerValve> valves = 
                		new ArrayList<RedisSessionHandlerValve>();
                valves.add(0, valve);
                tomcatEmbeddedServletContainerFactory.setContextValves(valves);
                tomcatEmbeddedServletContainerFactory.setPort(28080);    // Set the port of embeded tomcat as 28080 for default. 
 
                System.out.println("Enterring EmbeddedServletContainerCustomizer.customize()...");
                tomcatEmbeddedServletContainerFactory.addContextCustomizers(
                		new ServletContainerCustomizer());
            }
        }
    };
}
 
開發者ID:xiaowing,項目名稱:various_demos,代碼行數:24,代碼來源:Application.java

示例8: embeddedServletContainerCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer() {
    return new EmbeddedServletContainerCustomizer() {
    	@Value("${application.port}")
    	private int embeddedServletContainerListenPort;
    	
        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            if (container instanceof TomcatEmbeddedServletContainerFactory) {
                TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory = 
                		(TomcatEmbeddedServletContainerFactory) container;
                if (embeddedServletContainerListenPort <= 1024 ||  embeddedServletContainerListenPort > 65535) {
                	throw new IllegalArgumentException("The value of \"application.port\" in the properties file is invalid.");
                }
                
                tomcatEmbeddedServletContainerFactory.setPort(embeddedServletContainerListenPort);
            }
        }
    };
}
 
開發者ID:xiaowing,項目名稱:various_demos,代碼行數:21,代碼來源:EmbeddedTomcatConfig.java

示例9: servletContainerCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer()
{
	return new EmbeddedServletContainerCustomizer()
	{
		@Override
		public void customize(final ConfigurableEmbeddedServletContainer servletContainer)
		{
			final TomcatEmbeddedServletContainerFactory tomcatContainerFactory = (TomcatEmbeddedServletContainerFactory)servletContainer;
			tomcatContainerFactory.addConnectorCustomizers(new TomcatConnectorCustomizer()
			{
				@Override
				public void customize(final Connector connector)
				{
					final AbstractHttp11Protocol<?> httpProtocol = (AbstractHttp11Protocol<?>)connector.getProtocolHandler();
					httpProtocol.setCompression("on");
					httpProtocol.setCompressionMinSize(256);
					final String mimeTypes = httpProtocol.getCompressibleMimeType();
					final String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE + ",application/javascript";
					httpProtocol.setCompressibleMimeType(mimeTypesWithJson);
				}
			});
		}
	};
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:26,代碼來源:WebRestApiApplication.java

示例10: servletContainerCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
@Autowired
public EmbeddedServletContainerCustomizer servletContainerCustomizer(ServerProperties properties) {
    return container -> {
        if (container instanceof JettyEmbeddedServletContainerFactory) {
            JettyEmbeddedServletContainerFactory jettyContainer = (JettyEmbeddedServletContainerFactory) container;
            jettyContainer.addConfigurations(new AbstractConfiguration() {

                @Override
                public void configure(WebAppContext context) throws Exception {
                    properties.getContextParameters().forEach((k, v) -> context.setInitParameter(k, v));
                }
            });
        }
    };
}
 
開發者ID:HeroXXiv,項目名稱:Robocode,代碼行數:17,代碼來源:AppConfig.java

示例11: containerCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
/**
 * Container customizer. Configures the embedded tomcat (e.g. post size)
 *
 * @return the embedded servlet container customizer
 * @throws Exception the exception
 */
@Bean 
public EmbeddedServletContainerCustomizer containerCustomizer(
        ) throws Exception {
 
      
      return new EmbeddedServletContainerCustomizer() {
		@Override
		public void customize(ConfigurableEmbeddedServletContainer container) {

		      if (container instanceof TomcatEmbeddedServletContainerFactory) {

		          TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
		          tomcat.addConnectorCustomizers(
		                  new TomcatConnectorCustomizer() {
							@Override
							public void customize(Connector connector) {
								  connector.setMaxPostSize(20000000);//20MB
							  }
						}
		          );
		      }
		  }
	};
  }
 
開發者ID:andju,項目名稱:findlunch,代碼行數:31,代碼來源:Beans.java

示例12: disableServerHeader

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer disableServerHeader() {
    return container -> {
        if (container instanceof JettyEmbeddedServletContainerFactory) {
            ((JettyEmbeddedServletContainerFactory) container).addServerCustomizers(new JettyServerCustomizer() {
                @Override
                public void customize(Server server) {
                    for (Connector connector : server.getConnectors()) {
                        if (connector instanceof ServerConnector) {
                            HttpConnectionFactory connectionFactory = connector.getConnectionFactory(HttpConnectionFactory.class);
                            connectionFactory.getHttpConfiguration().setSendServerVersion(false);
                        }
                    }
                }
            });
        }
    };
}
 
開發者ID:AusDTO,項目名稱:citizenship-appointment-server,代碼行數:19,代碼來源:AppConfig.java

示例13: servletContainerCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer() {
    return servletContainer -> {
        addMimeMappingsForFonts(servletContainer);

        TomcatEmbeddedServletContainerFactory container = (TomcatEmbeddedServletContainerFactory) servletContainer;

        container.setRegisterJspServlet(false);

        container.addContextCustomizers(customizer -> customizer.addWelcomeFile("index.html"));
        container.addConnectorCustomizers(
                connector -> {
                    AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler();
                    httpProtocol.setCompression("on");
                    httpProtocol.setCompressionMinSize(256);
                    httpProtocol.setCompressableMimeTypes(COMPRESSIBLE_MEDIA_TYPES);
                }
        );
    };
}
 
開發者ID:servicosgovbr,項目名稱:portal-de-servicos,代碼行數:21,代碼來源:ServletContainerConfig.java

示例14: customizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer customizer() {
    return new EmbeddedServletContainerCustomizer() {

        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
            TomcatContextCustomizer contextCustomizer = new TomcatContextCustomizer() {

                @Override
                public void customize(Context context) {
                    context.setCookieProcessor(new LegacyCookieProcessor());
                }
            };
            tomcat.addContextCustomizers(contextCustomizer);
        }
    };
}
 
開發者ID:mkopylec,項目名稱:recaptcha-spring-boot-starter,代碼行數:19,代碼來源:TestApplication.java

示例15: servletContainerCustomizer

import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer(){
	return configurableEmbeddedServletContainer -> 
			((TomcatEmbeddedServletContainerFactory) configurableEmbeddedServletContainer).addConnectorCustomizers(
			new TomcatConnectorCustomizer() {
				@Override
				public void customize(Connector connector) {
					AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler();
					httpProtocol.setCompression("on");
					httpProtocol.setCompressionMinSize(256);
					String mimeTypes = httpProtocol.getCompressableMimeTypes();
					String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE;
					httpProtocol.setCompressableMimeTypes(mimeTypesWithJson);
				}
			}
	);
}
 
開發者ID:oncoblocks,項目名稱:centromere,代碼行數:18,代碼來源:WebServicesConfig.java


注:本文中的org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。