Merge remote-tracking branch 'upstream/master'

Bump guice version to 4.2.2
This commit is contained in:
ghubstan 2019-08-13 11:44:00 -03:00
commit 4ed65c229f
No known key found for this signature in database
GPG key ID: E35592D6800A861E
47 changed files with 231 additions and 90 deletions

View file

@ -41,7 +41,7 @@ configure(subprojects) {
findbugsVersion = '3.0.2'
firebaseVersion = '6.2.0'
guavaVersion = '20.0'
guiceVersion = '4.1.0'
guiceVersion = '4.2.2'
hamcrestVersion = '1.3'
httpclientVersion = '4.5.3'
ioVersion = '2.4'
@ -201,7 +201,7 @@ configure(project(':common')) {
compile "com.google.code.findbugs:jsr305:$findbugsVersion"
compile "com.google.guava:guava:$guavaVersion"
compile("com.google.inject:guice:$guiceVersion") {
exclude(module: 'guava')
exclude (module: 'guava')
}
compile("com.github.bisq-network.bitcoinj:bitcoinj-core:$bitcoinjVersion") {
exclude(module: 'jsr305')

View file

@ -17,6 +17,8 @@
package bisq.common;
import javax.inject.Singleton;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -26,6 +28,7 @@ import lombok.extern.slf4j.Slf4j;
// Helps configure listener objects that are run by the `UserThread` each second
// and can do per second, per minute and delayed second actions. Also detects when we were in standby, and logs it.
@Slf4j
@Singleton
public class ClockWatcher {
public static final int IDLE_TOLERANCE_MS = 20000;

View file

@ -18,6 +18,7 @@
package bisq.common.crypto;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPublicKey;
@ -34,6 +35,7 @@ import javax.annotation.Nullable;
@Getter
@EqualsAndHashCode
@Slf4j
@Singleton
public class KeyRing {
private final KeyPair signatureKeyPair;
private final KeyPair encryptionKeyPair;

View file

@ -22,6 +22,7 @@ import bisq.common.storage.FileUtil;
import com.google.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.bouncycastle.openpgp.PGPKeyPair;
@ -56,6 +57,7 @@ import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
// TODO: use a password protection for key storage
@Singleton
public class KeyStorage {
private static final Logger log = LoggerFactory.getLogger(KeyStorage.class);

View file

@ -18,6 +18,7 @@
package bisq.common.storage;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
@ -26,6 +27,7 @@ import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Singleton
public class CorruptedDatabaseFilesHandler {
private List<String> corruptedDatabaseFiles = new ArrayList<>();

View file

@ -19,53 +19,33 @@ package bisq.core;
import bisq.core.alert.AlertModule;
import bisq.core.app.AppOptionKeys;
import bisq.core.app.AvoidStandbyModeService;
import bisq.core.app.BisqEnvironment;
import bisq.core.app.BisqSetup;
import bisq.core.app.P2PNetworkSetup;
import bisq.core.app.TorSetup;
import bisq.core.app.WalletAppSetup;
import bisq.core.arbitration.ArbitratorModule;
import bisq.core.btc.BitcoinModule;
import bisq.core.dao.DaoModule;
import bisq.core.filter.FilterModule;
import bisq.core.network.p2p.seed.DefaultSeedNodeRepository;
import bisq.core.notifications.MobileMessageEncryption;
import bisq.core.notifications.MobileModel;
import bisq.core.notifications.MobileNotificationService;
import bisq.core.notifications.MobileNotificationValidator;
import bisq.core.notifications.alerts.DisputeMsgEvents;
import bisq.core.notifications.alerts.MyOfferTakenEvents;
import bisq.core.notifications.alerts.TradeEvents;
import bisq.core.notifications.alerts.market.MarketAlerts;
import bisq.core.notifications.alerts.price.PriceAlert;
import bisq.core.offer.OfferModule;
import bisq.core.payment.TradeLimits;
import bisq.core.presentation.CorePresentationModule;
import bisq.core.proto.network.CoreNetworkProtoResolver;
import bisq.core.proto.persistable.CorePersistenceProtoResolver;
import bisq.core.trade.TradeModule;
import bisq.core.user.Preferences;
import bisq.core.user.User;
import bisq.network.crypto.EncryptionServiceModule;
import bisq.network.p2p.P2PModule;
import bisq.network.p2p.network.BridgeAddressProvider;
import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.ClockWatcher;
import bisq.common.CommonOptionKeys;
import bisq.common.app.AppModule;
import bisq.common.crypto.KeyRing;
import bisq.common.crypto.KeyStorage;
import bisq.common.proto.network.NetworkProtoResolver;
import bisq.common.proto.persistable.PersistenceProtoResolver;
import bisq.common.storage.CorruptedDatabaseFilesHandler;
import bisq.common.storage.Storage;
import org.springframework.core.env.Environment;
import com.google.inject.Singleton;
import com.google.inject.name.Names;
import java.io.File;
@ -80,25 +60,11 @@ public class CoreModule extends AppModule {
@Override
protected void configure() {
bind(BisqSetup.class).in(Singleton.class);
bind(TorSetup.class).in(Singleton.class);
bind(P2PNetworkSetup.class).in(Singleton.class);
bind(WalletAppSetup.class).in(Singleton.class);
bind(BisqEnvironment.class).toInstance((BisqEnvironment) environment);
bind(TradeLimits.class).in(Singleton.class);
bind(BridgeAddressProvider.class).to(Preferences.class);
bind(KeyStorage.class).in(Singleton.class);
bind(KeyRing.class).in(Singleton.class);
bind(User.class).in(Singleton.class);
bind(ClockWatcher.class).in(Singleton.class);
bind(Preferences.class).in(Singleton.class);
bind(BridgeAddressProvider.class).to(Preferences.class).in(Singleton.class);
bind(CorruptedDatabaseFilesHandler.class).in(Singleton.class);
bind(AvoidStandbyModeService.class).in(Singleton.class);
bind(SeedNodeRepository.class).to(DefaultSeedNodeRepository.class).in(Singleton.class);
bind(SeedNodeRepository.class).to(DefaultSeedNodeRepository.class);
File storageDir = new File(environment.getRequiredProperty(Storage.STORAGE_DIR));
bind(File.class).annotatedWith(named(Storage.STORAGE_DIR)).toInstance(storageDir);
@ -106,8 +72,8 @@ public class CoreModule extends AppModule {
File keyStorageDir = new File(environment.getRequiredProperty(KeyStorage.KEY_STORAGE_DIR));
bind(File.class).annotatedWith(named(KeyStorage.KEY_STORAGE_DIR)).toInstance(keyStorageDir);
bind(NetworkProtoResolver.class).to(CoreNetworkProtoResolver.class).in(Singleton.class);
bind(PersistenceProtoResolver.class).to(CorePersistenceProtoResolver.class).in(Singleton.class);
bind(NetworkProtoResolver.class).to(CoreNetworkProtoResolver.class);
bind(PersistenceProtoResolver.class).to(CorePersistenceProtoResolver.class);
Boolean useDevPrivilegeKeys = environment.getProperty(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS, Boolean.class, false);
bind(boolean.class).annotatedWith(Names.named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS)).toInstance(useDevPrivilegeKeys);
@ -118,15 +84,6 @@ public class CoreModule extends AppModule {
String referralId = environment.getProperty(AppOptionKeys.REFERRAL_ID, String.class, "");
bind(String.class).annotatedWith(Names.named(AppOptionKeys.REFERRAL_ID)).toInstance(referralId);
bind(MobileNotificationService.class).in(Singleton.class);
bind(MobileMessageEncryption.class).in(Singleton.class);
bind(MobileNotificationValidator.class).in(Singleton.class);
bind(MobileModel.class).in(Singleton.class);
bind(MyOfferTakenEvents.class).in(Singleton.class);
bind(TradeEvents.class).in(Singleton.class);
bind(DisputeMsgEvents.class).in(Singleton.class);
bind(PriceAlert.class).in(Singleton.class);
bind(MarketAlerts.class).in(Singleton.class);
// ordering is used for shut down sequence
install(tradeModule());

View file

@ -20,6 +20,7 @@ package bisq.core.app;
import bisq.core.user.Preferences;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.io.IOUtils;
@ -40,6 +41,7 @@ import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;
@Slf4j
@Singleton
public class AvoidStandbyModeService {
private final Preferences preferences;
private volatile boolean isStopped;

View file

@ -72,6 +72,7 @@ import bisq.common.util.Utilities;
import org.bitcoinj.core.Coin;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.common.net.InetAddresses;
@ -109,6 +110,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
@Slf4j
@Singleton
public class BisqSetup {
public interface BisqSetupCompleteListener {
void onSetupComplete();

View file

@ -28,6 +28,7 @@ import bisq.network.p2p.network.Connection;
import bisq.network.p2p.network.ConnectionListener;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.monadic.MonadicBinding;
@ -44,6 +45,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
@Singleton
@Slf4j
public class P2PNetworkSetup {
private final PriceFeedService priceFeedService;

View file

@ -25,6 +25,7 @@ import bisq.common.storage.FileUtil;
import com.google.inject.name.Named;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.nio.file.Paths;
@ -36,6 +37,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
@Slf4j
@Singleton
public class TorSetup {
private File torDir;

View file

@ -28,6 +28,7 @@ import org.bitcoinj.store.BlockStoreException;
import org.bitcoinj.store.ChainFileLockedException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.monadic.MonadicBinding;
@ -50,6 +51,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
@Slf4j
@Singleton
public class WalletAppSetup {
private final WalletsManager walletsManager;
private final WalletsSetup walletsSetup;

View file

@ -25,6 +25,7 @@ import bisq.network.p2p.seed.SeedNodeRepository;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.BufferedReader;
import java.io.InputStream;
@ -43,6 +44,7 @@ import javax.annotation.Nullable;
// If a new BaseCurrencyNetwork type gets added we need to add the resource file for it as well!
@Slf4j
@Singleton
public class DefaultSeedNodeRepository implements SeedNodeRepository {
//TODO add support for localhost addresses
private static final Pattern pattern = Pattern.compile("^([a-z0-9]+\\.onion:\\d+)");

View file

@ -18,6 +18,7 @@
package bisq.core.notifications;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.common.base.Charsets;
@ -33,6 +34,7 @@ import java.security.NoSuchAlgorithmException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Singleton
public class MobileMessageEncryption {
private SecretKeySpec keySpec;
private Cipher cipher;

View file

@ -18,6 +18,7 @@
package bisq.core.notifications;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.common.annotations.VisibleForTesting;
@ -29,6 +30,7 @@ import javax.annotation.Nullable;
@Data
@Slf4j
@Singleton
public class MobileModel {
public static final String PHONE_SEPARATOR_ESCAPED = "\\|"; // see https://stackoverflow.com/questions/5675704/java-string-split-not-returning-the-right-values
public static final String PHONE_SEPARATOR_WRITING = "|";

View file

@ -29,6 +29,7 @@ import bisq.common.util.Utilities;
import com.google.gson.Gson;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import javax.inject.Named;
@ -54,6 +55,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
@Slf4j
@Singleton
public class MobileNotificationService {
// Used in Relay app to response of a success state. We won't want a code dependency just for that string so we keep it
// duplicated in relay and here. Must not be changed.

View file

@ -18,10 +18,12 @@
package bisq.core.notifications;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Singleton
public class MobileNotificationValidator {
@Inject
public MobileNotificationValidator() {

View file

@ -28,6 +28,7 @@ import bisq.core.notifications.MobileNotificationService;
import bisq.network.p2p.P2PService;
import javax.inject.Inject;
import javax.inject.Singleton;
import javafx.collections.ListChangeListener;
@ -36,6 +37,7 @@ import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Singleton
public class DisputeMsgEvents {
private final P2PService p2PService;
private final MobileNotificationService mobileNotificationService;

View file

@ -25,6 +25,7 @@ import bisq.core.offer.OpenOffer;
import bisq.core.offer.OpenOfferManager;
import javax.inject.Inject;
import javax.inject.Singleton;
import javafx.collections.ListChangeListener;
@ -33,6 +34,7 @@ import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Singleton
public class MyOfferTakenEvents {
private final OpenOfferManager openOfferManager;
private final MobileNotificationService mobileNotificationService;

View file

@ -28,6 +28,7 @@ import bisq.common.crypto.KeyRing;
import bisq.common.crypto.PubKeyRing;
import javax.inject.Inject;
import javax.inject.Singleton;
import javafx.collections.ListChangeListener;
@ -38,6 +39,7 @@ import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Singleton
public class TradeEvents {
private final PubKeyRing pubKeyRing;
private final TradeManager tradeManager;

View file

@ -38,6 +38,7 @@ import bisq.common.util.MathUtils;
import org.bitcoinj.utils.Fiat;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.List;
import java.util.UUID;
@ -45,6 +46,7 @@ import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Singleton
public class MarketAlerts {
private final OfferBookService offerBookService;
private final MobileNotificationService mobileNotificationService;

View file

@ -33,10 +33,12 @@ import bisq.common.util.MathUtils;
import org.bitcoinj.utils.Fiat;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Singleton
public class PriceAlert {
private final PriceFeedService priceFeedService;
private final MobileNotificationService mobileNotificationService;

View file

@ -26,6 +26,7 @@ import bisq.common.util.MathUtils;
import org.bitcoinj.core.Coin;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.common.annotations.VisibleForTesting;
@ -35,6 +36,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
@Slf4j
@Singleton
public class TradeLimits {
@Nullable
@Getter

View file

@ -79,11 +79,13 @@ import bisq.common.proto.network.NetworkPayload;
import bisq.common.proto.network.NetworkProtoResolver;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
// TODO Use ProtobufferException instead of ProtobufferRuntimeException
@Slf4j
@Singleton
public class CoreNetworkProtoResolver extends CoreProtoResolver implements NetworkProtoResolver {
@Inject

View file

@ -56,6 +56,7 @@ import com.google.inject.Provider;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File;
@ -63,6 +64,7 @@ import lombok.extern.slf4j.Slf4j;
// TODO Use ProtobufferException instead of ProtobufferRuntimeException
@Slf4j
@Singleton
public class CorePersistenceProtoResolver extends CoreProtoResolver implements PersistenceProtoResolver {
private final Provider<BtcWalletService> btcWalletService;
private final NetworkProtoResolver networkProtoResolver;

View file

@ -32,8 +32,8 @@ import bisq.core.locale.FiatCurrency;
import bisq.core.locale.GlobalSettings;
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.PaymentAccount;
import bisq.core.setup.CoreNetworkCapabilities;
import bisq.core.payment.PaymentAccountUtil;
import bisq.core.setup.CoreNetworkCapabilities;
import bisq.network.p2p.network.BridgeAddressProvider;
@ -43,6 +43,7 @@ import bisq.common.util.Utilities;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.LongProperty;
@ -74,6 +75,7 @@ import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
@Slf4j
@Singleton
public final class Preferences implements PersistedDataHost, BridgeAddressProvider {
private static final ArrayList<BlockChainExplorer> BTC_MAIN_NET_EXPLORERS = new ArrayList<>(Arrays.asList(

View file

@ -34,6 +34,7 @@ import bisq.common.proto.persistable.PersistedDataHost;
import bisq.common.storage.Storage;
import javax.inject.Inject;
import javax.inject.Singleton;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
@ -64,6 +65,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
@Slf4j
@AllArgsConstructor
@Singleton
public class User implements PersistedDataHost {
final private Storage<UserPayload> storage;
final private KeyRing keyRing;

View file

@ -38,6 +38,7 @@ import org.bitcoinj.utils.Fiat;
import org.bitcoinj.utils.MonetaryFormat;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
@ -59,6 +60,7 @@ import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
@Slf4j
@Singleton
public class BSFormatter {
public final static String RANGE_SEPARATOR = " - ";

View file

@ -35,6 +35,7 @@ import org.bitcoinj.core.Coin;
import org.bitcoinj.utils.MonetaryFormat;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.text.DecimalFormat;
import java.text.NumberFormat;
@ -44,6 +45,7 @@ import java.util.Locale;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Singleton
public class BsqFormatter extends BSFormatter {
@SuppressWarnings("PointlessBooleanExpression")
private static final boolean useBsqAddressFormat = true || !DevEnv.isDevMode();

View file

@ -18,26 +18,12 @@
package bisq.desktop;
import bisq.desktop.common.fxml.FxmlViewLoader;
import bisq.desktop.common.view.CachingViewLoader;
import bisq.desktop.common.view.ViewFactory;
import bisq.desktop.common.view.ViewLoader;
import bisq.desktop.common.view.guice.InjectorViewFactory;
import bisq.desktop.main.dao.bonding.BondingViewUtils;
import bisq.desktop.main.funds.transactions.DisplayedTransactionsFactory;
import bisq.desktop.main.funds.transactions.TradableRepository;
import bisq.desktop.main.funds.transactions.TransactionAwareTradableFactory;
import bisq.desktop.main.funds.transactions.TransactionListItemFactory;
import bisq.desktop.main.offer.offerbook.OfferBook;
import bisq.desktop.main.overlays.notifications.NotificationCenter;
import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow;
import bisq.desktop.main.presentation.DaoPresentation;
import bisq.desktop.main.presentation.MarketPricePresentation;
import bisq.desktop.util.Transitions;
import bisq.core.app.AppOptionKeys;
import bisq.core.locale.Res;
import bisq.core.util.BSFormatter;
import bisq.core.util.BsqFormatter;
import bisq.common.app.AppModule;
@ -57,32 +43,10 @@ public class DesktopModule extends AppModule {
@Override
protected void configure() {
bind(InjectorViewFactory.class).in(Singleton.class);
bind(ViewFactory.class).to(InjectorViewFactory.class);
bind(CachingViewLoader.class).in(Singleton.class);
bind(ResourceBundle.class).toInstance(Res.getResourceBundle());
bind(ViewLoader.class).to(FxmlViewLoader.class).in(Singleton.class);
bind(CachingViewLoader.class).in(Singleton.class);
bind(Navigation.class).in(Singleton.class);
bind(NotificationCenter.class).in(Singleton.class);
bind(OfferBook.class).in(Singleton.class);
bind(BSFormatter.class).in(Singleton.class);
bind(BsqFormatter.class).in(Singleton.class);
bind(TorNetworkSettingsWindow.class).in(Singleton.class);
bind(MarketPricePresentation.class).in(Singleton.class);
bind(DaoPresentation.class).in(Singleton.class);
bind(Transitions.class).in(Singleton.class);
bind(TradableRepository.class).in(Singleton.class);
bind(TransactionListItemFactory.class).in(Singleton.class);
bind(TransactionAwareTradableFactory.class).in(Singleton.class);
bind(DisplayedTransactionsFactory.class).in(Singleton.class);
bind(BondingViewUtils.class).in(Singleton.class);
bindConstant().annotatedWith(Names.named(AppOptionKeys.APP_NAME_KEY)).to(environment.getRequiredProperty(AppOptionKeys.APP_NAME_KEY));
}

View file

@ -28,6 +28,8 @@ import bisq.common.storage.Storage;
import com.google.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -41,6 +43,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
@Slf4j
@Singleton
public final class Navigation implements PersistedDataHost {
private static final ViewPath DEFAULT_VIEW_PATH = ViewPath.to(MainView.class, MarketView.class);

View file

@ -26,6 +26,7 @@ import bisq.desktop.common.view.ViewLoader;
import org.springframework.core.annotation.AnnotationUtils;
import javax.inject.Inject;
import javax.inject.Singleton;
import javafx.fxml.FXMLLoader;
@ -38,6 +39,7 @@ import java.util.ResourceBundle;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.springframework.core.annotation.AnnotationUtils.getDefaultValue;
@Singleton
public class FxmlViewLoader implements ViewLoader {
private final ViewFactory viewFactory;

View file

@ -18,9 +18,11 @@
package bisq.desktop.common.view;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.HashMap;
@Singleton
public class CachingViewLoader implements ViewLoader {
private final HashMap<Object, View> cache = new HashMap<>();

View file

@ -21,8 +21,11 @@ import bisq.desktop.common.view.ViewFactory;
import com.google.inject.Injector;
import javax.inject.Singleton;
import com.google.common.base.Preconditions;
@Singleton
public class InjectorViewFactory implements ViewFactory {
private Injector injector;

View file

@ -47,6 +47,7 @@ import org.bitcoinj.core.Coin;
import org.bitcoinj.core.InsufficientMoneyException;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Optional;
import java.util.function.Consumer;
@ -56,6 +57,7 @@ import lombok.extern.slf4j.Slf4j;
import static com.google.common.base.Preconditions.checkArgument;
@Slf4j
@Singleton
public class BondingViewUtils {
private final P2PService p2PService;
private final MyReputationListService myReputationListService;

View file

@ -20,7 +20,9 @@ package bisq.desktop.main.funds.transactions;
import bisq.core.btc.wallet.BtcWalletService;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class DisplayedTransactionsFactory {
private final BtcWalletService btcWalletService;
private final TradableRepository tradableRepository;

View file

@ -24,11 +24,13 @@ import bisq.core.trade.closed.ClosedTradableManager;
import bisq.core.trade.failed.FailedTradesManager;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
@Singleton
public class TradableRepository {
private final OpenOfferManager openOfferManager;
private final TradeManager tradeManager;

View file

@ -23,7 +23,9 @@ import bisq.core.trade.Tradable;
import bisq.core.trade.Trade;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class TransactionAwareTradableFactory {
private final DisputeManager disputeManager;

View file

@ -27,11 +27,13 @@ import bisq.core.util.BSFormatter;
import org.bitcoinj.core.Transaction;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Optional;
import javax.annotation.Nullable;
@Singleton
public class TransactionListItemFactory {
private final BtcWalletService btcWalletService;
private final BsqWalletService bsqWalletService;

View file

@ -22,6 +22,7 @@ import bisq.core.offer.OfferBookService;
import bisq.core.trade.TradeManager;
import javax.inject.Inject;
import javax.inject.Singleton;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@ -42,6 +43,7 @@ import static bisq.core.offer.OfferPayload.Direction.BUY;
* It also use OfferRepository.Listener as the lists items class and we don't want to get any dependency out of the
* package for that.
*/
@Singleton
@Slf4j
public class OfferBook {
private final OfferBookService offerBookService;

View file

@ -173,7 +173,7 @@ public abstract class Overlay<T extends Overlay> {
private HPos buttonAlignment = HPos.RIGHT;
protected Optional<Runnable> closeHandlerOptional = Optional.<Runnable>empty();
protected Optional<Runnable> actionHandlerOptional = Optional.<Runnable>empty();
protected Optional<Runnable> actionHandlerOptional = Optional.empty();
protected Optional<Runnable> secondaryActionHandlerOptional = Optional.<Runnable>empty();
protected ChangeListener<Number> positionListener;
@ -438,7 +438,7 @@ public abstract class Overlay<T extends Overlay> {
public T useShutDownButton() {
this.actionButtonText = Res.get("shared.shutDown");
this.actionHandlerOptional = Optional.of(BisqApp.getShutDownHandler());
this.actionHandlerOptional = Optional.ofNullable(BisqApp.getShutDownHandler());
//noinspection unchecked
return (T) this;
}

View file

@ -38,6 +38,8 @@ import bisq.common.UserThread;
import com.google.inject.Inject;
import javax.inject.Singleton;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.Subscription;
@ -54,6 +56,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
@Slf4j
@Singleton
public class NotificationCenter {
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -38,6 +38,7 @@ import bisq.common.util.Tuple4;
import bisq.common.util.Utilities;
import javax.inject.Inject;
import javax.inject.Singleton;
import javafx.scene.Scene;
import javafx.scene.control.Button;
@ -72,6 +73,7 @@ import lombok.extern.slf4j.Slf4j;
import static bisq.desktop.util.FormBuilder.*;
@Slf4j
@Singleton
public class TorNetworkSettingsWindow extends Overlay<TorNetworkSettingsWindow> {
public enum BridgeOption {

View file

@ -12,6 +12,7 @@ import bisq.core.user.Preferences;
import bisq.common.app.DevEnv;
import javax.inject.Inject;
import javax.inject.Singleton;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
@ -25,6 +26,7 @@ import javafx.collections.MapChangeListener;
import lombok.Getter;
@Singleton
public class DaoPresentation implements DaoStateListener {
public static final String DAO_NEWS = "daoNewsVersion1.0.0";

View file

@ -35,6 +35,7 @@ import bisq.core.util.BSFormatter;
import bisq.common.UserThread;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.Subscription;
@ -60,6 +61,7 @@ import java.util.stream.Collectors;
import lombok.Getter;
@Singleton
public class MarketPricePresentation {
private final Preferences preferences;
private final BSFormatter formatter;

View file

@ -22,6 +22,7 @@ import bisq.core.user.Preferences;
import bisq.common.UserThread;
import javax.inject.Inject;
import javax.inject.Singleton;
import javafx.animation.FadeTransition;
import javafx.animation.Interpolator;
@ -39,6 +40,7 @@ import javafx.event.EventHandler;
import javafx.util.Duration;
@Singleton
public class Transitions {
public final static int DEFAULT_DURATION = 600;

View file

@ -0,0 +1,135 @@
package bisq.desktop;
import bisq.desktop.app.BisqAppModule;
import bisq.desktop.common.view.CachingViewLoader;
import bisq.desktop.common.view.ViewLoader;
import bisq.desktop.common.view.guice.InjectorViewFactory;
import bisq.desktop.main.dao.bonding.BondingViewUtils;
import bisq.desktop.main.funds.transactions.DisplayedTransactionsFactory;
import bisq.desktop.main.funds.transactions.TradableRepository;
import bisq.desktop.main.funds.transactions.TransactionAwareTradableFactory;
import bisq.desktop.main.funds.transactions.TransactionListItemFactory;
import bisq.desktop.main.offer.offerbook.OfferBook;
import bisq.desktop.main.overlays.notifications.NotificationCenter;
import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow;
import bisq.desktop.main.presentation.DaoPresentation;
import bisq.desktop.main.presentation.MarketPricePresentation;
import bisq.desktop.util.Transitions;
import bisq.core.app.AvoidStandbyModeService;
import bisq.core.app.BisqEnvironment;
import bisq.core.app.P2PNetworkSetup;
import bisq.core.app.TorSetup;
import bisq.core.app.WalletAppSetup;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.network.p2p.seed.DefaultSeedNodeRepository;
import bisq.core.notifications.MobileMessageEncryption;
import bisq.core.notifications.MobileModel;
import bisq.core.notifications.MobileNotificationService;
import bisq.core.notifications.MobileNotificationValidator;
import bisq.core.notifications.alerts.MyOfferTakenEvents;
import bisq.core.notifications.alerts.TradeEvents;
import bisq.core.notifications.alerts.market.MarketAlerts;
import bisq.core.notifications.alerts.price.PriceAlert;
import bisq.core.payment.TradeLimits;
import bisq.core.proto.network.CoreNetworkProtoResolver;
import bisq.core.proto.persistable.CorePersistenceProtoResolver;
import bisq.core.user.Preferences;
import bisq.core.user.User;
import bisq.core.util.BSFormatter;
import bisq.core.util.BsqFormatter;
import bisq.network.p2p.network.BridgeAddressProvider;
import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.ClockWatcher;
import bisq.common.crypto.KeyRing;
import bisq.common.crypto.KeyStorage;
import bisq.common.proto.network.NetworkProtoResolver;
import bisq.common.proto.persistable.PersistenceProtoResolver;
import bisq.common.storage.CorruptedDatabaseFilesHandler;
import org.springframework.mock.env.MockPropertySource;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
public class GuiceSetupTest {
private Injector injector;
@Before
public void setUp() {
Res.setup();
CurrencyUtil.setup();
injector = Guice.createInjector(new BisqAppModule(new BisqEnvironment(new MockPropertySource())));
}
@Test
public void testGuiceSetup() {
injector.getInstance(AvoidStandbyModeService.class);
// desktop module
assertSingleton(OfferBook.class);
assertSingleton(CachingViewLoader.class);
assertSingleton(Navigation.class);
assertSingleton(InjectorViewFactory.class);
assertSingleton(NotificationCenter.class);
assertSingleton(BSFormatter.class);
assertSingleton(BsqFormatter.class);
assertSingleton(TorNetworkSettingsWindow.class);
assertSingleton(MarketPricePresentation.class);
assertSingleton(ViewLoader.class);
assertSingleton(DaoPresentation.class);
assertSingleton(Transitions.class);
assertSingleton(TradableRepository.class);
assertSingleton(TransactionListItemFactory.class);
assertSingleton(TransactionAwareTradableFactory.class);
assertSingleton(DisplayedTransactionsFactory.class);
assertSingleton(BondingViewUtils.class);
// core module
// assertSingleton(BisqSetup.class); // this is a can of worms
// assertSingleton(DisputeMsgEvents.class);
assertSingleton(TorSetup.class);
assertSingleton(P2PNetworkSetup.class);
assertSingleton(WalletAppSetup.class);
assertSingleton(TradeLimits.class);
assertSingleton(KeyStorage.class);
assertSingleton(KeyRing.class);
assertSingleton(User.class);
assertSingleton(ClockWatcher.class);
assertSingleton(Preferences.class);
assertSingleton(BridgeAddressProvider.class);
assertSingleton(CorruptedDatabaseFilesHandler.class);
assertSingleton(AvoidStandbyModeService.class);
assertSingleton(DefaultSeedNodeRepository.class);
assertSingleton(SeedNodeRepository.class);
assertTrue(injector.getInstance(SeedNodeRepository.class) instanceof DefaultSeedNodeRepository);
assertSingleton(CoreNetworkProtoResolver.class);
assertSingleton(NetworkProtoResolver.class);
assertTrue(injector.getInstance(NetworkProtoResolver.class) instanceof CoreNetworkProtoResolver);
assertSingleton(PersistenceProtoResolver.class);
assertSingleton(CorePersistenceProtoResolver.class);
assertTrue(injector.getInstance(PersistenceProtoResolver.class) instanceof CorePersistenceProtoResolver);
assertSingleton(MobileMessageEncryption.class);
assertSingleton(MobileNotificationService.class);
assertSingleton(MobileNotificationValidator.class);
assertSingleton(MobileModel.class);
assertSingleton(MyOfferTakenEvents.class);
assertSingleton(TradeEvents.class);
assertSingleton(PriceAlert.class);
assertSingleton(MarketAlerts.class);
}
private void assertSingleton(Class<?> type) {
assertSame(injector.getInstance(type), injector.getInstance(type));
}
}

View file

@ -42,7 +42,7 @@ dependencyVerification {
'ch.qos.logback:logback-core:4cd46fa17d77057b39160058df2f21ebbc2aded51d0edcc25d2c1cecc042a005',
'com.google.code.findbugs:jsr305:766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7',
'com.google.guava:guava:36a666e3b71ae7f0f0dca23654b67e086e6c93d192f60ba5dfd5519db6c288c8',
'com.google.inject:guice:9b9df27a5b8c7864112b4137fd92b36c3f1395bfe57be42fedf2f520ead1a93e',
'com.google.inject:guice:d258ff1bd9b8b527872f8402648226658ad3149f1f40e74b0566d69e7e042fbc',
'com.github.bisq-network.bitcoinj:bitcoinj-core:f979c2187e61ee3b08dd4cbfc49a149734cff64c045d29ed112f2e12f34068a3',
'com.github.JesusMcCloud.netlayer:tor:7950f8b44609eba2524941cb6517f43ade34e53c820aea849006e22eee93a83d',
'org.jetbrains.kotlin:kotlin-stdlib-jdk8:193ab7813e4d249f2ea4fc1b968fea8c2126bcbeeb5d6127050ce1b93dbaa7c2',
@ -80,4 +80,3 @@ dependencyVerification {
'org.jetbrains.kotlin:kotlin-stdlib-common:4b161ef619eee0d1a49b1c4f0c4a8e46f4e342573efd8e0106a765f47475fe39',
]
}