Author: christian.bauer(a)jboss.com
Date: 2009-02-14 22:54:15 -0500 (Sat, 14 Feb 2009)
New Revision: 10044
Modified:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/plugin/WikiPluginMacro.java
Log:
Fixed wiki macro cache key issue
Modified:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/plugin/WikiPluginMacro.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/plugin/WikiPluginMacro.java 2009-02-13
22:04:00 UTC (rev 10043)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/plugin/WikiPluginMacro.java 2009-02-15
03:54:15 UTC (rev 10044)
@@ -150,7 +150,7 @@
Cache keys for macros are unique hashes:
- unique in all wiki areas: the id of the current document
- - unique in a particular document: the hashcode of the macro, which includes its
name and position in the document
+ - unique in a particular document: the name and position of the macro in the
document
- unique with changing macro parameters: the hashcode of any macro parameters
- unique for a particular user access level: the current users access level
- unique considering the hashCode() of any additional objects passed to the
method
@@ -171,12 +171,17 @@
log.debug("generating cache key for document: " + currentDocument +
" and macro: " + this + " and access level: " + accessLevel);
StringBuilder builder = new StringBuilder();
+
if (log.isDebugEnabled()) log.debug("including id of document: " +
currentDocument.getId());
builder.append( currentDocument.getId() );
- if (log.isDebugEnabled()) log.debug("including hashCode of this macro:
" + Math.abs(hashCode()));
- builder.append( Math.abs(hashCode()) );
+
+ int namePositionHash = (getName() + "_" + getPosition()).hashCode();
+ if (log.isDebugEnabled()) log.debug("including name/position of this macro:
" + Math.abs(namePositionHash));
+ builder.append( Math.abs(namePositionHash) );
+
if (log.isDebugEnabled()) log.debug("including hashCode of macro params:
" + Math.abs(getParams().hashCode()));
builder.append( Math.abs(getParams().hashCode()) );
+
if (log.isDebugEnabled()) log.debug("including accessLevel: " +
accessLevel);
builder.append( accessLevel );
Show replies by date