Skip to content

Commit

Permalink
JAMES-1924 Spring should bind JSPF DNSService
Browse files Browse the repository at this point in the history
  • Loading branch information
chibenwa committed Feb 7, 2017
1 parent 39b5b28 commit 7abdb53
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 12 deletions.
Expand Up @@ -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;
Expand All @@ -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());
Expand Down
@@ -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));
}
}
Expand Up @@ -21,11 +21,8 @@

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;
Expand All @@ -36,8 +33,6 @@
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;

Expand All @@ -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 {
Expand Down
Expand Up @@ -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>
Expand Up @@ -177,6 +177,10 @@ public SPFLogger(Logger serviceLog) {
this.serviceLog = serviceLog;
}

public SPFLogger() {
this.serviceLog = FALLBACK_LOG;
}

/**
* @see org.apache.james.jspf.core.Logger#debug(String)
*/
Expand Down

0 comments on commit 7abdb53

Please sign in to comment.