james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject cvs commit: jakarta-james/src/java/org/apache/james James.java
Date Mon, 06 Jan 2003 12:39:31 GMT
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:   <mailto:james-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@jakarta.apache.org>


Mime
View raw message