r1124 - xwiki/trunk/src/main/java/com/xpn/xwiki/doc

Ludovic Dubost ludovic at users.forge.objectweb.org
Wed Aug 9 00:25:40 CEST 2006


Author: ludovic
Date: 2006-08-09 00:25:40 +0200 (Wed, 09 Aug 2006)
New Revision: 1124

Modified:
   xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
Log:
Changed way to handle Archives as it would break reading and saving an XWikiDocument using fromXML. It would loose the version archive file.
Now archives are handled using SoftReferences which allow the garbage collector to discards them but still have them for saving. The reference to the archive is saved in the XWikiContext object to make sure it is not discarded during a request.

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java	2006-08-08 20:13:33 UTC (rev 1123)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java	2006-08-08 22:25:40 UTC (rev 1124)
@@ -577,13 +577,17 @@
     public XWikiDocumentArchive getDocumentArchive() {
         // We are using a SoftReference which will allow the archive to be
         // discarded by the Garbage collector as long as the context is closed (usually during the request)
-        return (XWikiDocumentArchive) archive.get();
+        if (archive==null)
+         return null;
+        else
+         return (XWikiDocumentArchive) archive.get();
     }
 
     public void setDocumentArchive(XWikiDocumentArchive arch) {
         // We are using a SoftReference which will allow the archive to be
         // discarded by the Garbage collector as long as the context is closed (usually during the request)
-        this.archive = new SoftReference(arch);
+        if (arch!=null)
+         this.archive = new SoftReference(arch);
     }
 
     public void setDocumentArchive(String sarch) throws XWikiException {





More information about the Xwiki-notifications mailing list