Allows customers to rewrite URLs before they are written to the page.
Note: The rewriting of URLs from assets is mainly handled by the {@link AssetURLRewriter}, the exception is {@link com.volantis.mcs.assets.LinkAsset}s as they can be rewritten by both rewriters. i.e. If an <a> element's href attribute references a link asset then the URL for that will be passed to the {@link AssetURLRewriter} and the result of that will then be passed to thePageURLRewriter
with a type of {@link PageURLType#ANCHOR}.
Construction
Implementations of this interface must provide either a default constructor, or a constructor that takes a {@link com.volantis.mcs.application.MarinerApplication}. The latter constructor will be used if present, otherwise the default constructor will be used. The order of creation of customer classes is undefined and so implementation must not rely on being created before, or after other classes.
Note: It is not possible to use a non static inner class as the rewriter as its constructors require an additional parameter that is an instance of the containing class.
Rewriting Constraints
Implementations must not rely on the supplied URLs having a particular structure (e.g. a specific parameter) as that will change in future.
There is a very important relationship between URLs within a single page / request that must be maintained after rewriting. This relationship is defined as follows. Given two URLs A
and B
that are rewritten to A'
and B'
respectively. Then if length(A) <= length(B)
then length(A') <= length(B')
. Failure to maintain this relationship could cause pages to fail to render properly on certain devices.
e.g. a rewriter that added (or removed) the same number of characters to the all URLs within the page would satisfy this relationship but one that added (or removed) a different number of characters would not. Also, a rewriter that made all the URLs the same length would satisfy this relationship.
Supporting Infrastructure
It is the customers responsibility to provide any infrastructure (servlets, etc) necessary to serve any requests to the rewritten URLs.
e.g. If this rewriter is being used to compress the URLs then it could store the original and compressed URLs into a database. The customer would have to provide a servlet (or equivalent mechanism) that was the destination of the compressed URLs. This servlet would then retrieve the original URL from the database using the compressed URL as the key and then redirect the request to that URL.
@mock.generate