diff --git a/build.gradle b/build.gradle index ee6c651b7f..48eca018dc 100644 --- a/build.gradle +++ b/build.gradle @@ -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') diff --git a/common/src/main/java/bisq/common/ClockWatcher.java b/common/src/main/java/bisq/common/ClockWatcher.java index 0ca0a3423b..1b673535fa 100644 --- a/common/src/main/java/bisq/common/ClockWatcher.java +++ b/common/src/main/java/bisq/common/ClockWatcher.java @@ -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; diff --git a/common/src/main/java/bisq/common/crypto/KeyRing.java b/common/src/main/java/bisq/common/crypto/KeyRing.java index 4dab6ad3ac..7f965d702a 100644 --- a/common/src/main/java/bisq/common/crypto/KeyRing.java +++ b/common/src/main/java/bisq/common/crypto/KeyRing.java @@ -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; diff --git a/common/src/main/java/bisq/common/crypto/KeyStorage.java b/common/src/main/java/bisq/common/crypto/KeyStorage.java index 5a8d271acf..82274c34d2 100644 --- a/common/src/main/java/bisq/common/crypto/KeyStorage.java +++ b/common/src/main/java/bisq/common/crypto/KeyStorage.java @@ -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); diff --git a/common/src/main/java/bisq/common/storage/CorruptedDatabaseFilesHandler.java b/common/src/main/java/bisq/common/storage/CorruptedDatabaseFilesHandler.java index f33d8ac4bc..ac96760451 100644 --- a/common/src/main/java/bisq/common/storage/CorruptedDatabaseFilesHandler.java +++ b/common/src/main/java/bisq/common/storage/CorruptedDatabaseFilesHandler.java @@ -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 corruptedDatabaseFiles = new ArrayList<>(); diff --git a/core/src/main/java/bisq/core/CoreModule.java b/core/src/main/java/bisq/core/CoreModule.java index fa4d879515..adcbf3a163 100644 --- a/core/src/main/java/bisq/core/CoreModule.java +++ b/core/src/main/java/bisq/core/CoreModule.java @@ -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()); diff --git a/core/src/main/java/bisq/core/app/AvoidStandbyModeService.java b/core/src/main/java/bisq/core/app/AvoidStandbyModeService.java index 36badeaecd..bf9a733718 100644 --- a/core/src/main/java/bisq/core/app/AvoidStandbyModeService.java +++ b/core/src/main/java/bisq/core/app/AvoidStandbyModeService.java @@ -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; diff --git a/core/src/main/java/bisq/core/app/BisqSetup.java b/core/src/main/java/bisq/core/app/BisqSetup.java index d59dbd89bd..f4c2b66839 100644 --- a/core/src/main/java/bisq/core/app/BisqSetup.java +++ b/core/src/main/java/bisq/core/app/BisqSetup.java @@ -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(); diff --git a/core/src/main/java/bisq/core/app/P2PNetworkSetup.java b/core/src/main/java/bisq/core/app/P2PNetworkSetup.java index cbcda4bb3a..76527919dc 100644 --- a/core/src/main/java/bisq/core/app/P2PNetworkSetup.java +++ b/core/src/main/java/bisq/core/app/P2PNetworkSetup.java @@ -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; diff --git a/core/src/main/java/bisq/core/app/TorSetup.java b/core/src/main/java/bisq/core/app/TorSetup.java index 238e23e97a..669f570ee1 100644 --- a/core/src/main/java/bisq/core/app/TorSetup.java +++ b/core/src/main/java/bisq/core/app/TorSetup.java @@ -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; diff --git a/core/src/main/java/bisq/core/app/WalletAppSetup.java b/core/src/main/java/bisq/core/app/WalletAppSetup.java index e89df28ab8..f9ad67f2fd 100644 --- a/core/src/main/java/bisq/core/app/WalletAppSetup.java +++ b/core/src/main/java/bisq/core/app/WalletAppSetup.java @@ -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; diff --git a/core/src/main/java/bisq/core/network/p2p/seed/DefaultSeedNodeRepository.java b/core/src/main/java/bisq/core/network/p2p/seed/DefaultSeedNodeRepository.java index 6b3a021789..d8f4f039a1 100644 --- a/core/src/main/java/bisq/core/network/p2p/seed/DefaultSeedNodeRepository.java +++ b/core/src/main/java/bisq/core/network/p2p/seed/DefaultSeedNodeRepository.java @@ -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+)"); diff --git a/core/src/main/java/bisq/core/notifications/MobileMessageEncryption.java b/core/src/main/java/bisq/core/notifications/MobileMessageEncryption.java index 0b6195872b..37ddfe88d4 100644 --- a/core/src/main/java/bisq/core/notifications/MobileMessageEncryption.java +++ b/core/src/main/java/bisq/core/notifications/MobileMessageEncryption.java @@ -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; diff --git a/core/src/main/java/bisq/core/notifications/MobileModel.java b/core/src/main/java/bisq/core/notifications/MobileModel.java index ffd015afa0..2c212e7e4e 100644 --- a/core/src/main/java/bisq/core/notifications/MobileModel.java +++ b/core/src/main/java/bisq/core/notifications/MobileModel.java @@ -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 = "|"; diff --git a/core/src/main/java/bisq/core/notifications/MobileNotificationService.java b/core/src/main/java/bisq/core/notifications/MobileNotificationService.java index 3b80e0f894..e93845f0a4 100644 --- a/core/src/main/java/bisq/core/notifications/MobileNotificationService.java +++ b/core/src/main/java/bisq/core/notifications/MobileNotificationService.java @@ -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. diff --git a/core/src/main/java/bisq/core/notifications/MobileNotificationValidator.java b/core/src/main/java/bisq/core/notifications/MobileNotificationValidator.java index 95eab45fff..5cf6f2aeb5 100644 --- a/core/src/main/java/bisq/core/notifications/MobileNotificationValidator.java +++ b/core/src/main/java/bisq/core/notifications/MobileNotificationValidator.java @@ -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() { diff --git a/core/src/main/java/bisq/core/notifications/alerts/DisputeMsgEvents.java b/core/src/main/java/bisq/core/notifications/alerts/DisputeMsgEvents.java index e989317f77..fc9f21e0aa 100644 --- a/core/src/main/java/bisq/core/notifications/alerts/DisputeMsgEvents.java +++ b/core/src/main/java/bisq/core/notifications/alerts/DisputeMsgEvents.java @@ -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; diff --git a/core/src/main/java/bisq/core/notifications/alerts/MyOfferTakenEvents.java b/core/src/main/java/bisq/core/notifications/alerts/MyOfferTakenEvents.java index 2ed8a7ebb7..842dbadacc 100644 --- a/core/src/main/java/bisq/core/notifications/alerts/MyOfferTakenEvents.java +++ b/core/src/main/java/bisq/core/notifications/alerts/MyOfferTakenEvents.java @@ -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; diff --git a/core/src/main/java/bisq/core/notifications/alerts/TradeEvents.java b/core/src/main/java/bisq/core/notifications/alerts/TradeEvents.java index 43f51ec80e..adef19d1b1 100644 --- a/core/src/main/java/bisq/core/notifications/alerts/TradeEvents.java +++ b/core/src/main/java/bisq/core/notifications/alerts/TradeEvents.java @@ -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; diff --git a/core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java b/core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java index ac2a70a432..fad6fc2a2f 100644 --- a/core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java +++ b/core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java @@ -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; diff --git a/core/src/main/java/bisq/core/notifications/alerts/price/PriceAlert.java b/core/src/main/java/bisq/core/notifications/alerts/price/PriceAlert.java index c7b21aeaba..f52a048f60 100644 --- a/core/src/main/java/bisq/core/notifications/alerts/price/PriceAlert.java +++ b/core/src/main/java/bisq/core/notifications/alerts/price/PriceAlert.java @@ -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; diff --git a/core/src/main/java/bisq/core/payment/TradeLimits.java b/core/src/main/java/bisq/core/payment/TradeLimits.java index 78edb3a944..62e825e3ee 100644 --- a/core/src/main/java/bisq/core/payment/TradeLimits.java +++ b/core/src/main/java/bisq/core/payment/TradeLimits.java @@ -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 diff --git a/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java b/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java index 99dbf83ca7..3d0c065fc4 100644 --- a/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java @@ -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 diff --git a/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java b/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java index 4e4e5114c9..96e7bc9775 100644 --- a/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java @@ -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; private final NetworkProtoResolver networkProtoResolver; diff --git a/core/src/main/java/bisq/core/user/Preferences.java b/core/src/main/java/bisq/core/user/Preferences.java index d8023c5609..52e96b90da 100644 --- a/core/src/main/java/bisq/core/user/Preferences.java +++ b/core/src/main/java/bisq/core/user/Preferences.java @@ -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 BTC_MAIN_NET_EXPLORERS = new ArrayList<>(Arrays.asList( diff --git a/core/src/main/java/bisq/core/user/User.java b/core/src/main/java/bisq/core/user/User.java index 05b99b0fe2..af8637efaa 100644 --- a/core/src/main/java/bisq/core/user/User.java +++ b/core/src/main/java/bisq/core/user/User.java @@ -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 storage; final private KeyRing keyRing; diff --git a/core/src/main/java/bisq/core/util/BSFormatter.java b/core/src/main/java/bisq/core/util/BSFormatter.java index 9c49d7aaab..ffe731b639 100644 --- a/core/src/main/java/bisq/core/util/BSFormatter.java +++ b/core/src/main/java/bisq/core/util/BSFormatter.java @@ -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 = " - "; diff --git a/core/src/main/java/bisq/core/util/BsqFormatter.java b/core/src/main/java/bisq/core/util/BsqFormatter.java index cba0117212..7f2524598e 100644 --- a/core/src/main/java/bisq/core/util/BsqFormatter.java +++ b/core/src/main/java/bisq/core/util/BsqFormatter.java @@ -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(); diff --git a/desktop/src/main/java/bisq/desktop/DesktopModule.java b/desktop/src/main/java/bisq/desktop/DesktopModule.java index 3d7b601c16..ce4124f384 100644 --- a/desktop/src/main/java/bisq/desktop/DesktopModule.java +++ b/desktop/src/main/java/bisq/desktop/DesktopModule.java @@ -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)); } diff --git a/desktop/src/main/java/bisq/desktop/Navigation.java b/desktop/src/main/java/bisq/desktop/Navigation.java index 4fb4a7c322..a5f82fc52d 100644 --- a/desktop/src/main/java/bisq/desktop/Navigation.java +++ b/desktop/src/main/java/bisq/desktop/Navigation.java @@ -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); diff --git a/desktop/src/main/java/bisq/desktop/common/fxml/FxmlViewLoader.java b/desktop/src/main/java/bisq/desktop/common/fxml/FxmlViewLoader.java index 77b07e6978..62820fe4f8 100644 --- a/desktop/src/main/java/bisq/desktop/common/fxml/FxmlViewLoader.java +++ b/desktop/src/main/java/bisq/desktop/common/fxml/FxmlViewLoader.java @@ -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; diff --git a/desktop/src/main/java/bisq/desktop/common/view/CachingViewLoader.java b/desktop/src/main/java/bisq/desktop/common/view/CachingViewLoader.java index f86df63cee..cab1bc9d70 100644 --- a/desktop/src/main/java/bisq/desktop/common/view/CachingViewLoader.java +++ b/desktop/src/main/java/bisq/desktop/common/view/CachingViewLoader.java @@ -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 cache = new HashMap<>(); diff --git a/desktop/src/main/java/bisq/desktop/common/view/guice/InjectorViewFactory.java b/desktop/src/main/java/bisq/desktop/common/view/guice/InjectorViewFactory.java index 4b41b56cf0..b85de8fb75 100644 --- a/desktop/src/main/java/bisq/desktop/common/view/guice/InjectorViewFactory.java +++ b/desktop/src/main/java/bisq/desktop/common/view/guice/InjectorViewFactory.java @@ -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; diff --git a/desktop/src/main/java/bisq/desktop/main/dao/bonding/BondingViewUtils.java b/desktop/src/main/java/bisq/desktop/main/dao/bonding/BondingViewUtils.java index 4eba2b37e1..bd0a998099 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/bonding/BondingViewUtils.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/bonding/BondingViewUtils.java @@ -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; diff --git a/desktop/src/main/java/bisq/desktop/main/funds/transactions/DisplayedTransactionsFactory.java b/desktop/src/main/java/bisq/desktop/main/funds/transactions/DisplayedTransactionsFactory.java index 63a08bfebe..4f2e44fc9a 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/transactions/DisplayedTransactionsFactory.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/transactions/DisplayedTransactionsFactory.java @@ -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; diff --git a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TradableRepository.java b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TradableRepository.java index 0cabbe1438..691901fc1b 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TradableRepository.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TradableRepository.java @@ -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; diff --git a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionAwareTradableFactory.java b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionAwareTradableFactory.java index 0a6992d684..234d96c6b3 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionAwareTradableFactory.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionAwareTradableFactory.java @@ -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; diff --git a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionListItemFactory.java b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionListItemFactory.java index 752ca17e9e..e95974989d 100644 --- a/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionListItemFactory.java +++ b/desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionListItemFactory.java @@ -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; diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java index 53556eb948..99670bac96 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java @@ -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; diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java b/desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java index 66f8548409..2955e7c3b5 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java @@ -173,7 +173,7 @@ public abstract class Overlay { private HPos buttonAlignment = HPos.RIGHT; protected Optional closeHandlerOptional = Optional.empty(); - protected Optional actionHandlerOptional = Optional.empty(); + protected Optional actionHandlerOptional = Optional.empty(); protected Optional secondaryActionHandlerOptional = Optional.empty(); protected ChangeListener positionListener; @@ -438,7 +438,7 @@ public abstract class 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; } diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/notifications/NotificationCenter.java b/desktop/src/main/java/bisq/desktop/main/overlays/notifications/NotificationCenter.java index ed732eb718..04e9bfdf46 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/notifications/NotificationCenter.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/notifications/NotificationCenter.java @@ -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 { /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/TorNetworkSettingsWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/TorNetworkSettingsWindow.java index 5fd771c924..d6a4be79af 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/TorNetworkSettingsWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/TorNetworkSettingsWindow.java @@ -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 { public enum BridgeOption { diff --git a/desktop/src/main/java/bisq/desktop/main/presentation/DaoPresentation.java b/desktop/src/main/java/bisq/desktop/main/presentation/DaoPresentation.java index a13579cb08..27a7eab5d0 100644 --- a/desktop/src/main/java/bisq/desktop/main/presentation/DaoPresentation.java +++ b/desktop/src/main/java/bisq/desktop/main/presentation/DaoPresentation.java @@ -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"; diff --git a/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java b/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java index ef6f46dc26..870304ecf6 100644 --- a/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java +++ b/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java @@ -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; diff --git a/desktop/src/main/java/bisq/desktop/util/Transitions.java b/desktop/src/main/java/bisq/desktop/util/Transitions.java index 3892968adb..572f0fbe69 100644 --- a/desktop/src/main/java/bisq/desktop/util/Transitions.java +++ b/desktop/src/main/java/bisq/desktop/util/Transitions.java @@ -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; diff --git a/desktop/src/test/java/bisq/desktop/GuiceSetupTest.java b/desktop/src/test/java/bisq/desktop/GuiceSetupTest.java new file mode 100644 index 0000000000..68feb00202 --- /dev/null +++ b/desktop/src/test/java/bisq/desktop/GuiceSetupTest.java @@ -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)); + } +} diff --git a/gradle/witness/gradle-witness.gradle b/gradle/witness/gradle-witness.gradle index 5a3af56fae..58f15c9181 100644 --- a/gradle/witness/gradle-witness.gradle +++ b/gradle/witness/gradle-witness.gradle @@ -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', ] } -