Interface VirtualHost
-
- All Known Subinterfaces:
MutableVirtualHost
public interface VirtualHost
VirtualHost which holds the mapping between host (server name) and site name.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Collection<String>
getAllowedOrigins()
Returns all the allowed origins for thisVirtualHost
String
getBaseURL(javax.servlet.http.HttpServletRequest request)
Returns the base of theURL
as seen by for example a browser.String
getCdnHost()
VirtualHost
getChildHost(String name)
List<VirtualHost>
getChildHosts()
String
getContextPath()
Returns the contextpath (webapp) for all theMount
s below thisVirtualHost
.String[]
getDefaultResourceBundleIds()
String
getHomePage()
String
getHostGroupName()
Returns the name of host group this virtual host belongs to, for example 'prod', 'acct' or 'dev'String
getHostName()
The hostName of this VirtualHost.String
getHstLinkUrlPrefix()
Returns the 'HST Link URL prefix' in case one is configuredString
getLocale()
the locale for this VirtualHost ornull
when it does not contain one.String
getName()
Returns thename
of this VirtualHost.String
getPageNotFound()
PortMount
getPortMount(int portNumber)
Map<String,String>
getResponseHeaders()
Return a non-null unmodifiable map of the configuration values of HTTP Response headers which should be set in any responses by the requests on this.String
getScheme()
int
getSchemeNotMatchingResponseCode()
VirtualHosts
getVirtualHosts()
boolean
isCacheable()
boolean
isContextPathInUrl()
boolean
isCustomHttpsSupported()
boolean
isPortInUrl()
boolean
isSchemeAgnostic()
If aVirtualHost
is scheme agnostic, the request gets served regardless whether it ishttp
orhttps
(assumingMount
andHstSiteMapItem
do not override the value)boolean
isVersionInPreviewHeader()
-
-
-
Method Detail
-
getHostName
String getHostName()
The hostName of this VirtualHost. Note that this hostName might contain wildcards, for example www.onehippo.*- Returns:
- The composite hostName of this VirtualHost, thus including parent VirtualHosts if present
-
getName
String getName()
Returns thename
of this VirtualHost. Note, this is not the hostName, but only part of it. If the hostName is www.apache.org, then the name of this VirtualHost might be 'www' or 'apache' or 'org'. It can thus be one segment of the entire hostName or is get be www.apache.org which is also possible- Returns:
- The
name
of this VirtualHost. Note, this is only part of the entire hostName - See Also:
getHostName()
-
getHostGroupName
String getHostGroupName()
Returns the name of host group this virtual host belongs to, for example 'prod', 'acct' or 'dev'- Returns:
- the
name
of the host group this VirtualHost belongs to.
-
getLocale
String getLocale()
the locale for this VirtualHost ornull
when it does not contain one. Note that if an ancestor VirtualHost contains a locale, this value is inherited unless this VirtualHost explicitly defines its own. The VirtualHost directly below theVirtualHosts
inherits the value from theVirtualHosts
- Returns:
- the locale for this VirtualHost or
null
when it does not contain one.
-
getChildHost
VirtualHost getChildHost(String name)
- Parameters:
name
- the name segment of the hostname- Returns:
- the child
VirtualHost
ornull
if none found
-
getChildHosts
List<VirtualHost> getChildHosts()
- Returns:
- the list of all VirtualHost childs of this VirtualHost
-
getPortMount
PortMount getPortMount(int portNumber)
- Parameters:
portNumber
-- Returns:
- the
-
getVirtualHosts
VirtualHosts getVirtualHosts()
- Returns:
- the
VirtualHosts
container of thisVirtualHost
-
isContextPathInUrl
boolean isContextPathInUrl()
- Returns:
true
when the created url should have the contextpath in it
-
getContextPath
String getContextPath()
Returns the contextpath (webapp) for all the
Mount
s below thisVirtualHost
.- Returns:
- Returns the contextpath (webapp) for all the
Mount
s below thisVirtualHost
. The contextpath for the ROOT application must be an empty String. If non-empty, a path starting with a "/" character but that does not end with a "/" character must be returned. It is not allowed to returnnull
- See Also:
Mount.getContextPath()
-
isPortInUrl
boolean isPortInUrl()
- Returns:
true
when the created url should have the port in it
-
getScheme
String getScheme()
- Returns:
- the scheme to use for creating external urls, for example http / https
-
isSchemeAgnostic
boolean isSchemeAgnostic()
If aVirtualHost
is scheme agnostic, the request gets served regardless whether it ishttp
orhttps
(assumingMount
andHstSiteMapItem
do not override the value)- Returns:
true
when thisVirtualHost
is scheme agnostic
-
getSchemeNotMatchingResponseCode
int getSchemeNotMatchingResponseCode()
the response code the HST sets when
HttpServletRequest
scheme
does not matchgetScheme()
. Default response code isHttpServletResponse.SC_MOVED_PERMANENTLY
. The following response codes are supported and result in:- 200 : no behavior, ignored
- 301 : when request has different scheme than
getScheme()
, permanent redirect to the correct scheme is done - 302 | 303 | 307 : when request has different scheme than
getScheme()
, temporal redirect to the correct scheme is done - 403 : when request has different scheme than
getScheme()
, a page forbidden is returned - 404 : when request has different scheme than
getScheme()
, a page not found is returned
Any other response code than above will result in inheriting the response code from parent
VirtualHost
orVirtualHosts
-
getHomePage
String getHomePage()
- Returns:
- the homepage for this virtual host or
null
when not present
-
getBaseURL
String getBaseURL(javax.servlet.http.HttpServletRequest request)
Returns the base of theURL
as seen by for example a browser. The base URL is consists ofscheme + hostname + portnumber
for example 'http://www.hippoecm.org:8081' The scheme is 'http' by default, unlessgetScheme()
returns something else The hostname is the HttpServeltRequest request.getServerName() (proxies must haveProxyPreserveHost On
) The portnumber is as follows:- when
#isPortVisible()
isfalse
, there is no portnumber - otherwise:
port =
#getPortNumber()
if (port == 0) {port = request.getServerPort()}
if(port == 80 && "http".equals(scheme)) || (port == 443 && "https".equals(scheme))
: no portnumber will be in baseUrl
- Parameters:
request
- the HttpServletRequest- Returns:
- the
URL
until the context path, thusscheme + hostname + portnumber
, for example 'http://www.hippoecm.org:8081'
- when
-
getPageNotFound
String getPageNotFound()
- Returns:
- the pagenotfound for this
Mount
ornull
when not present
-
isVersionInPreviewHeader
boolean isVersionInPreviewHeader()
- Returns:
- whether the version of the HST is in the header of the preview
-
isCacheable
boolean isCacheable()
- Returns:
true
if rendering / resource requests can have their entire page http responses cached.
-
getDefaultResourceBundleIds
String[] getDefaultResourceBundleIds()
- Returns:
- default resource bundle IDs for all sites below this virtualhost to use, for example { "org.example.resources.MyResources" }. Returns empty array
when not configured on this
VirtualHost
and empty from ancestorVirtualHost
or when root host fromVirtualHosts.getDefaultResourceBundleIds()
-
getCdnHost
String getCdnHost()
- Returns:
null
or empty String in case no cdn host is used and otherwise the cdn host to be used for URLs to sitemap items that haveHstSiteMapItem#isContainerResource() = true
. Preferred format for a cdn host is //hostname so it piggybacks on the scheme of the current request. Starting with http/https is allowed but is not preferred
-
getHstLinkUrlPrefix
String getHstLinkUrlPrefix()
Returns the 'HST Link URL prefix' in case one is configured
- Returns:
-
isCustomHttpsSupported
boolean isCustomHttpsSupported()
- Returns:
true
if thisVirtualHost
allows aHttpServletRequest
overhttps
to be rendered while the matchedHstSiteMapItem
orMount
indicates throughgetScheme()
the request should behttp
-
getResponseHeaders
Map<String,String> getResponseHeaders()
Return a non-null unmodifiable map of the configuration values of HTTP Response headers which should be set in any responses by the requests on this. They keys from the returned map are the header names.
Note that the header names returned by this method overwrites any already set headers during request processing with the same name
- Returns:
- a non-null unmodifiable map of the configuration values of HTTP Response headers which should be set in any responses by the requests on this.
-
getAllowedOrigins
Collection<String> getAllowedOrigins()
Returns all the allowed origins for this
VirtualHost
- Returns:
- unmdifiable collection of the allowed origins for this virtualhost used in case of a CORS OPTIONS request, if no allowed origins specified, the parent virtual host its allowed origins will be used and if there is no parent an empty list will be returned.
-
-