Cache theme root URI

This is a performance optimization.

Closes #20176
This commit is contained in:
Alexander Schwartz 2023-05-05 10:55:16 +02:00 committed by Michal Hajas
parent 2758d78865
commit 93373b9398

View file

@ -36,6 +36,7 @@ public class UrlBean {
private URI baseURI;
private Theme theme;
private String realm;
private URI themeRootUri;
public UrlBean(RealmModel realm, Theme theme, URI baseURI, URI actionUri) {
this.realm = realm != null ? realm.getName() : null;
@ -103,7 +104,7 @@ public class UrlBean {
}
public String getResourcesUrl() {
return Urls.themeRoot(baseURI).toString() + "/" + theme.getType().toString().toLowerCase() +"/" + theme.getName();
return getThemeRootUri().toString() + "/" + theme.getType().toString().toLowerCase() +"/" + theme.getName();
}
public String getOauthAction() {
@ -123,12 +124,12 @@ public class UrlBean {
}
public String getResourcesPath() {
URI uri = Urls.themeRoot(baseURI);
URI uri = getThemeRootUri();
return uri.getPath() + "/" + theme.getType().toString().toLowerCase() +"/" + theme.getName();
}
public String getResourcesCommonPath() {
URI uri = Urls.themeRoot(baseURI);
URI uri = getThemeRootUri();
String commonPath = "";
try {
commonPath = theme.getProperties().getProperty("import");
@ -140,4 +141,11 @@ public class UrlBean {
}
return uri.getPath() + "/" + commonPath;
}
private URI getThemeRootUri() {
if (themeRootUri == null) {
themeRootUri = Urls.themeRoot(baseURI);
}
return themeRootUri;
}
}