tmortagne (SVN) wrote:
> Author: tmortagne
> Date: 2008-11-14 15:41:52 +0100 (Fri, 14 Nov 2008)
> New Revision: 14215
>
> Added:
>
> platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/XWikiContextTest.java
> Modified:
>
> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWikiContext.java
> Log:
> XWIKI-2837: Class Cache in context is not database aware
> Applied patch from Denis Gervalle (just added the base class's wiki if exists)
>
> Modified:
> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWikiContext.java
> ===================================================================
> ---
> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWikiContext.java
> 2008-11-14 14:41:34 UTC (rev 14214)
> +++
> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWikiContext.java
> 2008-11-14 14:41:52 UTC (rev 14215)
> @@ -407,16 +407,47 @@
> put("mainxwiki", str);
> }
>
> - // Used to avoid recursive loading of documents if there are recursives
> usage of classes
> + /**
> + * Used to avoid recurrent loading of documents if there are recurrent
> usage of classes.
> + *
> + * @param bclass the class to cache.
> + */
> public void addBaseClass(BaseClass bclass)
> {
> - this.classCache.put(bclass.getName(), bclass);
> + String className = bclass.getName();
> + if (bclass.getWiki() != null) {
> + StringBuffer sb = new StringBuffer(bclass.getWiki());
> + sb.append(":");
> + sb.append(className);
> + className = sb.toString();
> + } else if (getDatabase() != null) {
> + StringBuffer sb = new StringBuffer(getDatabase());
> + sb.append(":");
> + sb.append(className);
> + className = sb.toString();
> + }
> +
> + this.classCache.put(className, bclass);
> }
>
> - // Used to avoid recursive loading of documents if there are recursives
> usage of classes
> + /**
> + * Used to avoid recurrent loading of documents if there are recurrent
> usage of classes.
> + *
> + * @param name the local name (without the wiki identifier) of the
> xclass. The wiki identifier is taken from
> + * [EMAIL PROTECTED] #getDatabase()}.
> + * @return the cached xclass or null if the cache does not contains any
> xclass.
> + */
> public BaseClass getBaseClass(String name)
> {
> - return this.classCache.get(name);
> + String classname = name;
> + if (getDatabase() != null) {
> + StringBuffer sb = new StringBuffer(getDatabase());
> + sb.append(":");
> + sb.append(name);
> + classname = sb.toString();
> + }
> +
> + return this.classCache.get(classname);
> }
>
> // Used to avoid recursive loading of documents if there are recursives
> usage of classes
>
Unfortunately this has a bad side effect:
org.hibernate.NonUniqueObjectException: a different object with the same
identifier value was already associated with the session:
[com.xpn.xwiki.doc.XWikiDocument#-34276813]
Lots of errors were displayed when starting the server, caused by
http://jira.xwiki.org/jira/browse/XWIKI-2842 and the fact that although
the class cache sees XWiki.Tags and xwiki:XWiki.Tags as different
entities, in Hibernate they represent the same entity.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs