org.springframework.boot.context.embedded.MimeMappings Java Examples

The following examples show how to use org.springframework.boot.context.embedded.MimeMappings. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebConfigurer.java    From flair-engine with Apache License 2.0 6 votes vote down vote up
/**
 * Customize the Servlet engine: Mime types, the document root, the cache.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);
    // When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets.
    setLocationForStaticAssets(container);

    /*
     * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288
     * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1.
     * See the JHipsterProperties class and your application-*.yml configuration files
     * for more information.
     */
    if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) &&
        container instanceof UndertowEmbeddedServletContainerFactory) {

        ((UndertowEmbeddedServletContainerFactory) container)
            .addBuilderCustomizers(builder ->
                builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
    }
}
 
Example #2
Source File: WebConfigurer.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
/**
 * Set up Mime types.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);
}
 
Example #3
Source File: WebConfigurer.java    From demo-spring-security-cas with Apache License 2.0 5 votes vote down vote up
/**
 * Set up Mime types.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
	MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
	// IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
	mappings.add("html", "text/html;charset=utf-8");
	// CloudFoundry issue, see
	// https://github.com/cloudfoundry/gorouter/issues/64
	mappings.add("json", "text/html;charset=utf-8");
	container.setMimeMappings(mappings);
}
 
Example #4
Source File: WebConfigurer.java    From expper with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set up Mime types.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);
}
 
Example #5
Source File: App.java    From bluemix-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    //Enabled UTF-8 as the default character encoding for static HTML resources.
    //If you would like to disable this comment out the 3 lines below or change
    //the encoding to whatever you would like.
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    mappings.add("html", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);
}
 
Example #6
Source File: WebConfigurer.java    From ServiceCutter with Apache License 2.0 5 votes vote down vote up
/**
 * Set up Mime types.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);
}
 
Example #7
Source File: WebConfigurer.java    From angularjs-springboot-bookstore with MIT License 5 votes vote down vote up
/**
 * Set up Mime types.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);
}
 
Example #8
Source File: ServletContainerConfig.java    From portal-de-servicos with MIT License 5 votes vote down vote up
private void addMimeMappingsForFonts(ConfigurableEmbeddedServletContainer servletContainer) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    mappings.add("eot", "application/vnd.ms-fontobject");
    mappings.add("ttf", "application/font-sfnt");
    mappings.add("otf", "application/font-sfnt");
    mappings.add("woff", "application/font-woff");
    mappings.add("woff2", "application/font-woff");
    servletContainer.setMimeMappings(mappings);
}
 
Example #9
Source File: PlatformWebFontMimeMapper.java    From abixen-platform with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
	MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
	mappings.add("woff", "application/font-woff");
	mappings.add("woff2", "application/font-woff2");
	mappings.add("ttf", "application/x-font-truetype");
	mappings.add("eot", "application/vnd.ms-fontobject");
	mappings.add("svg", "image/svg+xml");
	mappings.add("otf", "application/x-font-opentype");
	container.setMimeMappings(mappings);
}
 
Example #10
Source File: WebConfigurer.java    From OpenIoE with Apache License 2.0 5 votes vote down vote up
/**
 * Set up Mime types and, if needed, set the document root.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);

    // When running in an IDE or with ./gradlew bootRun, set location of the static web assets.
    setLocationForStaticAssets(container);
}
 
Example #11
Source File: WebConfigurer.java    From gpmr with Apache License 2.0 5 votes vote down vote up
/**
 * Set up Mime types and, if needed, set the document root.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);

    // When running in an IDE or with ./gradlew bootRun, set location of the static web assets.
    setLocationForStaticAssets(container);
}
 
Example #12
Source File: WebConfigurer.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set up Mime types and, if needed, set the document root.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);
}
 
Example #13
Source File: WebConfigurer.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set up Mime types and, if needed, set the document root.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);
}
 
Example #14
Source File: WebConfigurer.java    From klask-io with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set up Mime types and, if needed, set the document root.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);

    // When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets.
    setLocationForStaticAssets(container);
}
 
Example #15
Source File: MonitorClientApplication.java    From MonitorClient with Apache License 2.0 5 votes vote down vote up
@Override
public void customize(ConfigurableEmbeddedServletContainer configurableEmbeddedServletContainer) {
       MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
       mappings.add("html", "text/html;charset=utf-8");
       configurableEmbeddedServletContainer.setMimeMappings(mappings );
	String Lport = IniUtil.getLport(System.getProperty("user.dir") + File.separator + "config/config.ini");
	configurableEmbeddedServletContainer.setPort(Integer.parseInt(Lport));
}
 
Example #16
Source File: TomcatContainerCustomizer.java    From radar with Apache License 2.0 5 votes vote down vote up
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
	MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
	mappings.add("woff", "application/x-font-woff");
	mappings.add("eot", "application/vnd.ms-fontobject");
	mappings.add("ttf", "application/x-font-ttf");
	container.setMimeMappings(mappings);

	if (!(container instanceof TomcatEmbeddedServletContainerFactory)) {
		return;
	}
	if (!environment.containsProperty(TOMCAT_ACCEPTOR_COUNT)) {
		return;
	}
	TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
	tomcat.addConnectorCustomizers(new TomcatConnectorCustomizer() {

		@Override
		public void customize(Connector connector) {
			ProtocolHandler handler = connector.getProtocolHandler();
			if (handler instanceof Http11NioProtocol) {
				Http11NioProtocol http = (Http11NioProtocol) handler;
				acceptCount = soaConfig.getTomcatAcceptCount();
				soaConfig.registerChanged(() -> {
					if (acceptCount != soaConfig.getTomcatAcceptCount()) {
						acceptCount = soaConfig.getTomcatAcceptCount();
						http.setBacklog(acceptCount);
					}
				});
				http.setBacklog(acceptCount);
				logger.info("Setting tomcat accept count to {}", acceptCount);
			}
		}
	});
}
 
Example #17
Source File: ReferenceApplication.java    From aws-refapp with Apache License 2.0 4 votes vote down vote up
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    mappings.add("html", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);
}
 
Example #18
Source File: TomcatContainerCustomizer.java    From pmq with Apache License 2.0 4 votes vote down vote up
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
	MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
	mappings.add("woff", "application/x-font-woff");
	mappings.add("eot", "application/vnd.ms-fontobject");
	mappings.add("ttf", "application/x-font-ttf");
	container.setMimeMappings(mappings);

	if (!(container instanceof TomcatEmbeddedServletContainerFactory)) {
		return;
	}
	if (!environment.containsProperty(TOMCAT_ACCEPTOR_COUNT)) {
		return;
	}
	TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
	tomcat.addConnectorCustomizers(new TomcatConnectorCustomizer() {

		@Override
		public void customize(Connector connector) {
			ProtocolHandler handler = connector.getProtocolHandler();
			if (handler instanceof Http11NioProtocol) {
				Http11NioProtocol http = (Http11NioProtocol) handler;
				acceptCount = soaConfig.getTomcatAcceptCount();
				maxThreads = soaConfig.getTomcatMaxThreads();
				minThreads = soaConfig.getTomcatMinThreads();
				soaConfig.registerChanged(() -> {						
					if (maxThreads != soaConfig.getTomcatMaxThreads()) {
						maxThreads = soaConfig.getTomcatMaxThreads();
						if (maxThreads > 0) {
							http.setMaxThreads(maxThreads);
						} else {
							http.setMaxThreads(200);
						}
					}
					if (minThreads != soaConfig.getTomcatMinThreads()) {
						minThreads = soaConfig.getTomcatMinThreads();
						if (minThreads > 0) {
							http.setMinSpareThreads(minThreads);
						} else {
							http.setMinSpareThreads(10);
						}
					}


				});
				http.setBacklog(acceptCount);
				http.setMaxThreads(maxThreads);
				http.setMinSpareThreads(minThreads);
				logger.info("Setting tomcat accept count to {}", acceptCount);
			}
		}
	});
}