public class RotatingVirtualUriMapping extends RegexpVirtualUriMapping
An extension of RegexpVirtualUriMapping
that allows a rotation between different destination urls. In order
to rotate toUri
must contain the *
that will be replaced by a random number between
start
(default is 1
) and end
(defaults is 3
).
An additional property padding
can specify the left 0 padding for numbers (defaults is 2
).
So for example a destination url like forward:/banner/image_*.jpg
will randomly forward the request to
/banner/image_01.jpg
, /banner/image_02.jpg
or /banner/image_03.jpg
VirtualUriMapping.Result
Constructor and Description |
---|
RotatingVirtualUriMapping() |
Modifier and Type | Method and Description |
---|---|
Optional<VirtualUriMapping.Result> |
mapUri(URI uri)
Maps an incoming URI to a new target URI.
|
void |
setEnd(int end)
Sets the end.
|
void |
setPadding(int padding)
Sets the padding.
|
void |
setStart(int start)
Sets the start.
|
setFromUri
getFromUri, getPattern, getToUri, isValid, setInternalFromUri, setToUri, toString
public void setStart(int start)
start
- the start to setpublic void setEnd(int end)
end
- the end to setpublic void setPadding(int padding)
padding
- the padding to setpublic Optional<VirtualUriMapping.Result> mapUri(URI uri)
VirtualUriMapping
mapUri
in interface VirtualUriMapping
mapUri
in class RegexpVirtualUriMapping
uri
- a relative URI containing only the path and query components.
The path is relative to the magnolia servlet mapping; context path is already stripped.Copyright © 2003–2019 Magnolia International Ltd.. All rights reserved.