Move {MessageModule=>TomP2PMessageModule}#NETWORK_INTERFACE_KEY

This change moves the NETWORK_INTERFACE_KEY into
BootstrappedPeerFactory, where it is actually used, but because
BootstrappedPeerFactory is package-private and has no other reason to be
public, NETWORK_INTERFACE_KEY is re-exposed publicly through
TomP2PMessageModule, where it can be used by types in the
io.bitsquare.app* packages.
This commit is contained in:
Chris Beams 2014-11-10 08:47:15 +01:00
parent 9e00c3d85e
commit ed76f73897
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
5 changed files with 4 additions and 12 deletions

View file

@ -22,7 +22,6 @@ import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import static io.bitsquare.app.AppModule.APP_NAME_KEY;
import static io.bitsquare.msg.MessageModule.NETWORK_INTERFACE_KEY;
import static io.bitsquare.msg.tomp2p.TomP2PMessageModule.*;
public class ArgumentParser {

View file

@ -50,7 +50,6 @@ import lighthouse.files.AppDirectory;
import net.sourceforge.argparse4j.inf.Namespace;
import static io.bitsquare.app.AppModule.APP_NAME_KEY;
import static io.bitsquare.msg.MessageModule.NETWORK_INTERFACE_KEY;
import static io.bitsquare.msg.tomp2p.TomP2PMessageModule.*;
public class Main extends Application {

View file

@ -20,14 +20,11 @@ package io.bitsquare.msg;
import io.bitsquare.BitsquareModule;
import com.google.inject.Injector;
import com.google.inject.name.Names;
import java.util.Properties;
public abstract class MessageModule extends BitsquareModule {
public static final String NETWORK_INTERFACE_KEY = "networkInterface";
protected MessageModule(Properties properties) {
super(properties);
}
@ -36,10 +33,6 @@ public abstract class MessageModule extends BitsquareModule {
protected final void configure() {
bind(MessageFacade.class).to(messageFacade()).asEagerSingleton();
bind(String.class)
.annotatedWith(Names.named(NETWORK_INTERFACE_KEY))
.toInstance(properties.getProperty(NETWORK_INTERFACE_KEY, ""));
doConfigure();
}

View file

@ -17,7 +17,6 @@
package io.bitsquare.msg.tomp2p;
import io.bitsquare.msg.MessageModule;
import io.bitsquare.network.BootstrapState;
import io.bitsquare.network.Node;
import io.bitsquare.persistence.Persistence;
@ -69,8 +68,6 @@ import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static io.bitsquare.msg.MessageModule.NETWORK_INTERFACE_KEY;
/**
* Creates a DHT peer and bootstrap to the network via a seed node
@ -79,6 +76,7 @@ class BootstrappedPeerFactory {
private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerFactory.class);
static final String BOOTSTRAP_NODE_KEY = "bootstrapNode";
static final String NETWORK_INTERFACE_KEY = "networkInterface";
private KeyPair keyPair;
private Storage storage;

View file

@ -33,6 +33,7 @@ public class TomP2PMessageModule extends MessageModule {
public static final String BOOTSTRAP_NODE_ID_KEY = "id";
public static final String BOOTSTRAP_NODE_IP_KEY = "ip";
public static final String BOOTSTRAP_NODE_PORT_KEY = "port";
public static final String NETWORK_INTERFACE_KEY = BootstrappedPeerFactory.NETWORK_INTERFACE_KEY;
public TomP2PMessageModule(Properties properties) {
super(properties);
@ -50,6 +51,8 @@ public class TomP2PMessageModule extends MessageModule {
properties.getProperty(BOOTSTRAP_NODE_PORT_KEY, DEFAULT_BOOTSTRAP_NODE.getPortAsString())
)
);
bindConstant().annotatedWith(Names.named(NETWORK_INTERFACE_KEY)).to(
properties.getProperty(NETWORK_INTERFACE_KEY, ""));
bind(BootstrappedPeerFactory.class).asEagerSingleton();
}