public class CssUrlRewritingProcessor extends AbstractCssUrlRewritingProcessor
CssImportPreProcessor, the CssUrlRewritingProcessor should come first,
otherwise it will produce wrong results.
Rewrites background images url of the provided css content. This implementation takes care of most common cases such as those described bellow:
| Css resource URI | Image URL | Computed Image URL |
|---|---|---|
| ANY | [URL]/1.jpg | [URL]/1.jpg |
| /1.css | /a/1.jpg | /a/1.jpg |
| /1.jpg | /1.jpg | |
| 1.jpg | ../1.jpg | |
| ../1.jpg | ../../1.jpg | |
| /WEB-INF/1.css | /a/1.jpg | /a/1.jpg |
| /1.jpg | /1.jpg | |
| 1.jpg | [WRO-PREFIX]?id=/WEB-INF/1.jpg | |
| ../1.jpg | [WRO-PREFIX]?id=/WEB-INF/../1.jpg | |
| [X]/1.css where [X] is URL or a classpath resource where [WRO-PREFIX] is a servletContext prefix which will map WRO filter to the result url. |
/a/1.jpg | [WRO-PREFIX]?id=[X]/a/1.jpg |
| /1.jpg | [WRO-PREFIX]?id=[X]/1.jpg | |
| 1.jpg | [WRO-PREFIX]?id=[X]/1.jpg | |
| ../1.jpg | [WRO-PREFIX]?id=[X]/../1.jpg |
UriLocator objects, one for resolving url resources & one for classpath
resources. Both need to be injected using IoC when creating the instance of CssUrlRewritingProcessor class.| Constructor and Description |
|---|
CssUrlRewritingProcessor() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isUriAllowed(String uri) |
protected void |
onProcessCompleted()
Invoked when the process operation is completed.
|
protected void |
onUrlReplaced(String replacedUrl)
Invoked when an url is replaced.
|
protected String |
replaceImageUrl(String cssUri,
String imageUrl)
Replace provided url with the new url if needed.
|
getUrlPrefix, isImportAware, isReplaceNeeded, newCssUrlInspector, process, process, replaceDeclarationpublic static final String ALIAS
protected void onUrlReplaced(String replacedUrl)
onUrlReplaced in class AbstractCssUrlRewritingProcessorreplacedUrl - the newly computed url created as a result of url rewriting.protected String replaceImageUrl(String cssUri, String imageUrl)
replaceImageUrl in class AbstractCssUrlRewritingProcessorcssUri - Uri of the parsed css.imageUrl - to replace.public final boolean isUriAllowed(String uri)
uri - to check if is allowed.protected void onProcessCompleted()
onProcessCompleted in class AbstractCssUrlRewritingProcessorCopyright © 2008-2014. All Rights Reserved.