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 ro...@apache.org on 2017/01/11 09:26:22 UTC

[34/50] [abbrv] james-project git commit: MAILET-115 Convert RedirectNotify to interface

MAILET-115 Convert RedirectNotify to interface


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/4e81a893
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4e81a893
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4e81a893

Branch: refs/heads/master
Commit: 4e81a8934f49234fbaadba3e4acd9d4c46728481
Parents: e59ef33
Author: Antoine Duprat <ad...@apache.org>
Authored: Thu Nov 17 16:02:19 2016 +0100
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Wed Jan 11 10:03:31 2017 +0700

----------------------------------------------------------------------
 .../apache/james/transport/mailets/Bounce.java  | 54 +++++++++++---
 .../james/transport/mailets/DSNBounce.java      | 49 ++++++++++---
 .../apache/james/transport/mailets/Forward.java | 54 +++++++++++---
 .../transport/mailets/NotifyPostmaster.java     | 54 +++++++++++---
 .../james/transport/mailets/NotifySender.java   | 54 +++++++++++---
 .../james/transport/mailets/Redirect.java       | 54 +++++++++++---
 .../apache/james/transport/mailets/Resend.java  | 54 +++++++++++---
 .../mailets/redirect/ProcessRedirectNotify.java |  2 +-
 .../mailets/redirect/RedirectNotify.java        | 74 +++++++-------------
 .../transport/util/SpecialAddressesUtils.java   | 26 +++----
 .../util/SpecialAddressesUtilsTest.java         | 19 ++---
 11 files changed, 341 insertions(+), 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
index 2b1d3e2..ad25df2 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
@@ -21,14 +21,16 @@ package org.apache.james.transport.mailets;
 
 import java.util.List;
 
+import javax.inject.Inject;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 
-import org.apache.james.transport.mailets.redirect.RedirectNotify;
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.redirect.InitParameters;
 import org.apache.james.transport.mailets.redirect.NotifyMailetInitParameters;
 import org.apache.james.transport.mailets.redirect.NotifyMailetsMessage;
 import org.apache.james.transport.mailets.redirect.ProcessRedirectNotify;
+import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.james.transport.mailets.utils.MimeMessageModifier;
 import org.apache.james.transport.mailets.utils.MimeMessageUtils;
@@ -39,6 +41,7 @@ import org.apache.james.transport.util.SpecialAddressesUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.GenericMailet;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
@@ -117,12 +120,13 @@ import com.google.common.collect.ImmutableList;
  *
  * @since 2.2.0
  */
-public class Bounce extends RedirectNotify {
+public class Bounce extends GenericMailet implements RedirectNotify {
 
     private static final String[] CONFIGURABLE_PARAMETERS = new String[] {
             "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError" };
     private static final List<MailAddress> RECIPIENTS = ImmutableList.of(SpecialAddress.REVERSE_PATH);
     private static final List<InternetAddress> TO = ImmutableList.of(SpecialAddress.REVERSE_PATH.toInternetAddress());
+    private DNSService dns;
 
     @Override
     public String getMailetInfo() {
@@ -135,10 +139,38 @@ public class Bounce extends RedirectNotify {
     }
 
     @Override
-    protected String[] getAllowedInitParameters() {
+    public String[] getAllowedInitParameters() {
         return CONFIGURABLE_PARAMETERS;
     }
 
+    @Inject
+    @Override
+    public void setDNSService(DNSService dns) {
+        this.dns = dns;
+    }
+
+    @Override
+    public DNSService getDNSService() {
+        return dns;
+    }
+
+    @Override
+    public void init() throws MessagingException {
+        if (getInitParameters().isDebug()) {
+            log("Initializing");
+        }
+
+        // check that all init parameters have been declared in
+        // allowedInitParameters
+        checkInitParameters(getAllowedInitParameters());
+
+        if (getInitParameters().isStatic()) {
+            if (getInitParameters().isDebug()) {
+                log(getInitParameters().asString());
+            }
+        }
+    }
+
     @Override
     public String getMessage(Mail originalMail) throws MessagingException {
         return new NotifyMailetsMessage().generateMessage(getInitParameters().getMessage(), originalMail);
@@ -150,7 +182,7 @@ public class Bounce extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
         return RecipientsUtils.from(this).getRecipients(originalMail);
     }
 
@@ -160,7 +192,7 @@ public class Bounce extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getTo(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getTo(Mail originalMail) throws MessagingException {
         return TosUtils.from(this).getTo(originalMail);
     }
 
@@ -170,17 +202,17 @@ public class Bounce extends RedirectNotify {
     }
 
     @Override
-    protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {
+    public MailAddress getReplyTo(Mail originalMail) throws MessagingException {
         return ReplyToUtils.from(getReplyTo()).getReplyTo(originalMail);
     }
 
     @Override
-    protected MailAddress getReversePath(Mail originalMail) {
+    public MailAddress getReversePath(Mail originalMail) {
         return SpecialAddress.NULL;
     }
 
     @Override
-    protected MailAddress getReversePath() throws MessagingException {
+    public MailAddress getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS);
     }
@@ -192,12 +224,12 @@ public class Bounce extends RedirectNotify {
     }
 
     @Override
-    protected Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
+    public Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
         return SenderUtils.from(getSender()).getSender(originalMail);
     }
 
     @Override
-    protected Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
+    public Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
         return new MimeMessageUtils(originalMail.getMessage()).subjectWithPrefix(subjectPrefix);
     }
 
@@ -223,7 +255,7 @@ public class Bounce extends RedirectNotify {
     }
 
     @Override
-    protected MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
+    public MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
         return new MimeMessageModifier(originalMail.getMessage());
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
index 33fba54..a88f4ae 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
@@ -25,6 +25,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.regex.Pattern;
 
+import javax.inject.Inject;
 import javax.mail.MessagingException;
 import javax.mail.Session;
 import javax.mail.internet.InternetAddress;
@@ -32,6 +33,7 @@ import javax.mail.internet.MimeBodyPart;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.james.core.MailImpl;
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.redirect.InitParameters;
 import org.apache.james.transport.mailets.redirect.MailModifier;
 import org.apache.james.transport.mailets.redirect.NotifyMailetInitParameters;
@@ -50,6 +52,7 @@ import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.base.DateFormats;
+import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.base.StringUtils;
 import org.apache.mailet.base.mail.MimeMultipartReport;
@@ -97,7 +100,7 @@ import com.google.common.collect.ImmutableList;
  * @see org.apache.james.transport.mailets.AbstractNotify
  */
 
-public class DSNBounce extends RedirectNotify {
+public class DSNBounce extends GenericMailet implements RedirectNotify {
 
     private static final String[] CONFIGURABLE_PARAMETERS = new String[]{ "debug", "passThrough", "messageString", "attachment", "sender", "prefix" };
     private static final List<MailAddress> RECIPIENT_MAIL_ADDRESSES = ImmutableList.of(SpecialAddress.REVERSE_PATH);
@@ -109,10 +112,23 @@ public class DSNBounce extends RedirectNotify {
     private static final String LINE_BREAK = "\n";
 
     private String messageString = null;
+    private DNSService dns;
 
     @Override
     public void init() throws MessagingException {
-        super.init();
+        if (getInitParameters().isDebug()) {
+            log("Initializing");
+        }
+
+        // check that all init parameters have been declared in
+        // allowedInitParameters
+        checkInitParameters(getAllowedInitParameters());
+
+        if (getInitParameters().isStatic()) {
+            if (getInitParameters().isDebug()) {
+                log(getInitParameters().asString());
+            }
+        }
         messageString = getInitParameter("messageString",
                 "Hi. This is the James mail server at [machine].\nI'm afraid I wasn't able to deliver your message to the following addresses.\nThis is a permanent error; I've given up. Sorry it didn't work out.  Below\nI include the list of recipients and the reason why I was unable to deliver\nyour message.\n");
     }
@@ -128,10 +144,21 @@ public class DSNBounce extends RedirectNotify {
     }
 
     @Override
-    protected String[] getAllowedInitParameters() {
+    public String[] getAllowedInitParameters() {
         return CONFIGURABLE_PARAMETERS;
     }
 
+    @Inject
+    @Override
+    public void setDNSService(DNSService dns) {
+        this.dns = dns;
+    }
+
+    @Override
+    public DNSService getDNSService() {
+        return dns;
+    }
+
     @Override
     public String getMessage(Mail originalMail) throws MessagingException {
         return new NotifyMailetsMessage().generateMessage(getInitParameters().getMessage(), originalMail);
@@ -143,7 +170,7 @@ public class DSNBounce extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
         return RecipientsUtils.from(this).getRecipients(originalMail);
     }
 
@@ -153,7 +180,7 @@ public class DSNBounce extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getTo(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getTo(Mail originalMail) throws MessagingException {
         return TosUtils.from(this).getTo(originalMail);
     }
 
@@ -163,18 +190,18 @@ public class DSNBounce extends RedirectNotify {
     }
 
     @Override
-    protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {
+    public MailAddress getReplyTo(Mail originalMail) throws MessagingException {
         return ReplyToUtils.from(getReplyTo()).getReplyTo(originalMail);
     }
 
     @Override
-    protected MailAddress getReversePath() throws MessagingException {
+    public MailAddress getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS);
     }
 
     @Override
-    protected MailAddress getReversePath(Mail originalMail) {
+    public MailAddress getReversePath(Mail originalMail) {
         return SpecialAddress.NULL;
     }
 
@@ -185,12 +212,12 @@ public class DSNBounce extends RedirectNotify {
     }
 
     @Override
-    protected Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
+    public Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
         return SenderUtils.from(getSender()).getSender(originalMail);
     }
 
     @Override
-    protected Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
+    public Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
         return new MimeMessageUtils(originalMail.getMessage()).subjectWithPrefix(subjectPrefix);
     }
 
@@ -411,7 +438,7 @@ public class DSNBounce extends RedirectNotify {
     }
 
     @Override
-    protected MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
+    public MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
         return new MimeMessageModifier(originalMail.getMessage());
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
index fcab123..fda5f23 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
@@ -21,15 +21,17 @@ package org.apache.james.transport.mailets;
 
 import java.util.List;
 
+import javax.inject.Inject;
 import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 import javax.mail.internet.InternetAddress;
 
-import org.apache.james.transport.mailets.redirect.RedirectNotify;
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.redirect.AddressExtractor;
 import org.apache.james.transport.mailets.redirect.InitParameters;
 import org.apache.james.transport.mailets.redirect.ProcessRedirectNotify;
 import org.apache.james.transport.mailets.redirect.RedirectMailetInitParameters;
+import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.TypeCode;
 import org.apache.james.transport.mailets.utils.MimeMessageModifier;
 import org.apache.james.transport.util.RecipientsUtils;
@@ -38,6 +40,7 @@ import org.apache.james.transport.util.SenderUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.GenericMailet;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Strings;
@@ -87,12 +90,13 @@ import com.google.common.collect.ImmutableList;
  * for backward compatibility.
  * </p>
  */
-public class Forward extends RedirectNotify {
+public class Forward extends GenericMailet implements RedirectNotify {
 
     private static final String[] CONFIGURABLE_PARAMETERS = new String[] {
             "debug", "passThrough", "fakeDomainCheck", "forwardto", "forwardTo" };
     private static final List<String> ALLOWED_SPECIALS = ImmutableList.of(
             "postmaster", "sender", "from", "replyTo", "reversePath", "unaltered", "recipients", "to", "null");
+    private DNSService dns;
 
     @Override
     public String getMailetInfo() {
@@ -105,10 +109,38 @@ public class Forward extends RedirectNotify {
     }
 
     @Override
-    protected String[] getAllowedInitParameters() {
+    public String[] getAllowedInitParameters() {
         return CONFIGURABLE_PARAMETERS;
     }
 
+    @Inject
+    @Override
+    public void setDNSService(DNSService dns) {
+        this.dns = dns;
+    }
+
+    @Override
+    public DNSService getDNSService() {
+        return dns;
+    }
+
+    @Override
+    public void init() throws MessagingException {
+        if (getInitParameters().isDebug()) {
+            log("Initializing");
+        }
+
+        // check that all init parameters have been declared in
+        // allowedInitParameters
+        checkInitParameters(getAllowedInitParameters());
+
+        if (getInitParameters().isStatic()) {
+            if (getInitParameters().isDebug()) {
+                log(getInitParameters().asString());
+            }
+        }
+    }
+
     @Override
     public String getMessage(Mail originalMail) throws MessagingException {
         return getInitParameters().getMessage();
@@ -124,7 +156,7 @@ public class Forward extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
         return RecipientsUtils.from(this).getRecipients(originalMail);
     }
 
@@ -164,7 +196,7 @@ public class Forward extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getTo(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getTo(Mail originalMail) throws MessagingException {
         return TosUtils.from(this).getTo(originalMail);
     }
 
@@ -174,17 +206,17 @@ public class Forward extends RedirectNotify {
     }
 
     @Override
-    protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {
+    public MailAddress getReplyTo(Mail originalMail) throws MessagingException {
         return ReplyToUtils.from(getReplyTo()).getReplyTo(originalMail);
     }
 
     @Override
-    protected MailAddress getReversePath() throws MessagingException {
+    public MailAddress getReversePath() throws MessagingException {
         return null;
     }
 
     @Override
-    protected MailAddress getReversePath(Mail originalMail) throws MessagingException {
+    public MailAddress getReversePath(Mail originalMail) throws MessagingException {
         return null;
     }
 
@@ -194,17 +226,17 @@ public class Forward extends RedirectNotify {
     }
 
     @Override
-    protected Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
+    public Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
         return SenderUtils.from(getSender()).getSender(originalMail);
     }
 
     @Override
-    protected Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
+    public Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
         return Optional.absent();
     }
 
     @Override
-    protected MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
+    public MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
         return new MimeMessageModifier(newMail.getMessage());
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
index 47f6ece..9c1684b 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
@@ -21,15 +21,17 @@ package org.apache.james.transport.mailets;
 
 import java.util.List;
 
+import javax.inject.Inject;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 
-import org.apache.james.transport.mailets.redirect.RedirectNotify;
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.redirect.AddressExtractor;
 import org.apache.james.transport.mailets.redirect.InitParameters;
 import org.apache.james.transport.mailets.redirect.NotifyMailetInitParameters;
 import org.apache.james.transport.mailets.redirect.NotifyMailetsMessage;
 import org.apache.james.transport.mailets.redirect.ProcessRedirectNotify;
+import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.james.transport.mailets.utils.MimeMessageModifier;
 import org.apache.james.transport.mailets.utils.MimeMessageUtils;
@@ -41,6 +43,7 @@ import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.MailetConfig;
+import org.apache.mailet.base.GenericMailet;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
@@ -117,13 +120,14 @@ import com.google.common.collect.ImmutableList;
  * are kept for backward compatibility.
  * </p>
  */
-public class NotifyPostmaster extends RedirectNotify {
+public class NotifyPostmaster extends GenericMailet implements RedirectNotify {
 
     private static final String[] CONFIGURABLE_PARAMETERS = new String[]{
             "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "to" };
     private static final List<String> ALLOWED_SPECIALS = ImmutableList.of("postmaster", "unaltered");
 
     private Optional<String> to = Optional.absent();
+    private DNSService dns;
 
     @Override
     public void init(MailetConfig mailetConfig) throws MessagingException {
@@ -142,10 +146,38 @@ public class NotifyPostmaster extends RedirectNotify {
     }
 
     @Override
-    protected String[] getAllowedInitParameters() {
+    public String[] getAllowedInitParameters() {
         return CONFIGURABLE_PARAMETERS;
     }
 
+    @Inject
+    @Override
+    public void setDNSService(DNSService dns) {
+        this.dns = dns;
+    }
+
+    @Override
+    public DNSService getDNSService() {
+        return dns;
+    }
+
+    @Override
+    public void init() throws MessagingException {
+        if (getInitParameters().isDebug()) {
+            log("Initializing");
+        }
+
+        // check that all init parameters have been declared in
+        // allowedInitParameters
+        checkInitParameters(getAllowedInitParameters());
+
+        if (getInitParameters().isStatic()) {
+            if (getInitParameters().isDebug()) {
+                log(getInitParameters().asString());
+            }
+        }
+    }
+
     @Override
     public String getMessage(Mail originalMail) throws MessagingException {
         return new NotifyMailetsMessage().generateMessage(getInitParameters().getMessage(), originalMail);
@@ -157,7 +189,7 @@ public class NotifyPostmaster extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
         return RecipientsUtils.from(this).getRecipients(originalMail);
     }
 
@@ -176,7 +208,7 @@ public class NotifyPostmaster extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getTo(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getTo(Mail originalMail) throws MessagingException {
         return TosUtils.from(this).getTo(originalMail);
     }
 
@@ -186,18 +218,18 @@ public class NotifyPostmaster extends RedirectNotify {
     }
 
     @Override
-    protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {
+    public MailAddress getReplyTo(Mail originalMail) throws MessagingException {
         return ReplyToUtils.from(getReplyTo()).getReplyTo(originalMail);
     }
 
     @Override
-    protected MailAddress getReversePath() throws MessagingException {
+    public MailAddress getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS);
     }
 
     @Override
-    protected MailAddress getReversePath(Mail originalMail) throws MessagingException {
+    public MailAddress getReversePath(Mail originalMail) throws MessagingException {
         return getSender(originalMail).orNull();
     }
 
@@ -208,17 +240,17 @@ public class NotifyPostmaster extends RedirectNotify {
     }
 
     @Override
-    protected Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
+    public Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
         return SenderUtils.from(getSender()).getSender(originalMail);
     }
 
     @Override
-    protected Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
+    public Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
         return new MimeMessageUtils(originalMail.getMessage()).subjectWithPrefix(subjectPrefix);
     }
 
     @Override
-    protected MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
+    public MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
         return new MimeMessageModifier(originalMail.getMessage());
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
index 11a46cb..c018706 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
@@ -21,15 +21,17 @@ package org.apache.james.transport.mailets;
 
 import java.util.List;
 
+import javax.inject.Inject;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 
-import org.apache.james.transport.mailets.redirect.RedirectNotify;
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.redirect.AddressExtractor;
 import org.apache.james.transport.mailets.redirect.InitParameters;
 import org.apache.james.transport.mailets.redirect.NotifyMailetInitParameters;
 import org.apache.james.transport.mailets.redirect.NotifyMailetsMessage;
 import org.apache.james.transport.mailets.redirect.ProcessRedirectNotify;
+import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.james.transport.mailets.utils.MimeMessageModifier;
 import org.apache.james.transport.mailets.utils.MimeMessageUtils;
@@ -41,6 +43,7 @@ import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.MailetConfig;
+import org.apache.mailet.base.GenericMailet;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
@@ -116,7 +119,7 @@ import com.google.common.collect.ImmutableList;
  * are kept for backward compatibility.
  * </p>
  */
-public class NotifySender extends RedirectNotify {
+public class NotifySender extends GenericMailet implements RedirectNotify {
 
     private static final String[] CONFIGURABLE_PARAMETERS = new String[]{
             "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "to" };
@@ -124,6 +127,7 @@ public class NotifySender extends RedirectNotify {
     private static final List<String> ALLOWED_SPECIALS = ImmutableList.of("sender", "unaltered", "from");
 
     private Optional<String> to = Optional.absent();
+    private DNSService dns;
 
     @Override
     public void init(MailetConfig mailetConfig) throws MessagingException {
@@ -142,10 +146,38 @@ public class NotifySender extends RedirectNotify {
     }
 
     @Override
-    protected String[] getAllowedInitParameters() {
+    public String[] getAllowedInitParameters() {
         return CONFIGURABLE_PARAMETERS;
     }
 
+    @Inject
+    @Override
+    public void setDNSService(DNSService dns) {
+        this.dns = dns;
+    }
+
+    @Override
+    public DNSService getDNSService() {
+        return dns;
+    }
+
+    @Override
+    public void init() throws MessagingException {
+        if (getInitParameters().isDebug()) {
+            log("Initializing");
+        }
+
+        // check that all init parameters have been declared in
+        // allowedInitParameters
+        checkInitParameters(getAllowedInitParameters());
+
+        if (getInitParameters().isStatic()) {
+            if (getInitParameters().isDebug()) {
+                log(getInitParameters().asString());
+            }
+        }
+    }
+
     @Override
     public String getMessage(Mail originalMail) throws MessagingException {
         return new NotifyMailetsMessage().generateMessage(getInitParameters().getMessage(), originalMail);
@@ -157,7 +189,7 @@ public class NotifySender extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
         return RecipientsUtils.from(this).getRecipients(originalMail);
     }
 
@@ -176,7 +208,7 @@ public class NotifySender extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getTo(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getTo(Mail originalMail) throws MessagingException {
         return TosUtils.from(this).getTo(originalMail);
     }
 
@@ -186,18 +218,18 @@ public class NotifySender extends RedirectNotify {
     }
 
     @Override
-    protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {
+    public MailAddress getReplyTo(Mail originalMail) throws MessagingException {
         return ReplyToUtils.from(getReplyTo()).getReplyTo(originalMail);
     }
 
     @Override
-    protected MailAddress getReversePath() throws MessagingException {
+    public MailAddress getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS);
     }
 
     @Override
-    protected MailAddress getReversePath(Mail originalMail) throws MessagingException {
+    public MailAddress getReversePath(Mail originalMail) throws MessagingException {
         return getSender(originalMail).orNull();
     }
 
@@ -208,17 +240,17 @@ public class NotifySender extends RedirectNotify {
     }
 
     @Override
-    protected Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
+    public Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
         return SenderUtils.from(getSender()).getSender(originalMail);
     }
 
     @Override
-    protected Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
+    public Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
         return new MimeMessageUtils(originalMail.getMessage()).subjectWithPrefix(subjectPrefix);
     }
 
     @Override
-    protected MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
+    public MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
         return new MimeMessageModifier(originalMail.getMessage());
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
index 1e86f56..e5c25d1 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
@@ -21,14 +21,16 @@ package org.apache.james.transport.mailets;
 
 import java.util.List;
 
+import javax.inject.Inject;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 
-import org.apache.james.transport.mailets.redirect.RedirectNotify;
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.redirect.AddressExtractor;
 import org.apache.james.transport.mailets.redirect.InitParameters;
 import org.apache.james.transport.mailets.redirect.ProcessRedirectNotify;
 import org.apache.james.transport.mailets.redirect.RedirectMailetInitParameters;
+import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.TypeCode;
 import org.apache.james.transport.mailets.utils.MimeMessageModifier;
 import org.apache.james.transport.mailets.utils.MimeMessageUtils;
@@ -40,6 +42,7 @@ import org.apache.james.transport.util.SpecialAddressesUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.GenericMailet;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Strings;
@@ -296,12 +299,13 @@ import com.google.common.collect.ImmutableList;
  * </p>
  */
 
-public class Redirect extends RedirectNotify {
+public class Redirect extends GenericMailet implements RedirectNotify {
 
     private static final String[] CONFIGURABLE_PARAMETERS = new String[] {
             "static", "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "recipients", "to", "replyTo", "replyto", "reversePath", "sender", "subject", "prefix", "attachError", "isReply" };
     private static final List<String> ALLOWED_SPECIALS = ImmutableList.of(
             "postmaster", "sender", "from", "replyTo", "reversePath", "unaltered", "recipients", "to", "null");
+    private DNSService dns;
 
     @Override
     public String getMailetInfo() {
@@ -314,10 +318,38 @@ public class Redirect extends RedirectNotify {
     }
 
     @Override
-    protected String[] getAllowedInitParameters() {
+    public String[] getAllowedInitParameters() {
         return CONFIGURABLE_PARAMETERS;
     }
 
+    @Inject
+    @Override
+    public void setDNSService(DNSService dns) {
+        this.dns = dns;
+    }
+
+    @Override
+    public DNSService getDNSService() {
+        return dns;
+    }
+
+    @Override
+    public void init() throws MessagingException {
+        if (getInitParameters().isDebug()) {
+            log("Initializing");
+        }
+
+        // check that all init parameters have been declared in
+        // allowedInitParameters
+        checkInitParameters(getAllowedInitParameters());
+
+        if (getInitParameters().isStatic()) {
+            if (getInitParameters().isDebug()) {
+                log(getInitParameters().asString());
+            }
+        }
+    }
+
     @Override
     public String getMessage(Mail originalMail) throws MessagingException {
         return getInitParameters().getMessage();
@@ -347,7 +379,7 @@ public class Redirect extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
         return RecipientsUtils.from(this).getRecipients(originalMail);
     }
 
@@ -371,7 +403,7 @@ public class Redirect extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getTo(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getTo(Mail originalMail) throws MessagingException {
         return TosUtils.from(this).getTo(originalMail);
     }
 
@@ -392,18 +424,18 @@ public class Redirect extends RedirectNotify {
     }
 
     @Override
-    protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {
+    public MailAddress getReplyTo(Mail originalMail) throws MessagingException {
         return ReplyToUtils.from(getReplyTo()).getReplyTo(originalMail);
     }
 
     @Override
-    protected MailAddress getReversePath() throws MessagingException {
+    public MailAddress getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), ImmutableList.of("postmaster", "sender", "null"));
     }
 
     @Override
-    protected MailAddress getReversePath(Mail originalMail) throws MessagingException {
+    public MailAddress getReversePath(Mail originalMail) throws MessagingException {
         MailAddress reversePath = retrieveReversePath();
         if (reversePath != null) {
             return reversePath;
@@ -428,17 +460,17 @@ public class Redirect extends RedirectNotify {
     }
 
     @Override
-    protected Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
+    public Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
         return SenderUtils.from(getSender()).getSender(originalMail);
     }
 
     @Override
-    protected Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
+    public Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
         return new MimeMessageUtils(newMail.getMessage()).subjectWithPrefix(subjectPrefix, originalMail, getInitParameters().getSubject());
     }
 
     @Override
-    protected MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
+    public MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
         return new MimeMessageModifier(newMail.getMessage());
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
index bde2c78..c1cfe12 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
@@ -21,14 +21,16 @@ package org.apache.james.transport.mailets;
 
 import java.util.List;
 
+import javax.inject.Inject;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 
-import org.apache.james.transport.mailets.redirect.RedirectNotify;
+import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.transport.mailets.redirect.AddressExtractor;
 import org.apache.james.transport.mailets.redirect.InitParameters;
 import org.apache.james.transport.mailets.redirect.ProcessRedirectNotify;
 import org.apache.james.transport.mailets.redirect.RedirectMailetInitParameters;
+import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.utils.MimeMessageModifier;
 import org.apache.james.transport.mailets.utils.MimeMessageUtils;
 import org.apache.james.transport.util.MailAddressUtils;
@@ -39,6 +41,7 @@ import org.apache.james.transport.util.SpecialAddressesUtils;
 import org.apache.james.transport.util.TosUtils;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.GenericMailet;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Strings;
@@ -291,10 +294,11 @@ import com.google.common.collect.ImmutableList;
  * @since 2.2.0
  */
 
-public class Resend extends RedirectNotify {
+public class Resend extends GenericMailet implements RedirectNotify {
 
     private static final String[] CONFIGURABLE_PARAMETERS = new String[] {
             "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "recipients", "to", "replyTo", "replyto", "reversePath", "sender", "subject", "prefix", "attachError", "isReply" };
+    private DNSService dns;
 
     @Override
     public String getMailetInfo() {
@@ -307,10 +311,38 @@ public class Resend extends RedirectNotify {
     }
 
     @Override
-    protected String[] getAllowedInitParameters() {
+    public String[] getAllowedInitParameters() {
         return CONFIGURABLE_PARAMETERS;
     }
 
+    @Inject
+    @Override
+    public void setDNSService(DNSService dns) {
+        this.dns = dns;
+    }
+
+    @Override
+    public DNSService getDNSService() {
+        return dns;
+    }
+
+    @Override
+    public void init() throws MessagingException {
+        if (getInitParameters().isDebug()) {
+            log("Initializing");
+        }
+
+        // check that all init parameters have been declared in
+        // allowedInitParameters
+        checkInitParameters(getAllowedInitParameters());
+
+        if (getInitParameters().isStatic()) {
+            if (getInitParameters().isDebug()) {
+                log(getInitParameters().asString());
+            }
+        }
+    }
+
     @Override
     public String getMessage(Mail originalMail) throws MessagingException {
         return getInitParameters().getMessage();
@@ -325,7 +357,7 @@ public class Resend extends RedirectNotify {
     }
 
     @Override
-    protected List<MailAddress> getTo(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getTo(Mail originalMail) throws MessagingException {
         return TosUtils.from(this).getTo(originalMail);
     }
 
@@ -346,7 +378,7 @@ public class Resend extends RedirectNotify {
     }
 
     @Override
-    protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {
+    public MailAddress getReplyTo(Mail originalMail) throws MessagingException {
         return ReplyToUtils.from(getReplyTo()).getReplyTo(originalMail);
     }
 
@@ -363,18 +395,18 @@ public class Resend extends RedirectNotify {
       }
 
     @Override
-    protected List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
+    public List<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
         return RecipientsUtils.from(this).getRecipients(originalMail);
     }
 
     @Override
-    protected MailAddress getReversePath() throws MessagingException {
+    public MailAddress getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS);
     }
 
     @Override
-    protected MailAddress getReversePath(Mail originalMail) throws MessagingException {
+    public MailAddress getReversePath(Mail originalMail) throws MessagingException {
         MailAddress reversePath = getReversePath();
         if (reversePath != null) {
             if (MailAddressUtils.isUnalteredOrReversePathOrSender(reversePath)) {
@@ -391,17 +423,17 @@ public class Resend extends RedirectNotify {
     }
 
     @Override
-    protected Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
+    public Optional<MailAddress> getSender(Mail originalMail) throws MessagingException {
         return SenderUtils.from(getSender()).getSender(originalMail);
     }
 
     @Override
-    protected Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
+    public Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
         return new MimeMessageUtils(newMail.getMessage()).subjectWithPrefix(subjectPrefix, originalMail, getInitParameters().getSubject());
     }
 
     @Override
-    protected MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
+    public MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException {
         return new MimeMessageModifier(newMail.getMessage());
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java
index df4eba4..cd7d5e3 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java
@@ -49,7 +49,7 @@ public class ProcessRedirectNotify {
             MailModifier mailModifier = MailModifier.builder()
                     .mailet(mailet)
                     .mail(newMail)
-                    .dns(mailet.dns)
+                    .dns(mailet.getDNSService())
                     .build();
             mailModifier.setRemoteAddr();
             mailModifier.setRemoteHost();

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
index aa5c19e..c72fad5 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
@@ -21,7 +21,6 @@ package org.apache.james.transport.mailets.redirect;
 
 import java.util.List;
 
-import javax.inject.Inject;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 
@@ -30,7 +29,8 @@ import org.apache.james.transport.mailets.Redirect;
 import org.apache.james.transport.mailets.utils.MimeMessageModifier;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
-import org.apache.mailet.base.GenericMailet;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.MailetConfig;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
@@ -134,21 +134,21 @@ import com.google.common.collect.ImmutableList;
  * @since 2.2.0
  */
 
-public abstract class RedirectNotify extends GenericMailet {
+public interface RedirectNotify extends Mailet, MailetConfig {
 
-    public static final List<String> REVERSE_PATH_ALLOWED_SPECIALS = ImmutableList.of("postmaster", "sender", "null", "unaltered");
-    public static final List<String> SENDER_ALLOWED_SPECIALS = ImmutableList.of("postmaster", "sender", "unaltered");
+    List<String> REVERSE_PATH_ALLOWED_SPECIALS = ImmutableList.of("postmaster", "sender", "null", "unaltered");
+    List<String> SENDER_ALLOWED_SPECIALS = ImmutableList.of("postmaster", "sender", "unaltered");
 
-    public abstract InitParameters getInitParameters();
+    InitParameters getInitParameters();
 
-    protected abstract String[] getAllowedInitParameters();
+    String[] getAllowedInitParameters();
 
-    protected DNSService dns;
+    void setDNSService(DNSService dns);
 
-    @Inject
-    public void setDNSService(DNSService dns) {
-        this.dns = dns;
-    }
+    DNSService getDNSService();
+
+    void log(String message);
+    void log(String message, Throwable t);
 
     /**
      * Gets the <code>message</code> property, built dynamically using the
@@ -156,7 +156,7 @@ public abstract class RedirectNotify extends GenericMailet {
      *
      * @return {@link #getMessage()}
      */
-    public abstract String getMessage(Mail originalMail) throws MessagingException;
+    String getMessage(Mail originalMail) throws MessagingException;
 
     /**
      * Gets the <code>recipients</code> property. Returns the collection of
@@ -172,7 +172,7 @@ public abstract class RedirectNotify extends GenericMailet {
      *         <code>SpecialAddress.RECIPIENTS</code> or <code>null</code> if
      *         missing
      */
-    public abstract List<MailAddress> getRecipients() throws MessagingException; 
+    List<MailAddress> getRecipients() throws MessagingException; 
 
     /**
      * Gets the <code>recipients</code> property, built dynamically using the
@@ -180,7 +180,7 @@ public abstract class RedirectNotify extends GenericMailet {
      *
      * @return {@link #replaceMailAddresses} on {@link #getRecipients()},
      */
-    protected abstract List<MailAddress> getRecipients(Mail originalMail) throws MessagingException; 
+    List<MailAddress> getRecipients(Mail originalMail) throws MessagingException; 
 
     /**
      * Gets the <code>to</code> property. Returns the "To:" recipients of the
@@ -194,7 +194,7 @@ public abstract class RedirectNotify extends GenericMailet {
      *         <code>SpecialAddress.UNALTERED</code> or
      *         <code>SpecialAddress.TO</code> or <code>null</code> if missing
      */
-    public abstract List<InternetAddress> getTo() throws MessagingException;
+    List<InternetAddress> getTo() throws MessagingException;
 
     /**
      * Gets the <code>to</code> property, built dynamically using the original
@@ -204,7 +204,7 @@ public abstract class RedirectNotify extends GenericMailet {
      *
      * @return {@link #replaceInternetAddresses} on {@link #getRecipients()},
      */
-    protected abstract List<MailAddress> getTo(Mail originalMail) throws MessagingException;
+    List<MailAddress> getTo(Mail originalMail) throws MessagingException;
 
     /**
      * Gets the <code>replyto</code> property. Returns the Reply-To address of
@@ -215,7 +215,7 @@ public abstract class RedirectNotify extends GenericMailet {
      *         <code>SpecialAddress.UNALTERED</code> or
      *         <code>SpecialAddress.NULL</code> or <code>null</code> if missing
      */
-    public abstract MailAddress getReplyTo() throws MessagingException;
+    MailAddress getReplyTo() throws MessagingException;
 
     /**
      * Gets the <code>replyTo</code> property, built dynamically using the
@@ -225,7 +225,7 @@ public abstract class RedirectNotify extends GenericMailet {
      *         <code>SpecialAddress.UNALTERED</code> if applicable with null and
      *         <code>SpecialAddress.SENDER</code> with the original mail sender
      */
-    protected abstract MailAddress getReplyTo(Mail originalMail) throws MessagingException;
+    MailAddress getReplyTo(Mail originalMail) throws MessagingException;
 
     /**
      * Gets the <code>reversePath</code> property. Returns the reverse-path of
@@ -237,7 +237,7 @@ public abstract class RedirectNotify extends GenericMailet {
      *         <code>SpecialAddress.UNALTERED</code> or <code>null</code> if
      *         missing
      */
-    protected abstract MailAddress getReversePath() throws MessagingException; 
+    MailAddress getReversePath() throws MessagingException; 
 
     /**
      * Gets the <code>reversePath</code> property, built dynamically using the
@@ -250,7 +250,7 @@ public abstract class RedirectNotify extends GenericMailet {
      *         but not replacing <code>SpecialAddress.NULL</code> that will be
      *         handled by {@link #setReversePath}
      */
-    protected abstract MailAddress getReversePath(Mail originalMail) throws MessagingException;
+    MailAddress getReversePath(Mail originalMail) throws MessagingException;
 
     /**
      * Gets the <code>sender</code> property. Returns the new sender as a
@@ -261,7 +261,7 @@ public abstract class RedirectNotify extends GenericMailet {
      *         <code>SpecialAddress.UNALTERED</code> or <code>null</code> if
      *         missing
      */
-    public abstract MailAddress getSender() throws MessagingException; 
+    MailAddress getSender() throws MessagingException; 
 
     /**
      * Gets the <code>sender</code> property, built dynamically using the
@@ -271,36 +271,14 @@ public abstract class RedirectNotify extends GenericMailet {
      *         <code>SpecialAddress.UNALTERED</code> and
      *         <code>SpecialAddress.SENDER</code> if applicable with null
      */
-    protected abstract Optional<MailAddress> getSender(Mail originalMail) throws MessagingException;
+    Optional<MailAddress> getSender(Mail originalMail) throws MessagingException;
 
     /**
      * Builds the subject of <i>newMail</i> appending the subject of
      * <i>originalMail</i> to <i>subjectPrefix</i>. Is a "setX(Mail, Tx, Mail)"
      * method.
      */
-    protected abstract Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException;
-
-    /**
-     * Mailet initialization routine. Will setup static values for each "x"
-     * initialization parameter in config.xml, using getX(), if
-     * {@link #isStatic()} returns true.
-     */
-    @Override
-    public void init() throws MessagingException {
-        if (getInitParameters().isDebug()) {
-            log("Initializing");
-        }
-
-        // check that all init parameters have been declared in
-        // allowedInitParameters
-        checkInitParameters(getAllowedInitParameters());
-
-        if (getInitParameters().isStatic()) {
-            if (getInitParameters().isDebug()) {
-                log(getInitParameters().asString());
-            }
-        }
-    }
+    Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException;
 
     /**
      * Service does the hard work,and redirects the originalMail in the form
@@ -310,7 +288,7 @@ public abstract class RedirectNotify extends GenericMailet {
      * @throws MessagingException if a problem arises formulating the redirected mail
      */
     @Override
-    public abstract void service(Mail originalMail) throws MessagingException;
+    void service(Mail originalMail) throws MessagingException;
 
-    protected abstract MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException;
+    MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException;
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
index 707925d..dc4912d 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
@@ -27,11 +27,11 @@ import javax.mail.internet.InternetAddress;
 import javax.mail.internet.ParseException;
 
 import org.apache.james.transport.mailets.redirect.AddressExtractor;
+import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.james.transport.mailets.redirect.SpecialAddressKind;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
-import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.RFC2822Headers;
 
 import com.google.common.base.Strings;
@@ -41,14 +41,14 @@ import com.google.common.collect.ImmutableSet;
 
 public class SpecialAddressesUtils {
 
-    public static SpecialAddressesUtils from(GenericMailet genericMailet) {
-        return new SpecialAddressesUtils(genericMailet);
+    public static SpecialAddressesUtils from(RedirectNotify mailet) {
+        return new SpecialAddressesUtils(mailet);
     }
 
-    private final GenericMailet genericMailet;
+    private final RedirectNotify mailet;
 
-    public SpecialAddressesUtils(GenericMailet genericMailet) {
-        this.genericMailet = genericMailet;
+    public SpecialAddressesUtils(RedirectNotify genericMailet) {
+        this.mailet = genericMailet;
     }
 
     /**
@@ -123,7 +123,7 @@ public class SpecialAddressesUtils {
             }
             return getReplyTos(replyToArray);
         } catch (MessagingException ae) {
-            genericMailet.log("Unable to parse the \"REPLY_TO\" header in the original message; ignoring.");
+            mailet.log("Unable to parse the \"REPLY_TO\" header in the original message; ignoring.");
             return ImmutableSet.of();
         }
     }
@@ -142,7 +142,7 @@ public class SpecialAddressesUtils {
             try {
                 builder.add(new MailAddress(replyTo));
             } catch (ParseException pe) {
-                genericMailet.log("Unable to parse a \"REPLY_TO\" header address in the original message: " + replyTo + "; ignoring.");
+                mailet.log("Unable to parse a \"REPLY_TO\" header address in the original message: " + replyTo + "; ignoring.");
             }
         }
         return builder.build();
@@ -200,7 +200,7 @@ public class SpecialAddressesUtils {
                     InternetAddress[] fromArray = (InternetAddress[]) mailWithReplacementAddresses.getMessage().getFrom();
                     builder.addAll(allOrSender(mailWithReplacementAddresses, fromArray));
                 } catch (MessagingException me) {
-                    genericMailet.log("Unable to parse the \"FROM\" header in the original message; ignoring.");
+                    mailet.log("Unable to parse the \"FROM\" header in the original message; ignoring.");
                 }
                 break;
             case REPLY_TO:
@@ -208,7 +208,7 @@ public class SpecialAddressesUtils {
                     InternetAddress[] replyToArray = (InternetAddress[]) mailWithReplacementAddresses.getMessage().getReplyTo();
                     builder.addAll(allOrSender(mailWithReplacementAddresses, replyToArray));
                 } catch (MessagingException me) {
-                    genericMailet.log("Unable to parse the \"REPLY_TO\" header in the original message; ignoring.");
+                    mailet.log("Unable to parse the \"REPLY_TO\" header in the original message; ignoring.");
                 }
                 break;
             case TO:
@@ -247,13 +247,13 @@ public class SpecialAddressesUtils {
                         InternetAddress[] originalToInternetAddresses = InternetAddress.parse(toHeader, false);
                         return MailAddressUtils.from(originalToInternetAddresses);
                     } catch (MessagingException ae) {
-                        genericMailet.log("Unable to parse a \"TO\" header address in the original message: " + toHeader + "; ignoring.");
+                        mailet.log("Unable to parse a \"TO\" header address in the original message: " + toHeader + "; ignoring.");
                     }
                 }
             }
             return ImmutableList.of();
         } catch (MessagingException ae) {
-            genericMailet.log("Unable to parse the \"TO\" header  in the original message; ignoring.");
+            mailet.log("Unable to parse the \"TO\" header  in the original message; ignoring.");
             return ImmutableList.of();
         }
     }
@@ -268,7 +268,7 @@ public class SpecialAddressesUtils {
         }
 
         List<MailAddress> extractAddresses = AddressExtractor
-                .withContext(genericMailet.getMailetContext())
+                .withContext(mailet.getMailetContext())
                 .allowedSpecials(allowedSpecials)
                 .extract(givenAddress);
         return FluentIterable.from(extractAddresses).first().orNull();

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e81a893/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
index 5388998..369befc 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
@@ -26,16 +26,14 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Properties;
 
-import javax.mail.MessagingException;
 import javax.mail.Session;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 
+import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
-import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.MailetContext;
-import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.base.test.FakeMail;
@@ -56,17 +54,10 @@ public class SpecialAddressesUtilsTest {
         when(mailetContext.getPostmaster())
             .thenReturn(postmaster);
 
-        testee = SpecialAddressesUtils.from(new GenericMailet() {
-            
-            @Override
-            public MailetContext getMailetContext() {
-                return mailetContext;
-            }
-
-            @Override
-            public void service(Mail mail) throws MessagingException {
-            }
-        });
+        RedirectNotify mailet = mock(RedirectNotify.class);
+        when(mailet.getMailetContext())
+            .thenReturn(mailetContext);
+        testee = SpecialAddressesUtils.from(mailet);
     }
 
     @Test


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