You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by da...@apache.org on 2003/01/06 13:39:31 UTC

cvs commit: jakarta-james/src/java/org/apache/james James.java

danny       2003/01/06 04:39:31

  Modified:    src/java/org/apache/mailet MailetContext.java
               src/java/org/apache/james James.java
  Log:
  removing avalon dependance in mailets.
  Step two adding mail repository access methods to MailetContext
  
  Revision  Changes    Path
  1.6       +5 -0      jakarta-james/src/java/org/apache/mailet/MailetContext.java
  
  Index: MailetContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/mailet/MailetContext.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MailetContext.java	2 Dec 2002 21:58:58 -0000	1.5
  +++ MailetContext.java	6 Jan 2003 12:39:31 -0000	1.6
  @@ -228,4 +228,9 @@
        */
       void storeMail(MailAddress sender, MailAddress recipient, MimeMessage msg)
           throws MessagingException;
  +        
  +
  +    MailRepository getMailRepository(String specificationURL) throws MessagingException;
  +    SpoolRepository getMailSpool(String specificationURL) throws MessagingException;
  +//void getUserRepository() throws MessagingException;
   }
  
  
  
  1.36      +44 -1     jakarta-james/src/java/org/apache/james/James.java
  
  Index: James.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/James.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- James.java	2 Oct 2002 06:12:01 -0000	1.35
  +++ James.java	6 Jan 2003 12:39:31 -0000	1.36
  @@ -24,6 +24,7 @@
   import org.apache.james.userrepository.DefaultJamesUser;
   import org.apache.james.util.RFC2822Headers;
   import org.apache.james.util.RFC822DateFormat;
  +import org.apache.mailet.*;
   import org.apache.mailet.Mail;
   import org.apache.mailet.MailAddress;
   import org.apache.mailet.MailetContext;
  @@ -350,6 +351,8 @@
           //compMgr.put("org.apache.mailet.MailetContext", this);
           // For AVALON aware mailets and matchers, we put the Component object as
           // an attribute
  +        
  +        //TODO NOT unless specifically required by conf
           attributes.put(Constants.AVALON_COMPONENT_MANAGER, compMgr);
   
           System.out.println(SOFTWARE_NAME_VERSION);
  @@ -832,4 +835,44 @@
           success = localusers.addUser(user);
           return success;
       }
  +   
  +
  +    /**
  +     * @see org.apache.mailet.MailetContext#getMailSpool(String)
  +     */
  +    public SpoolRepository getMailSpool(String specificationURL) throws MessagingException {
  +    return (SpoolRepository) getRepository(specificationURL,SpoolRepository.SPOOL);
  +    }        
  +
  +        private MailRepository getRepository(String specificationURL,String storeType)throws MessagingException {
  +        if (specificationURL == null) {
  +            throw new MessagingException("Failed to retrieve Store component because specificationURL is null" );
  +        }
  +
  +        try {
  +            // Instantiate the a MailRepository for outgoing mails
  +            MailStore mailstore = (MailStore) compMgr.lookup("org.apache.james.services.MailStore");
  +
  +            DefaultConfiguration spoolConf
  +                = new DefaultConfiguration("repository", "generated by Context");
  +            spoolConf.setAttribute("destinationURL", specificationURL);
  +            spoolConf.setAttribute("type", storeType);
  +            return (MailRepository) mailstore.select(spoolConf);
  +        } catch (ComponentException cnfe) {
  +            log("Failed to retrieve Store component:" + cnfe.getMessage());
  +            throw new MessagingException("Failed to retrieve Store component:"+specificationURL+" because "+cnfe.getMessage(),cnfe );
  +        } catch (Exception e) {
  +            log("Failed to retrieve Store component:" + e.getMessage());
  +            throw new MessagingException("Failed to retrieve Store component:"+specificationURL+" because "+e.getMessage(),e );
  +        }        
  +        
  +    }
  +
  +    /**
  +     * @see org.apache.mailet.MailetContext#getMailRepository(String)
  +     */
  +    public MailRepository getMailRepository(String specificationURL) throws MessagingException {
  +        return getRepository(specificationURL,MailRepository.MAIL);
  +    }
  +
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: cvs commit: jakarta-james/src/java/org/apache/james James.java

Posted by Danny Angus <da...@apache.org>.
Harmeet,
SpoolRepository currently extends MailRepository.

I can't see any benefit of a super interface for all repository types, after
all theres not a lot of common functionality apart from "get(key)"

I can see the benefit of extending UserRepository to provide different
functions, but we should perhaps have some means of identifying different
types other than resort to introspection, in any case I don't think this is
a trivial issue, and perhaps we should consider making mail and spool
repositories both inherit from a single common interface so that they are
peers rather than a rather arbitrarily parent and child. Better brains than
mine have discussed this already.

As far as this series of commits is concerned I want to simply re-factor
avalon repository access out of the standard mailets, and make mailets gain
repository access through contracts defined by the MailetAPI.

This means I'm refactoring some interfaces from James into Mailet, adding
methods and implementing them.

What I'm conciously *not* doing is altering the logic or architecture in any
way beyond my self-imposed remit.

This in order that everyone else can see, test and comment on what I've
done. Hopefully so that I don't introduce any badness, but also so that
whatever other API changes can or will be encouraged by these changes isn't
simply on my whim, but has some clear architectural benefit.

I'm imposing a limit on myself for this work, limiting it to changes to the
MailetAPI and James aimed at improving the lot of mailet writers, which
includes these changes plus the classloading issues discussed earlier and on
the wiki. Otherwise I'll get no work done, earn no money and my wife will
have at me with a frying pan ;-)

Noel and I have argued at length about mailet logging, and as he was
proposing it and me opposing it I'll leave it to him to flesh out the
initial offering.

Once my changes are complete we may have enough v3 differences to make it
worth releasing an early access milestone for mailet developers to comment
on and direct further changes.

d.

> -----Original Message-----
> From: Harmeet Bedi [mailto:harmeet@kodemuse.com]
> Sent: 06 January 2003 17:39
> To: James Developers List
> Subject: Re: cvs commit: jakarta-james/src/java/org/apache/james
> James.java
>
>
> ----- Original Message -----
> From: <da...@apache.org>
> >   +    MailRepository getMailRepository(String specificationURL) throws
> MessagingException;
> >   +    SpoolRepository getMailSpool(String specificationURL) throws
> MessagingException;
> >   +//void getUserRepository() throws MessagingException;
>
>
> Danny, what do you think about having an abstraction of
> Repository type and
> Repository. There could be multiple repositories. For instance there could
> be a Mail, Spool, Spam and may be user specified repositories.
>
> Harmeet
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-james/src/java/org/apache/james James.java

Posted by Harmeet Bedi <ha...@kodemuse.com>.
----- Original Message -----
From: <da...@apache.org>
>   +    MailRepository getMailRepository(String specificationURL) throws
MessagingException;
>   +    SpoolRepository getMailSpool(String specificationURL) throws
MessagingException;
>   +//void getUserRepository() throws MessagingException;


Danny, what do you think about having an abstraction of Repository type and
Repository. There could be multiple repositories. For instance there could
be a Mail, Spool, Spam and may be user specified repositories.

Harmeet


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>