public abstract class AbstractWebCmsDomainContextFilter
extends org.springframework.web.filter.OncePerRequestFilter
WebCmsDomainContext
based on the hostname of the current request. Builds a list of AbstractWebCmsDomainContextFilter.DomainContextLookup records and will use the
first one that matches for the current hostname. If no domain can be matched on hostname, a default domain will be assigned instead.
A AbstractWebCmsDomainContextFilter.DomainContextLookup record can optionally specify a Locale that should be set for the selected hostname match.
For performance reasons, this base class caches its lookup records. It is strongly advised that domain metadata
can be cached eternally as long as the domain itself is not modified.
Extend this class to create your own domain selection logic. Note however that your filter must be created as a bean and
requires the WebCmsDomainCache. Only a single filter can be active.WebCmsSiteConfigurationFilter| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractWebCmsDomainContextFilter.DomainContextLookup
Helper for a single hostname lookup that maps to a
WebCmsDomainContext
and its corresponding default Locale. |
| Modifier and Type | Field and Description |
|---|---|
static String |
FILTER_NAME |
| Constructor and Description |
|---|
AbstractWebCmsDomainContextFilter() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract AbstractWebCmsDomainContextFilter.DomainContextLookup |
buildDefaultDomainLookup(List<AbstractWebCmsDomainContextFilter.DomainContextLookup> domainSpecificLookups)
Builds the
AbstractWebCmsDomainContextFilter.DomainContextLookup for the default domain. |
protected abstract List<AbstractWebCmsDomainContextFilter.DomainContextLookup> |
buildDomainSpecificLookups()
Builds the list of lookups that should be used.
|
protected Pattern |
compileHostPattern(String hostName)
Convert a configured hostname to a lookup pattern.
|
protected void |
doFilterInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain filterChain) |
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatchpublic static final String FILTER_NAME
protected final void doFilterInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain filterChain)
throws javax.servlet.ServletException,
IOException
doFilterInternal in class org.springframework.web.filter.OncePerRequestFilterjavax.servlet.ServletExceptionIOExceptionprotected abstract List<AbstractWebCmsDomainContextFilter.DomainContextLookup> buildDomainSpecificLookups()
WebCmsSiteConfiguration.
If so, create a lookup for every hostname in the configuration.
The list should not include the default domain lookup.
NOTE: Only called if lookup cache is being refreshed.protected abstract AbstractWebCmsDomainContextFilter.DomainContextLookup buildDefaultDomainLookup(List<AbstractWebCmsDomainContextFilter.DomainContextLookup> domainSpecificLookups)
AbstractWebCmsDomainContextFilter.DomainContextLookup for the default domain.
This lookup will be used in case no lookup matched based on the hostname.
Any configured AbstractWebCmsDomainContextFilter.DomainContextLookup.hostPattern will be ignored.
NOTE: Only called if lookup cache is being refreshed.domainSpecificLookups - list of lookups for actual domainsprotected Pattern compileHostPattern(String hostName)
hostName - patternCopyright © 2020. All rights reserved.