You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by haipeng du <ha...@gmail.com> on 2006/03/07 17:09:09 UTC

questions about mail file system repository

I want to save some special email to my own repository. To do that, I use
ToRepository mailet. It works great. The problem is that how could I retrive
it through repository. I checked source code, when it saves mail to file
system, it dose not return the key so that I can get that. Also, how could I
get that repository object from other java class such as monitor class that
I wrote myself.
Thanks a lot

--
Haipeng Du
Software Engineer
Comphealth,
Salt Lake City

Re: questions about mail file system repository

Posted by Stefano Bagnara <ap...@bago.org>.
haipeng du wrote:
> For all emails that from special users, I need to forward these email out
> after delay time. For example, I got one email in , and forward it out after
> 24 hours. I do not want mailets to be held so long time. So, I saved mail to
> a folder. I have another thread to check the folder to see if there are
> emails that are there longer  than 24 hours. I just want to get repository
> that is used in ToRepository Mailets and retrive the mail through it.
> Thanks a lot.

Look at the RemoteDelivery sourcecode.
It uses a spoolrepository option to avoid to retry mails that have 
temporary errors until a given time.
You probably want to do something similar, but starting from an "error" 
scenario and having a 24 hour retry time.

The easy way is to start your watching thread from a mailet: create your 
own extension of ToRepository and in the init start a new thread using 
the same repository (RemoteDelivery does a similar thing with the 
outgoing spool repository and the ougoing spool threads).

The "cool" (perhaps "hard") way is to create your own avalon component. 
Just look at the FetchScheduler component. It has to implement an 
interface, and you also need to write an .xinfo file describing 
dependencies. As a dependency you should put the "Store" object (look at 
the default assembly.xml and default .xinfo files to understand how 
dependencies are declared).
 From the store you can obtain a MAIL or SPOOL repository using the 
destinationUrl. Once you have the mail repository you can get a Mail by 
its name or you can also list Mail keys (names) for the retrieved 
repository.
If your repository is a spool repository you can also use the 
accept()/accept(time) methods.

If you use James 2.3.0a1 you can check MailStoreSpoolRepository.java 
sources and the MailStoreSpoolRepository.xinfo file.

In the assembly.xml I added this:
   <!-- The main SpoolRepository -->
   <block name="spoolrepository" 
class="org.apache.james.mailrepository.MailStoreSpoolRepository" >
     <provide name="mailstore"
              role="org.apache.avalon.cornerstone.services.store.Store" />
   </block>

In the config.xml I added this:
    <spoolrepository destinationURL="dbfile://maildb/spool/spool" 
type="SPOOL"/>

So, here is what you should do:
Add to assembly.xml:
   <block name="myrepository" 
class="org.apache.james.mailrepository.MailStoreSpoolRepository" >
     <provide name="mailstore"
              role="org.apache.avalon.cornerstone.services.store.Store" />
   </block>

And to config.xml:
    <myrepository destinationURL="db://maildb/inbox/myrepos" 
type="MAIL"/> (or SPOOL if the repos is a spool)

Then create your own component that depend on the new repository.

Add this to assembly:
   <!-- The James Spool Manager block  -->
   <block name="mymanager" class="org.apache.james.test.MyManager" >
     <provide name="myrepository" 
role="org.apache.james.services.SpoolRepository"/>
   </block>

Then you create your MyManager.xinfo file (look at the 
JamesSpoolManager.xinfo file as an example) and the MyManager.java (look 
at the JamesSpoolManager.java)

-------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: questions about mail file system repository

Posted by haipeng du <ha...@gmail.com>.
For all emails that from special users, I need to forward these email out
after delay time. For example, I got one email in , and forward it out after
24 hours. I do not want mailets to be held so long time. So, I saved mail to
a folder. I have another thread to check the folder to see if there are
emails that are there longer  than 24 hours. I just want to get repository
that is used in ToRepository Mailets and retrive the mail through it.
Thanks a lot.

On 3/7/06, Stefano Bagnara <ap...@bago.org> wrote:
>
> Can you explain what is your goal?
>
> What is the "other java class such as monitor"? Is it in a mailet? Is it
> inside james/phoenix ? Is it in the same JVM?
>
> Stefano
>
> haipeng du wrote:
> > I want to save some special email to my own repository. To do that, I
> use
> > ToRepository mailet. It works great. The problem is that how could I
> retrive
> > it through repository. I checked source code, when it saves mail to file
> > system, it dose not return the key so that I can get that. Also, how
> could I
> > get that repository object from other java class such as monitor class
> that
> > I wrote myself.
> > Thanks a lot
> >
> > --
> > Haipeng Du
> > Software Engineer
> > Comphealth,
> > Salt Lake City
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>


--
Haipeng Du
Software Engineer
Comphealth,
Salt Lake City

Re: questions about mail file system repository

Posted by Stefano Bagnara <ap...@bago.org>.
Can you explain what is your goal?

What is the "other java class such as monitor"? Is it in a mailet? Is it 
inside james/phoenix ? Is it in the same JVM?

Stefano

haipeng du wrote:
> I want to save some special email to my own repository. To do that, I use
> ToRepository mailet. It works great. The problem is that how could I retrive
> it through repository. I checked source code, when it saves mail to file
> system, it dose not return the key so that I can get that. Also, how could I
> get that repository object from other java class such as monitor class that
> I wrote myself.
> Thanks a lot
> 
> --
> Haipeng Du
> Software Engineer
> Comphealth,
> Salt Lake City
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org