public interface BaseURLSource
Request.getServerName()
. In production, behind a firewall, it is often
necessary to do a bit more, since getServerName()
will often be the name of the internal server (not
visible to the client web browser), and a hard-coded name of a server that is visible to the web browser
is needed. Further, in testing, non-default ports are often used. In those cases, an overriding contribution to the
ServiceOverride
service will allow a custom implementation to supercede the default version. You may also
contribute application specific values for the following SymbolConstants
:
SymbolConstants.HOSTNAME
, SymbolConstants.HOSTPORT
and
SymbolConstants.HOSTPORT_SECURE
to alter the behavior of the default BaseURLSource
implementation. The default values for the SymbolConstants require Request
context to be available. If you contribute specific values for the specified SymbolConstants, it's safe to use
the default implementation of this service outside of request context, for example in a batch job. For
SymbolConstants.HOSTNAME
, a value starting with a dollar sign ($) will be resolved
using System.getenv()
- contributing "$HOSTNAME" for SymbolConstants.HOSTNAME
is the most sensible choice for a dynamic value that doesn't use
Request.getServerName()
.Modifier and Type | Method and Description |
---|---|
String |
getBaseURL(boolean secure)
Returns the base portion of the URL, before the context path and servlet path are appended.
|
String getBaseURL(boolean secure)
secure
- whether a secure "https" or insecure "http" base URL should be returned${project.version} - Copyright © 2003-2015 The Apache Software Foundation.