Update of
/var/cvs/contributions/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/navigation
In directory
james.mmbase.org:/tmp/cvs-serv20473/cmsc/taglib/src/java/com/finalist/cmsc/taglib/navigation
Modified Files:
Tag: b1_4
LinkTag.java
Log Message:
CMSC-883 Cache the computed target page for urlfragments and portletdefinitions.
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/navigation
See also: http://www.mmbase.org/jira/browse/CMSC-883
Index: LinkTag.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/navigation/LinkTag.java,v
retrieving revision 1.17.2.1
retrieving revision 1.17.2.2
diff -u -b -r1.17.2.1 -r1.17.2.2
--- LinkTag.java 10 Mar 2008 09:25:14 -0000 1.17.2.1
+++ LinkTag.java 2 May 2008 12:50:15 -0000 1.17.2.2
@@ -62,13 +62,52 @@
if (page == null) {
if (!StringUtils.isBlank(urlfragment)) {
+ // Computing the window for a given urlfragment can be expensive
and will always yield
+ // the same result. Therefore the computed pageId is cached in the
page context.
+ String key = "linktag_urlfragment_" + urlfragment;
+ Integer pageId = (Integer) ctx.getAttribute(key);
+ if (pageId == null) {
String path = getPath();
page = getPageWithUrlFragement(path, urlfragment);
+
+ pageId = page != null ? page.getId() : -1;
+ ctx.setAttribute(key, pageId);
+ }
+ else if (pageId == -1) {
+ page = null;
+ }
+ else {
+ page = SiteManagement.getNavigationItem(pageId);
+ }
}
else {
if (!StringUtils.isBlank(portletdefinition)) {
+ // Computing the window and page for a given portletdefinition
can be expensive and
+ // will always yield the same result. Therefore the computed
values are cached in the
+ // page context.
+ String key = "linktag_portlet_" + portletdefinition;
+ String value = (String) ctx.getAttribute(key);
+ if (value == null) {
+ // No value in the page context, so we have to compute it now
String path = getPath();
setPageAndWindowBasedOnPortletDefinition(path,
portletdefinition);
+
+ value = page != null ? page.getId() + "_" + window : "";
+ ctx.setAttribute(key, value); // Cache the result in the
page context
+ }
+ else if ("".equals(value.trim())) {
+ // An empty String indicates a value is computed, but no
page and window was found
+ page = null;
+ window = null;
+ }
+ else {
+ // Otherwise the value has format 'pageId_window'
+ int splitAt = value.indexOf("_");
+ int pageId = Integer.valueOf(value.substring(0, splitAt));
+
+ page = SiteManagement.getNavigationItem(pageId);
+ window = value.substring(splitAt + 1);
+ }
}
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs