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 ad...@apache.org on 2017/02/07 10:26:58 UTC

[2/2] james-project git commit: JAMES-1924 Spring should bind JSPF DNSService

JAMES-1924 Spring should bind JSPF DNSService


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

Branch: refs/heads/master
Commit: 7abdb538bbf6087b354aca0072834d73681a6678
Parents: 39b5b28
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Feb 6 15:25:46 2017 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Tue Feb 7 16:35:05 2017 +0700

----------------------------------------------------------------------
 .../apache/james/modules/ProtocolsModule.java   |  2 +
 .../james/modules/protocols/JSPFModule.java     | 43 ++++++++++++++++++++
 .../modules/protocols/SMTPServerModule.java     | 12 ------
 .../META-INF/org/apache/james/spring-server.xml | 12 ++++++
 .../james/smtpserver/fastfail/SPFHandler.java   |  4 ++
 5 files changed, 61 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/7abdb538/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ProtocolsModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ProtocolsModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ProtocolsModule.java
index 5a1822d..2600d44 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ProtocolsModule.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ProtocolsModule.java
@@ -19,6 +19,7 @@
 package org.apache.james.modules;
 
 import org.apache.james.modules.protocols.IMAPServerModule;
+import org.apache.james.modules.protocols.JSPFModule;
 import org.apache.james.modules.protocols.LMTPServerModule;
 import org.apache.james.modules.protocols.ManageSieveServerModule;
 import org.apache.james.modules.protocols.POP3ServerModule;
@@ -32,6 +33,7 @@ public class ProtocolsModule extends AbstractModule {
 
     @Override
     protected void configure() {
+        install(new JSPFModule());
         install(new IMAPServerModule());
         install(new ProtocolHandlerModule());
         install(new POP3ServerModule());

http://git-wip-us.apache.org/repos/asf/james-project/blob/7abdb538/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JSPFModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JSPFModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JSPFModule.java
new file mode 100644
index 0000000..15eeb92
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JSPFModule.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.protocols;
+
+import org.apache.james.jspf.impl.DNSServiceXBillImpl;
+import org.apache.james.smtpserver.fastfail.SPFHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+
+public class JSPFModule extends AbstractModule {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(JSPFModule.class);
+
+    @Override
+    protected void configure() {
+
+    }
+
+    @Provides
+    public DNSServiceXBillImpl provideJSPFDNSService() {
+        return new DNSServiceXBillImpl(new SPFHandler.SPFLogger(LOGGER));
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/7abdb538/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
index 5fa7bc6..bb5f233 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
@@ -21,11 +21,8 @@ package org.apache.james.modules.protocols;
 
 import java.util.List;
 
-import org.apache.james.jspf.core.DNSService;
-import org.apache.james.jspf.impl.DNSServiceXBillImpl;
 import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.smtpserver.SendMailHandler;
-import org.apache.james.smtpserver.fastfail.SPFHandler;
 import org.apache.james.smtpserver.netty.SMTPServerFactory;
 import org.apache.james.utils.ConfigurationPerformer;
 import org.apache.james.utils.ConfigurationProvider;
@@ -36,8 +33,6 @@ import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
-import com.google.inject.Provides;
-import com.google.inject.Scopes;
 import com.google.inject.Singleton;
 import com.google.inject.multibindings.Multibinder;
 
@@ -47,15 +42,8 @@ public class SMTPServerModule extends AbstractModule {
 
     @Override
     protected void configure() {
-        bind(DNSServiceXBillImpl.class).in(Scopes.SINGLETON);
-
         Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(SMTPModuleConfigurationPerformer.class);
     }
-    
-    @Provides
-    public DNSServiceXBillImpl provideJSPFDNSService() {
-        return new DNSServiceXBillImpl(new SPFHandler.SPFLogger(LOGGER));
-    }
 
     @Singleton
     public static class SMTPModuleConfigurationPerformer implements ConfigurationPerformer {

http://git-wip-us.apache.org/repos/asf/james-project/blob/7abdb538/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
----------------------------------------------------------------------
diff --git a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
index aec7db9..39788f0 100644
--- a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
+++ b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
@@ -300,4 +300,16 @@
 
     <bean id="metricRegistry" class="com.codahale.metrics.MetricRegistry"/>
 
+    <!--
+    ======================================================================
+    JSPF
+    ======================================================================
+    -->
+
+    <bean id="jspfDnsService" class="org.apache.james.jspf.impl.DNSServiceXBillImpl">
+        <constructor-arg index="0" ref="jspfLogger"/>
+    </bean>
+
+    <bean id="jspfLogger" class="org.apache.james.smtpserver.fastfail.SPFHandler.SPFLogger"/>
+
 </beans>

http://git-wip-us.apache.org/repos/asf/james-project/blob/7abdb538/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
index 588bd2b..b7f1788 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
@@ -177,6 +177,10 @@ public class SPFHandler implements JamesMessageHook, MailHook, RcptHook, Protoco
             this.serviceLog = serviceLog;
         }
 
+        public SPFLogger() {
+            this.serviceLog = FALLBACK_LOG;
+        }
+
         /**
          * @see org.apache.james.jspf.core.Logger#debug(String)
          */


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