001 // Copyright 2008 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry.services;
016
017 /**
018 * Used when switching between normal/insecure (HTTP) and secure (HTTPS) mode. When a switch occurs, it is no longer
019 * possible to use relative URLs, instead absolute URLs must be generated. The default implementation of this is
020 * simple-minded: it just tacks the correct scheme in front of {@link org.apache.tapestry.services.Request#getServerName()}.
021 * In production, behind a firewall, it is often necessary to do a bit more, since <code>getServerName()</code> will
022 * often be the name of the internal server (not visible to the client web browser), and a hard-coded name of a server
023 * that <em>is</em> visible to the web browser is needed. Further, in testing, non-default ports are often used. In
024 * those cases, an overriding contribution to the {@link org.apache.tapestry.services.Alias} service will allow a custom
025 * implementation to supercede the default version.
026 */
027 public interface BaseURLSource
028 {
029 /**
030 * Returns the base portion of the URL, before the context path and servlet path are appended. The return value
031 * should <em>not</em> end with a slash; it should end after the host name, or after the port number. The context
032 * path, servlet path, and path info will be appended to the returned value.
033 *
034 * @param secure whether a secure "https" or insecure "http" base URL should be returned
035 * @return the base URL ready for additional extensions
036 */
037 String getBaseURL(boolean secure);
038 }