From: Timo S. <ts...@us...> - 2005-08-28 19:53:05
|
Update of /cvsroot/columba/columba/src/mail/core/org/columba/mail/folder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30273/src/mail/core/org/columba/mail/folder Modified Files: AbstractMessageFolder.java AbstractLocalFolder.java Removed Files: AbstractHeaderListStorage.java Log Message: [intern]Refactoring of the HeaderCacheFramework. Now HeaderList and its persistance are transparently handeled. Now we can even start into looking to use BerkelyDB in the future. Unplanned but not unwelcome this refactoring also includes some IMAP speedus :-) Index: AbstractMessageFolder.java =================================================================== RCS file: /cvsroot/columba/columba/src/mail/core/org/columba/mail/folder/AbstractMessageFolder.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AbstractMessageFolder.java 7 Aug 2005 16:52:50 -0000 1.8 --- AbstractMessageFolder.java 28 Aug 2005 19:52:16 -0000 1.9 *************** *** 122,127 **** protected DefaultSearchEngine searchEngine; - protected IHeaderListStorage headerListStorage; - /** * Standard constructor. --- 122,125 ---- *************** *** 213,217 **** try { ! getHeaderListStorage().removeMessage(uid); } catch (Exception e) { } --- 211,215 ---- try { ! getHeaderList().remove(uid); } catch (Exception e) { } *************** *** 700,704 **** // remove from header-list ! getHeaderListStorage().removeMessage(uid); } --- 698,702 ---- // remove from header-list ! getHeaderList().remove(uid); } *************** *** 708,712 **** * @return Returns the attributeStorage. */ ! public abstract IHeaderListStorage getHeaderListStorage(); /** --- 706,710 ---- * @return Returns the attributeStorage. */ ! //public abstract IHeaderListStorage getHeaderListStorage(); /** *************** *** 714,725 **** */ public boolean exists(Object uid) throws Exception { ! return getHeaderListStorage().exists(uid); ! } ! ! /** ! * @see org.columba.mail.folder.IMailbox#getHeaderList() ! */ ! public IHeaderList getHeaderList() throws Exception { ! return getHeaderListStorage().getHeaderList(); } --- 712,716 ---- */ public boolean exists(Object uid) throws Exception { ! return getHeaderList().exists(uid); } *************** *** 728,732 **** */ public Object[] getUids() throws Exception { ! return getHeaderListStorage().getUids(); } --- 719,723 ---- */ public Object[] getUids() throws Exception { ! return getHeaderList().getUids(); } *************** *** 737,741 **** public void setAttribute(Object uid, String key, Object value) throws Exception { ! getHeaderListStorage().setAttribute(uid, key, value); // set folder changed flag // -> if not, the header cache wouldn't notice that something --- 728,732 ---- public void setAttribute(Object uid, String key, Object value) throws Exception { ! getHeaderList().setAttribute(uid, key, value); // set folder changed flag // -> if not, the header cache wouldn't notice that something *************** *** 748,752 **** */ public Flags getFlags(Object uid) throws Exception { ! return getHeaderListStorage().getFlags(uid); } --- 739,743 ---- */ public Flags getFlags(Object uid) throws Exception { ! return getHeaderList().getFlags(uid); } *************** *** 755,759 **** */ public Attributes getAttributes(Object uid) throws Exception { ! return getHeaderListStorage().getAttributes(uid); } --- 746,750 ---- */ public Attributes getAttributes(Object uid) throws Exception { ! return getHeaderList().getAttributes(uid); } *************** *** 763,767 **** */ public Object getAttribute(Object uid, String key) throws Exception { ! return getHeaderListStorage().getAttribute(uid, key); } --- 754,758 ---- */ public Object getAttribute(Object uid, String key) throws Exception { ! return getHeaderList().getAttribute(uid, key); } *************** *** 852,854 **** --- 843,851 ---- } + + /** + * @return Returns the headerList. + */ + public abstract IHeaderList getHeaderList() throws Exception; + } \ No newline at end of file Index: AbstractLocalFolder.java =================================================================== RCS file: /cvsroot/columba/columba/src/mail/core/org/columba/mail/folder/AbstractLocalFolder.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AbstractLocalFolder.java 27 Aug 2005 13:23:12 -0000 1.7 --- AbstractLocalFolder.java 28 Aug 2005 19:52:16 -0000 1.8 *************** *** 40,44 **** import org.columba.ristretto.message.Header; import org.columba.ristretto.message.LocalMimePart; - import org.columba.ristretto.message.MimePart; import org.columba.ristretto.message.MimeTree; import org.columba.ristretto.parser.HeaderParser; --- 40,43 ---- *************** *** 271,277 **** public Object addMessage(InputStream in, Attributes attributes, Flags flags) throws Exception { - // before adding message, load header list - getHeaderListStorage().getHeaderList(); - // generate UID for new message Object newUid = generateNextMessageUid(); --- 270,273 ---- *************** *** 288,303 **** Header header = HeaderParser.parse(source); ! if ((attributes != null) && (flags != null)) { // save header and attributes ! getHeaderListStorage() ! .addMessage(newUid, header, attributes, flags); } else { ! ColumbaHeader h = new ColumbaHeader(header); h.set("columba.size",new Integer(messageSize / 1024)); - getHeaderListStorage().addMessage(newUid, header, - h.getAttributes(), h.getFlags()); } source.close(); fireMessageAdded(newUid); --- 284,298 ---- Header header = HeaderParser.parse(source); ! ColumbaHeader h; if ((attributes != null) && (flags != null)) { // save header and attributes ! h = new ColumbaHeader( header, attributes, flags); } else { ! h = new ColumbaHeader(header); h.set("columba.size",new Integer(messageSize / 1024)); } source.close(); + h.set("columba.uid", newUid); + getHeaderList().add(h,newUid); fireMessageAdded(newUid); *************** *** 385,390 **** //We use the attributes and flags from the cache //but the parsed header from the parsed message ! ColumbaHeader header = (ColumbaHeader) getHeaderListStorage() ! .getHeaderList().get(uid); header.setHeader(message.getHeader().getHeader()); message.setHeader(header); --- 380,384 ---- //We use the attributes and flags from the cache //but the parsed header from the parsed message ! IColumbaHeader header = getHeaderList().get(uid); header.setHeader(message.getHeader().getHeader()); message.setHeader(header); *************** *** 409,414 **** // get header from cache ! ColumbaHeader h = (ColumbaHeader) getHeaderListStorage() ! .getHeaderList().get(uid); // message doesn't exist (this shouldn't happen here) --- 403,407 ---- // get header from cache ! IColumbaHeader h = getHeaderList().get(uid); // message doesn't exist (this shouldn't happen here) *************** *** 429,439 **** // message isn't cached // -> just return header from cache ! return (ColumbaHeader) getHeaderListStorage().getHeaderList().get( ! uid); } } /** ! * @see org.columba.mail.folder.IMailbox#removeMessage(java.lang.Object) */ public void removeMessage(Object uid) throws Exception { --- 422,431 ---- // message isn't cached // -> just return header from cache ! return getHeaderList().get(uid); } } /** ! * @see org.columba.mail.folder.IMailbox#remove(java.lang.Object) */ public void removeMessage(Object uid) throws Exception { *************** *** 447,464 **** /** - * @see org.columba.mail.folder.Folder#save() - */ - public void save() throws Exception { - // only save header-cache if folder data changed - if (hasChanged()) { - getHeaderListStorage().save(); - setChanged(false); - } - - // call Folder.save() to be sure that messagefolderinfo is saved - super.save(); - } - - /** * Changes the selected message flags and updates the {@link MailFolderInfo} * accordingly. --- 439,442 ---- *************** *** 473,478 **** */ protected void setFlags(Object uid, Flags flags) throws Exception { ! ColumbaHeader h = (ColumbaHeader) getHeaderListStorage() ! .getHeaderList().get(uid); Flags oldFlags = h.getFlags(); --- 451,455 ---- */ protected void setFlags(Object uid, Flags flags) throws Exception { ! IColumbaHeader h = getHeaderList().get(uid); Flags oldFlags = h.getFlags(); *************** *** 515,519 **** if (keyList.size() == 0) { ! return getHeaderListStorage().getHeaderFields(uid, keys); } else { // We need to parse --- 492,496 ---- if (keyList.size() == 0) { ! return getHeaderList().getHeaderFields(uid, keys); } else { // We need to parse --- AbstractHeaderListStorage.java DELETED --- |