mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-25 07:10:48 -04:00
Remove static access to Bitsquare#getAppName
This commit is contained in:
parent
6f27c5ce29
commit
865cf39e64
8 changed files with 114 additions and 108 deletions
|
@ -38,7 +38,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import akka.actor.ActorRef;
|
import akka.actor.ActorRef;
|
||||||
import akka.actor.ActorSystem;
|
import akka.actor.ActorSystem;
|
||||||
import akka.actor.Inbox;
|
import akka.actor.Inbox;
|
||||||
import net.sourceforge.argparse4j.inf.ArgumentParserException;
|
|
||||||
import net.sourceforge.argparse4j.inf.Namespace;
|
import net.sourceforge.argparse4j.inf.Namespace;
|
||||||
import scala.concurrent.duration.Duration;
|
import scala.concurrent.duration.Duration;
|
||||||
import scala.concurrent.duration.FiniteDuration;
|
import scala.concurrent.duration.FiniteDuration;
|
||||||
|
@ -49,21 +48,9 @@ public class Bitsquare {
|
||||||
private static String appName = "Bitsquare";
|
private static String appName = "Bitsquare";
|
||||||
private static String interfaceHint;
|
private static String interfaceHint;
|
||||||
|
|
||||||
public static String getAppName() {
|
|
||||||
return appName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
BitsquareArgumentParser parser = new BitsquareArgumentParser();
|
BitsquareArgumentParser parser = new BitsquareArgumentParser();
|
||||||
Namespace namespace = null;
|
Namespace namespace = parser.parseArgs(args);
|
||||||
try {
|
|
||||||
namespace = parser.parseArgs(args);
|
|
||||||
} catch (ArgumentParserException e) {
|
|
||||||
parser.handleError(e);
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
if (namespace != null) {
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// global args
|
// global args
|
||||||
|
@ -89,7 +76,7 @@ public class Bitsquare {
|
||||||
seedID = namespace.getString(BitsquareArgumentParser.PEER_ID_FLAG);
|
seedID = namespace.getString(BitsquareArgumentParser.PEER_ID_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorSystem actorSystem = ActorSystem.create(getAppName());
|
ActorSystem actorSystem = ActorSystem.create(appName);
|
||||||
|
|
||||||
final Set<PeerAddress> peerAddresses = new HashSet<PeerAddress>();
|
final Set<PeerAddress> peerAddresses = new HashSet<PeerAddress>();
|
||||||
final String sid = seedID;
|
final String sid = seedID;
|
||||||
|
@ -139,5 +126,4 @@ public class Bitsquare {
|
||||||
});
|
});
|
||||||
seedNodeThread.start();
|
seedNodeThread.start();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import io.bitsquare.gui.util.ImageUtil;
|
||||||
import io.bitsquare.persistence.Persistence;
|
import io.bitsquare.persistence.Persistence;
|
||||||
import io.bitsquare.settings.Settings;
|
import io.bitsquare.settings.Settings;
|
||||||
import io.bitsquare.user.User;
|
import io.bitsquare.user.User;
|
||||||
|
import io.bitsquare.util.BitsquareArgumentParser;
|
||||||
import io.bitsquare.util.ViewLoader;
|
import io.bitsquare.util.ViewLoader;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
|
@ -44,20 +45,29 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import lighthouse.files.AppDirectory;
|
import lighthouse.files.AppDirectory;
|
||||||
|
import net.sourceforge.argparse4j.inf.Namespace;
|
||||||
|
|
||||||
public class BitsquareUI extends Application {
|
public class BitsquareUI extends Application {
|
||||||
private static final Logger log = LoggerFactory.getLogger(BitsquareUI.class);
|
private static final Logger log = LoggerFactory.getLogger(BitsquareUI.class);
|
||||||
|
private static String appName = "Bitsquare";
|
||||||
|
|
||||||
private BitsquareModule bitsquareModule;
|
private BitsquareModule bitsquareModule;
|
||||||
private Injector injector;
|
private Injector injector;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
BitsquareArgumentParser parser = new BitsquareArgumentParser();
|
||||||
|
Namespace namespace = parser.parseArgs(args);
|
||||||
|
|
||||||
|
if (namespace.getString(BitsquareArgumentParser.NAME_FLAG) != null) {
|
||||||
|
appName = appName + "-" + namespace.getString(BitsquareArgumentParser.NAME_FLAG);
|
||||||
|
}
|
||||||
|
|
||||||
Application.launch(BitsquareUI.class, args);
|
Application.launch(BitsquareUI.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
bitsquareModule = new BitsquareModule(primaryStage);
|
bitsquareModule = new BitsquareModule(primaryStage, appName);
|
||||||
injector = Guice.createInjector(bitsquareModule);
|
injector = Guice.createInjector(bitsquareModule);
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +80,7 @@ public class BitsquareUI extends Application {
|
||||||
// configure the Bitsquare application data directory
|
// configure the Bitsquare application data directory
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AppDirectory.initAppDir(Bitsquare.getAppName());
|
AppDirectory.initAppDir(appName);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -113,7 +123,7 @@ public class BitsquareUI extends Application {
|
||||||
|
|
||||||
// configure the primary stage
|
// configure the primary stage
|
||||||
|
|
||||||
primaryStage.setTitle("Bitsquare (" + Bitsquare.getAppName() + ")");
|
primaryStage.setTitle("Bitsquare (" + appName + ")");
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
primaryStage.setMinWidth(75);
|
primaryStage.setMinWidth(75);
|
||||||
primaryStage.setMinHeight(50);
|
primaryStage.setMinHeight(50);
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package io.bitsquare.btc;
|
package io.bitsquare.btc;
|
||||||
|
|
||||||
import io.bitsquare.Bitsquare;
|
|
||||||
import io.bitsquare.btc.listeners.AddressConfidenceListener;
|
import io.bitsquare.btc.listeners.AddressConfidenceListener;
|
||||||
import io.bitsquare.btc.listeners.BalanceListener;
|
import io.bitsquare.btc.listeners.BalanceListener;
|
||||||
import io.bitsquare.btc.listeners.TxConfidenceListener;
|
import io.bitsquare.btc.listeners.TxConfidenceListener;
|
||||||
|
@ -73,6 +72,7 @@ import java.util.stream.Collectors;
|
||||||
import javax.annotation.concurrent.GuardedBy;
|
import javax.annotation.concurrent.GuardedBy;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.util.Pair;
|
import javafx.util.Pair;
|
||||||
|
@ -92,14 +92,13 @@ import static org.bitcoinj.script.ScriptOpCodes.OP_RETURN;
|
||||||
public class WalletFacade {
|
public class WalletFacade {
|
||||||
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class);
|
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class);
|
||||||
|
|
||||||
public static final String WALLET_PREFIX = Bitsquare.getAppName();
|
|
||||||
|
|
||||||
private final ReentrantLock lock = Threading.lock("lock");
|
private final ReentrantLock lock = Threading.lock("lock");
|
||||||
private final NetworkParameters params;
|
private final NetworkParameters params;
|
||||||
private WalletAppKit walletAppKit;
|
private WalletAppKit walletAppKit;
|
||||||
private final FeePolicy feePolicy;
|
private final FeePolicy feePolicy;
|
||||||
private final CryptoFacade cryptoFacade;
|
private final CryptoFacade cryptoFacade;
|
||||||
private final Persistence persistence;
|
private final Persistence persistence;
|
||||||
|
private final String appName;
|
||||||
// private final List<DownloadListener> downloadListeners = new CopyOnWriteArrayList<>();
|
// private final List<DownloadListener> downloadListeners = new CopyOnWriteArrayList<>();
|
||||||
private final List<AddressConfidenceListener> addressConfidenceListeners = new CopyOnWriteArrayList<>();
|
private final List<AddressConfidenceListener> addressConfidenceListeners = new CopyOnWriteArrayList<>();
|
||||||
private final List<TxConfidenceListener> txConfidenceListeners = new CopyOnWriteArrayList<>();
|
private final List<TxConfidenceListener> txConfidenceListeners = new CopyOnWriteArrayList<>();
|
||||||
|
@ -118,11 +117,12 @@ public class WalletFacade {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public WalletFacade(NetworkParameters params, FeePolicy feePolicy, CryptoFacade cryptoFacade,
|
public WalletFacade(NetworkParameters params, FeePolicy feePolicy, CryptoFacade cryptoFacade,
|
||||||
Persistence persistence) {
|
Persistence persistence, @Named("appName") String appName) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.feePolicy = feePolicy;
|
this.feePolicy = feePolicy;
|
||||||
this.cryptoFacade = cryptoFacade;
|
this.cryptoFacade = cryptoFacade;
|
||||||
this.persistence = persistence;
|
this.persistence = persistence;
|
||||||
|
this.appName = appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ public class WalletFacade {
|
||||||
Threading.USER_THREAD = Platform::runLater;
|
Threading.USER_THREAD = Platform::runLater;
|
||||||
|
|
||||||
// If seed is non-null it means we are restoring from backup.
|
// If seed is non-null it means we are restoring from backup.
|
||||||
walletAppKit = new WalletAppKit(params, AppDirectory.dir().toFile(), WALLET_PREFIX) {
|
walletAppKit = new WalletAppKit(params, AppDirectory.dir().toFile(), appName) {
|
||||||
@Override
|
@Override
|
||||||
protected void onSetupCompleted() {
|
protected void onSetupCompleted() {
|
||||||
// Don't make the user wait for confirmations for now, as the intention is they're sending it
|
// Don't make the user wait for confirmations for now, as the intention is they're sending it
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package io.bitsquare.di;
|
package io.bitsquare.di;
|
||||||
|
|
||||||
import io.bitsquare.Bitsquare;
|
|
||||||
import io.bitsquare.btc.BitcoinModule;
|
import io.bitsquare.btc.BitcoinModule;
|
||||||
import io.bitsquare.crypto.CryptoModule;
|
import io.bitsquare.crypto.CryptoModule;
|
||||||
import io.bitsquare.gui.GuiModule;
|
import io.bitsquare.gui.GuiModule;
|
||||||
|
@ -48,14 +47,16 @@ public class BitsquareModule extends AbstractBitsquareModule {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(BitsquareModule.class);
|
private static final Logger log = LoggerFactory.getLogger(BitsquareModule.class);
|
||||||
private final Stage primaryStage;
|
private final Stage primaryStage;
|
||||||
|
private final String appName;
|
||||||
|
|
||||||
public BitsquareModule(Stage primaryStage) {
|
public BitsquareModule(Stage primaryStage, String appName) {
|
||||||
this(primaryStage, ConfigLoader.loadConfig());
|
this(primaryStage, appName, ConfigLoader.loadConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BitsquareModule(Stage primaryStage, Properties properties) {
|
public BitsquareModule(Stage primaryStage, String appName, Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
this.primaryStage = primaryStage;
|
this.primaryStage = primaryStage;
|
||||||
|
this.appName = appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,7 +71,8 @@ public class BitsquareModule extends AbstractBitsquareModule {
|
||||||
install(tradeModule());
|
install(tradeModule());
|
||||||
install(guiModule());
|
install(guiModule());
|
||||||
|
|
||||||
bind(ActorSystem.class).toInstance(ActorSystem.create(Bitsquare.getAppName()));
|
bindConstant().annotatedWith(Names.named("appName")).to(appName);
|
||||||
|
bind(ActorSystem.class).toInstance(ActorSystem.create(appName));
|
||||||
|
|
||||||
int randomPort = new Ports().tcpPort();
|
int randomPort = new Ports().tcpPort();
|
||||||
bindConstant().annotatedWith(Names.named("clientPort")).to(randomPort);
|
bindConstant().annotatedWith(Names.named("clientPort")).to(randomPort);
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package io.bitsquare.gui.main;
|
package io.bitsquare.gui.main;
|
||||||
|
|
||||||
import io.bitsquare.Bitsquare;
|
|
||||||
import io.bitsquare.bank.BankAccount;
|
import io.bitsquare.bank.BankAccount;
|
||||||
import io.bitsquare.gui.Navigation;
|
import io.bitsquare.gui.Navigation;
|
||||||
import io.bitsquare.gui.OverlayManager;
|
import io.bitsquare.gui.OverlayManager;
|
||||||
|
@ -35,6 +34,7 @@ import java.net.URL;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import javafx.animation.Interpolator;
|
import javafx.animation.Interpolator;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
@ -56,9 +56,9 @@ public class MainViewCB extends ViewCB<MainPM> {
|
||||||
|
|
||||||
private final Navigation navigation;
|
private final Navigation navigation;
|
||||||
private final OverlayManager overlayManager;
|
private final OverlayManager overlayManager;
|
||||||
private Settings settings;
|
|
||||||
|
|
||||||
private final ToggleGroup navButtonsGroup = new ToggleGroup();
|
private final ToggleGroup navButtonsGroup = new ToggleGroup();
|
||||||
|
private final Settings settings;
|
||||||
|
private final String appName;
|
||||||
|
|
||||||
private BorderPane baseApplicationContainer;
|
private BorderPane baseApplicationContainer;
|
||||||
private VBox splashScreen;
|
private VBox splashScreen;
|
||||||
|
@ -76,12 +76,13 @@ public class MainViewCB extends ViewCB<MainPM> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private MainViewCB(MainPM presentationModel, Navigation navigation, OverlayManager overlayManager,
|
private MainViewCB(MainPM presentationModel, Navigation navigation, OverlayManager overlayManager,
|
||||||
TradeManager tradeManager, Settings settings) {
|
TradeManager tradeManager, Settings settings, @Named("appName") String appName) {
|
||||||
super(presentationModel);
|
super(presentationModel);
|
||||||
|
|
||||||
this.navigation = navigation;
|
this.navigation = navigation;
|
||||||
this.overlayManager = overlayManager;
|
this.overlayManager = overlayManager;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
this.appName = appName;
|
||||||
|
|
||||||
tradeManager.featureNotImplementedWarningProperty().addListener((ov, oldValue, newValue) -> {
|
tradeManager.featureNotImplementedWarningProperty().addListener((ov, oldValue, newValue) -> {
|
||||||
if (oldValue == null && newValue != null) {
|
if (oldValue == null && newValue != null) {
|
||||||
|
@ -205,8 +206,8 @@ public class MainViewCB extends ViewCB<MainPM> {
|
||||||
numPendingTradesLabel.setText(String.valueOf(numPendingTrades));
|
numPendingTradesLabel.setText(String.valueOf(numPendingTrades));
|
||||||
}
|
}
|
||||||
|
|
||||||
log.trace("openInfoNotification " + Bitsquare.getAppName());
|
log.trace("openInfoNotification " + appName);
|
||||||
SystemNotification.openInfoNotification(Bitsquare.getAppName(), "You got a new trade message.");
|
SystemNotification.openInfoNotification(appName, "You got a new trade message.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (portfolioButtonButtonPane.getChildren().size() > 1)
|
if (portfolioButtonButtonPane.getChildren().size() > 1)
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package io.bitsquare.persistence;
|
package io.bitsquare.persistence;
|
||||||
|
|
||||||
import io.bitsquare.Bitsquare;
|
|
||||||
import io.bitsquare.util.FileUtil;
|
import io.bitsquare.util.FileUtil;
|
||||||
|
|
||||||
import org.bitcoinj.utils.Threading;
|
import org.bitcoinj.utils.Threading;
|
||||||
|
@ -39,6 +38,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||||
import javax.annotation.concurrent.GuardedBy;
|
import javax.annotation.concurrent.GuardedBy;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -52,19 +52,20 @@ public class Persistence {
|
||||||
private static final Logger log = LoggerFactory.getLogger(Persistence.class);
|
private static final Logger log = LoggerFactory.getLogger(Persistence.class);
|
||||||
private static final ReentrantLock lock = Threading.lock("Storage");
|
private static final ReentrantLock lock = Threading.lock("Storage");
|
||||||
|
|
||||||
private final String prefix = Bitsquare.getAppName() + "_pref";
|
|
||||||
private final File storageFile = FileUtil.getFile(prefix, "ser");
|
|
||||||
|
|
||||||
@GuardedBy("lock")
|
@GuardedBy("lock")
|
||||||
private Map<String, Serializable> rootMap = new HashMap<>();
|
private Map<String, Serializable> rootMap = new HashMap<>();
|
||||||
|
|
||||||
|
private final String prefix;
|
||||||
|
private final File storageFile;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public Persistence() {
|
public Persistence(@Named("appName") String appName) {
|
||||||
|
this.prefix = appName + "_pref";
|
||||||
|
this.storageFile = FileUtil.getFile(prefix, "ser");
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -58,8 +58,14 @@ public class BitsquareArgumentParser {
|
||||||
.help("Append name to application name.");
|
.help("Append name to application name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Namespace parseArgs(String... args) throws ArgumentParserException {
|
public Namespace parseArgs(String... args) {
|
||||||
|
try {
|
||||||
return parser.parseArgs(args);
|
return parser.parseArgs(args);
|
||||||
|
} catch (ArgumentParserException e) {
|
||||||
|
parser.handleError(e);
|
||||||
|
System.exit(1);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleError(ArgumentParserException e) {
|
public void handleError(ArgumentParserException e) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class ViewLoaderTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
Injector injector = Guice.createInjector(new BitsquareModule(TestApp.primaryStage));
|
Injector injector = Guice.createInjector(new BitsquareModule(TestApp.primaryStage, "testApp"));
|
||||||
ViewLoader.setInjector(injector);
|
ViewLoader.setInjector(injector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue