My First Time to modify .class file directly

I’ve been implementing a email dispatching and archiving program recently. To avoid reinventing the wheel, I simply did several searches on Google, one open source software called MailArchiva can get the archiving job done perfectly. It is built to support millions of emails and thousands of mailboxes. So without doubt its performance can easily meet my requirement – simply listen to one single mailbox that won’t have more than 1000 emails a day.

So I just download the open source edition of MailArchiva (They sell the enterprise version which offers more advanced features like WebServices), upload it to my local server, run the install, then all are settled down. It runs smoothly and I can see the emails won’t stay more than 3 seconds within the inbox.

However, this software doesn’t ship with a configuration to let me modify which folder of the IMAP account the application listens to. Before the archiving, there should be another program written by myself to parse the incoming messages and dispatch accordingly. But now it turns out my program don’t even get to read the message before it is archived.

I’ve considered quite a few approaches to solve this problem, such as giving up this MailArchiva and implement a archiving program myself, or move the desired message to other folders on the server side via Exchange rules.

:) And I finally get things done by modifying one class of MailArchiva which is in charge of connecting to IMAP, changing default folder ‘INBOX’ to my own specified one. It’s my first time to modify .class file directly. There’re some existing tools outside, but I chose to edit it with UltraEdit as Vim doesn’t work correctly somehow. (The file modified by Vim cannot be loaded due to some ‘Extra bytes at the end of file’ problem.) Also, as I don’t want to spend the time to dig out where the length of String is, so instead of ‘ARCHIVE’, I named the folder ‘MAGIC’ as it’s of the same length with ‘INBOX’ :)

Sometimes, things can be so straightforward. You just haven’t found the right way. That’s what I’ve learned from today’s experience. Keep DRY(Don’t Repeat Yourself) principle in the mind all the time.

About Kymair

A simple guy living in Zhuhai, likes reading, not go out often.
This entry was posted in Development. Bookmark the permalink.

One Response to My First Time to modify .class file directly

  1. 潘大刀 says:

    Too long, too complex, i’m just too bored to wandering around

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>