Author: matthieu
Date: Tue Nov 3 16:50:38 2015
New Revision: 1712339
URL: http://svn.apache.org/viewvc?rev=1712339&view=rev
Log:
JAMES-1626 Add DNSService support in cassandra-guice application
Added:
james/project/trunk/server/container/cassandra-guice/src/test/resources/dnsservice.xml
Modified:
james/project/trunk/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
james/project/trunk/server/dns-service/dnsservice-dnsjava/pom.xml
james/project/trunk/server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
Modified:
james/project/trunk/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
URL:
http://svn.apache.org/viewvc/james/project/trunk/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java?rev=1712339&r1=1712338&r2=1712339&view=diff
==============================================================================
---
james/project/trunk/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
(original)
+++
james/project/trunk/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
Tue Nov 3 16:50:38 2015
@@ -18,23 +18,45 @@
****************************************************************/
package org.apache.james.modules.server;
-import com.google.inject.Provides;
+import com.google.inject.Inject;
import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
import org.apache.james.dnsservice.api.DNSService;
import org.apache.james.dnsservice.dnsjava.DNSJavaService;
import com.google.inject.AbstractModule;
+import org.apache.james.utils.ClassPathConfigurationProvider;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DNSServiceModule extends AbstractModule {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(DNSServiceModule.class);
+
@Override
protected void configure() {
-
+ bind(DNSService.class).to(DNSJavaService.class);
+ Multibinder.newSetBinder(binder(),
ConfigurationPerformer.class).addBinding().to(DNSServiceConfigurationPerformer.class);
}
- @Provides
@Singleton
- private DNSService provideDNSService() {
- return new DNSJavaService();
+ public static class DNSServiceConfigurationPerformer implements
ConfigurationPerformer {
+
+ private final ClassPathConfigurationProvider
classPathConfigurationProvider;
+ private final DNSJavaService dnsService;
+
+ @Inject
+ public DNSServiceConfigurationPerformer(ClassPathConfigurationProvider
classPathConfigurationProvider,
+ DNSJavaService dnsService) {
+ this.classPathConfigurationProvider =
classPathConfigurationProvider;
+ this.dnsService = dnsService;
+ }
+
+ public void initModule() throws Exception {
+ dnsService.setLog(LOGGER);
+
dnsService.configure(classPathConfigurationProvider.getConfiguration("dnsservice"));
+ dnsService.init();
+ }
}
}
\ No newline at end of file
Added:
james/project/trunk/server/container/cassandra-guice/src/test/resources/dnsservice.xml
URL:
http://svn.apache.org/viewvc/james/project/trunk/server/container/cassandra-guice/src/test/resources/dnsservice.xml?rev=1712339&view=auto
==============================================================================
---
james/project/trunk/server/container/cassandra-guice/src/test/resources/dnsservice.xml
(added)
+++
james/project/trunk/server/container/cassandra-guice/src/test/resources/dnsservice.xml
Tue Nov 3 16:50:38 2015
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+ -->
+
+<dnsservice>
+ <servers>
+ <server>8.8.8.8</server>
+ <server>62.210.16.6</server>
+ </servers>
+ <autodiscover>false</autodiscover>
+ <authoritative>false</authoritative>
+ <maxcachesize>50000</maxcachesize>
+</dnsservice>
Modified: james/project/trunk/server/dns-service/dnsservice-dnsjava/pom.xml
URL:
http://svn.apache.org/viewvc/james/project/trunk/server/dns-service/dnsservice-dnsjava/pom.xml?rev=1712339&r1=1712338&r2=1712339&view=diff
==============================================================================
--- james/project/trunk/server/dns-service/dnsservice-dnsjava/pom.xml (original)
+++ james/project/trunk/server/dns-service/dnsservice-dnsjava/pom.xml Tue Nov
3 16:50:38 2015
@@ -60,6 +60,10 @@
<artifactId>dnsjava</artifactId>
</dependency>
<dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.1_spec</artifactId>
</dependency>
Modified:
james/project/trunk/server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
URL:
http://svn.apache.org/viewvc/james/project/trunk/server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java?rev=1712339&r1=1712338&r2=1712339&view=diff
==============================================================================
---
james/project/trunk/server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
(original)
+++
james/project/trunk/server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
Tue Nov 3 16:50:38 2015
@@ -44,6 +44,7 @@ import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;
import javax.annotation.PostConstruct;
+import javax.inject.Singleton;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -56,6 +57,7 @@ import java.util.List;
/**
* Provides DNS client functionality to services running inside James
*/
+@Singleton
public class DNSJavaService implements DNSService, DNSServiceMBean,
LogEnabled, Configurable {
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]