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 hb...@apache.org on 2001/03/31 04:40:45 UTC

cvs commit: jakarta-james/src/org/apache/james/transport/matchers HostIsLocal.java RecipientIsLocal.java

hbedi       01/03/30 18:40:45

  Modified:    src/org/apache/james/transport/matchers HostIsLocal.java
                        RecipientIsLocal.java
  Log:
  The mailet/MailetContext exposed these methods to determine if server/user is local
  --------------------------------------------------------------------------
  1)
  Collection getServerNames();
  
  2)
  Collection getLocalUsers();
  
  Changed API to have these methods instead
  ------------------------------------------------------------------
  1)
  /** Checks if a server is considered local by the mailet context. */
  boolean isLocalServer(String name);
  
  2)
  /** Checks if a user account is considered local by the mailet context. */
  boolean isLocalUser(String userAccount);
  
  The advantage are
  ------------------------------------------
  - allows the MailetContext to hide and possibly plugin alternate strategy
  for the local server name and user check.
  - The entire collection is never exposed, only a way to ask if an entity
  exists in the collection. This could have scalability benefits.
  
  Revision  Changes    Path
  1.6       +1 -10     jakarta-james/src/org/apache/james/transport/matchers/HostIsLocal.java
  
  Index: HostIsLocal.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/org/apache/james/transport/matchers/HostIsLocal.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HostIsLocal.java	2000/10/17 12:53:44	1.5
  +++ HostIsLocal.java	2001/03/31 02:40:44	1.6
  @@ -18,16 +18,7 @@
    */
   public class HostIsLocal extends GenericRecipientMatcher {
   
  -    private Collection localhosts;
  -
  -    public void init() {
  -        localhosts = new Vector();
  -        for (Iterator i = getMailetContext().getServerNames().iterator(); i.hasNext(); ) {
  -            localhosts.add(i.next().toString().toLowerCase());
  -        }
  -    }
  -
       public boolean matchRecipient(MailAddress recipient) {
  -        return localhosts.contains(recipient.getHost().toLowerCase());
  +        return getMailetContext().isLocalServer(recipient.getHost().toLowerCase());
       }
   }
  
  
  
  1.7       +3 -13     jakarta-james/src/org/apache/james/transport/matchers/RecipientIsLocal.java
  
  Index: RecipientIsLocal.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/org/apache/james/transport/matchers/RecipientIsLocal.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RecipientIsLocal.java	2000/10/29 19:46:33	1.6
  +++ RecipientIsLocal.java	2001/03/31 02:40:44	1.7
  @@ -18,20 +18,10 @@
    */
   public class RecipientIsLocal extends GenericRecipientMatcher {
   
  -    private Collection localhosts;
  -
  -    public void init() {
  -        //This shouldn't change after startup
  -        localhosts = new Vector();
  -        for (Iterator i = getMailetContext().getServerNames().iterator(); i.hasNext(); ) {
  -            localhosts.add(i.next().toString().toLowerCase());
  -        }
  -    }
  -
       public boolean matchRecipient(MailAddress recipient) {
  +        MailetContext mailetContext = getMailetContext();
           //This might change after startup
  -        Collection users = getMailetContext().getLocalUsers();
  -        return localhosts.contains(recipient.getHost().toLowerCase())
  -                && users.contains(recipient.getUser());
  +        return mailetContext.isLocalServer(recipient.getHost().toLowerCase())
  +            && mailetContext.isLocalUser(recipient.getUser());
       }
   }
  
  
  

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