JAMES-1877 Creating javax properties is a responsibility of 
RemoteDeliveryConfiguration


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

Branch: refs/heads/master
Commit: 69f66c7a6282c9b904ac5c1a0dc120b4e73a04f4
Parents: 6fa5298
Author: Benoit Tellier <[email protected]>
Authored: Wed Nov 30 17:28:42 2016 +0700
Committer: Benoit Tellier <[email protected]>
Committed: Tue Jan 10 15:04:32 2017 +0700

----------------------------------------------------------------------
 .../james/transport/mailets/RemoteDelivery.java | 48 +-------------------
 .../RemoteDeliveryConfiguration.java            | 29 ++++++++++++
 2 files changed, 30 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/69f66c7a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
----------------------------------------------------------------------
diff --git 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
index 0067607..c4c18d2 100644
--- 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
+++ 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
@@ -318,53 +318,7 @@ public class RemoteDelivery extends GenericMailet 
implements Runnable {
      */
     @Override
     public void run() {
-
-        // Checks the pool and delivers a mail message
-        Properties props = new Properties();
-        // Not needed for production environment
-        props.put("mail.debug", "false");
-        // Reactivated: javamail 1.3.2 should no more have problems with
-        // "250 OK"
-        // messages (WAS "false": Prevents problems encountered with 250 OK
-        // Messages)
-        props.put("mail.smtp.ehlo", "true");
-        // By setting this property to true the transport is allowed to
-        // send 8 bit data to the server (if it supports the 8bitmime
-        // extension).
-        // 2006/03/01 reverted to false because of a javamail bug converting to
-        // 8bit
-        // messages created by an inputstream.
-        props.setProperty("mail.smtp.allow8bitmime", "true");
-        // Sets timeout on going connections
-        props.put("mail.smtp.timeout", configuration.getSmtpTimeout() + "");
-
-        props.put("mail.smtp.connectiontimeout", 
configuration.getConnectionTimeout() + "");
-        props.put("mail.smtp.sendpartial", 
String.valueOf(configuration.isSendPartial()));
-
-        props.put("mail.smtp.localhost", 
configuration.getHeloNameProvider().getHeloName());
-
-        // handle starttls
-        props.put("mail.smtp.starttls.enable", 
String.valueOf(configuration.isStartTLS()));
-
-        // handle SSLEnable
-        props.put("mail.smtp.ssl.enable", 
String.valueOf(configuration.isSSLEnable()));
-
-        if (configuration.isBindUsed()) {
-            // undocumented JavaMail 1.2 feature, smtp transport will use
-            // our socket factory, which will also set the local address
-            props.put("mail.smtp.socketFactory.class", 
RemoteDeliverySocketFactory.class.getClass());
-            // Don't fallback to the standard socket factory on error, do throw
-            // an exception
-            props.put("mail.smtp.socketFactory.fallback", "false");
-        }
-
-        if (configuration.getAuthUser() != null) {
-            props.put("mail.smtp.auth", "true");
-        }
-
-        props.putAll(configuration.getJavaxAdditionalProperties());
-
-        final Session session = obtainSession(props);
+        final Session session = 
obtainSession(configuration.createFinalJavaxProperties());
         try {
             while (!Thread.interrupted() && !destroyed) {
                 try {

http://git-wip-us.apache.org/repos/asf/james-project/blob/69f66c7a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/RemoteDeliveryConfiguration.java
----------------------------------------------------------------------
diff --git 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/RemoteDeliveryConfiguration.java
 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/RemoteDeliveryConfiguration.java
index 621f3fe..3bfde9e 100644
--- 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/RemoteDeliveryConfiguration.java
+++ 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/RemoteDeliveryConfiguration.java
@@ -206,6 +206,35 @@ public class RemoteDeliveryConfiguration {
         return address;
     }
 
+    public Properties createFinalJavaxProperties() {
+        Properties props = new Properties();
+        props.put("mail.debug", "false");
+        // Reactivated: javamail 1.3.2 should no more have problems with "250 
OK" messages
+        // (WAS "false": Prevents problems encountered with 250 OK Messages)
+        props.put("mail.smtp.ehlo", "true");
+        // By setting this property to true the transport is allowed to send 8 
bit data to the server (if it supports
+        // the 8bitmime extension).
+        props.setProperty("mail.smtp.allow8bitmime", "true");
+        props.put("mail.smtp.timeout", String.valueOf(smtpTimeout));
+        props.put("mail.smtp.connectiontimeout", 
String.valueOf(connectionTimeout));
+        props.put("mail.smtp.sendpartial", String.valueOf(sendPartial));
+        props.put("mail.smtp.localhost", heloNameProvider.getHeloName());
+        props.put("mail.smtp.starttls.enable", String.valueOf(startTLS));
+        props.put("mail.smtp.ssl.enable", String.valueOf(isSSLEnable));
+        if (isBindUsed()) {
+            // undocumented JavaMail 1.2 feature, smtp transport will use
+            // our socket factory, which will also set the local address
+            props.put("mail.smtp.socketFactory.class", 
RemoteDeliverySocketFactory.class.getClass());
+            // Don't fallback to the standard socket factory on error, do 
throw an exception
+            props.put("mail.smtp.socketFactory.fallback", "false");
+        }
+        if (authUser != null) {
+            props.put("mail.smtp.auth", "true");
+        }
+        props.putAll(javaxAdditionalProperties);
+        return props;
+    }
+
     public boolean isDebug() {
         return isDebug;
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to