Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dariah
search
Commits
51315918
Commit
51315918
authored
Apr 28, 2021
by
Gradl, Tobias
Browse files
418: Improve performance of deployed WAR container (OPENED)
Task-Url:
#418
parent
f362efe7
Changes
1
Hide whitespace changes
Inline
Side-by-side
search-ui/src/main/java/eu/dariah/de/search/config/ApplicationConfig.java
View file @
51315918
package
eu.dariah.de.search.config
;
import
org.apache.catalina.Context
;
import
org.apache.catalina.webresources.ExtractingRoot
;
import
org.apache.tomcat.util.scan.StandardJarScanner
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory
;
import
org.springframework.boot.web.server.WebServerFactoryCustomizer
;
import
org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -28,21 +28,22 @@ public class ApplicationConfig {
public
void
setContextPath
(
String
contextPath
)
{
this
.
contextPath
=
contextPath
;
}
/**
* WebServerFactoryCustomizer bean that adapts to a configured context path for the application. This adaption is not
* necessary for implementation of the dariahsp-core library, but helps with setting up the application as it might
* be available or proxied at their deployments
* WebServerFactoryCustomizer bean that adapts to a configured context path for the application.
* This adaption helps with setting up the application as it might be available or proxied at their deployments
*
* @return WebServerFactoryCustomizer
*/
@Bean
public
WebServerFactoryCustomizer
<
Configurable
ServletWebServerFactory
>
webServerFactory
Customizer
()
{
public
WebServerFactoryCustomizer
<
Tomcat
ServletWebServerFactory
>
servletContainer
Customizer
()
{
log
.
info
(
"Web server context path set to {}"
,
contextPath
.
isEmpty
()
?
"/"
:
contextPath
);
return
factory
->
factory
.
setContextPath
(
contextPath
);
return
container
->
container
.
addContextCustomizers
(
context
->
{
context
.
setReloadable
(
false
);
context
.
setPath
(
contextPath
);
});
}
/**
* Provides tomcat factory bean disabling TLD scanning:
* @see https://stackoverflow.com/a/52229296
* Provides tomcat factory
*
* @return TomcatServletWebServerFactory tomcatFactory
*/
...
...
@@ -51,6 +52,11 @@ public class ApplicationConfig {
return
new
TomcatServletWebServerFactory
()
{
@Override
protected
void
postProcessContext
(
Context
context
)
{
// extracting packaged war file for better performance:
// @see https://stackoverflow.com/a/62759292
context
.
setResources
(
new
ExtractingRoot
());
// disabling TLD scanning:
// @see https://stackoverflow.com/a/52229296
((
StandardJarScanner
)
context
.
getJarScanner
()).
setScanManifest
(
false
);
}
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment