mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Remove now unused BisqEnvironment class
In previous commits, BisqEnvironment functionality has been fully ported to the new, simpler and more type-safe Config class. This change removes BisqEnvironment and all dependencies on the Spring Framework Environment interface that it implements. The one exception is the pricenode module, which is separate and apart from the rest of the codebase in that it is a standalone, Spring-based HTTP service.
This commit is contained in:
parent
1216ba2e2c
commit
f5a1854762
@ -19,26 +19,19 @@ package bisq.common.app;
|
|||||||
|
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AppModule extends AbstractModule {
|
public abstract class AppModule extends AbstractModule {
|
||||||
|
|
||||||
protected final Environment environment;
|
|
||||||
protected final Config config;
|
protected final Config config;
|
||||||
|
|
||||||
private final List<AppModule> modules = new ArrayList<>();
|
private final List<AppModule> modules = new ArrayList<>();
|
||||||
|
|
||||||
protected AppModule(Environment environment, Config config) {
|
protected AppModule(Config config) {
|
||||||
Preconditions.checkNotNull(environment, "Environment must not be null");
|
|
||||||
this.environment = environment;
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,6 @@ package bisq.core.alert;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import static bisq.common.config.Config.IGNORE_DEV_MSG;
|
import static bisq.common.config.Config.IGNORE_DEV_MSG;
|
||||||
@ -29,8 +27,8 @@ import static com.google.inject.name.Names.named;
|
|||||||
|
|
||||||
public class AlertModule extends AppModule {
|
public class AlertModule extends AppModule {
|
||||||
|
|
||||||
public AlertModule(Environment environment, Config config) {
|
public AlertModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of Bisq.
|
|
||||||
*
|
|
||||||
* Bisq is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or (at
|
|
||||||
* your option) any later version.
|
|
||||||
*
|
|
||||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
|
||||||
* License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package bisq.core.app;
|
|
||||||
|
|
||||||
import bisq.common.BisqException;
|
|
||||||
|
|
||||||
import org.springframework.core.env.JOptCommandLinePropertySource;
|
|
||||||
import org.springframework.core.env.MutablePropertySources;
|
|
||||||
import org.springframework.core.env.PropertiesPropertySource;
|
|
||||||
import org.springframework.core.env.PropertySource;
|
|
||||||
import org.springframework.core.env.StandardEnvironment;
|
|
||||||
|
|
||||||
import joptsimple.OptionSet;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class BisqEnvironment extends StandardEnvironment {
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Static
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public static final String BISQ_COMMANDLINE_PROPERTY_SOURCE_NAME = "bisqCommandLineProperties";
|
|
||||||
public static final String BISQ_DEFAULT_PROPERTY_SOURCE_NAME = "bisqDefaultProperties";
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Instance fields
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
protected boolean isBitcoinLocalhostNodeRunning;
|
|
||||||
|
|
||||||
public BisqEnvironment(OptionSet options) {
|
|
||||||
this(new JOptCommandLinePropertySource(BISQ_COMMANDLINE_PROPERTY_SOURCE_NAME, checkNotNull(
|
|
||||||
options)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
public BisqEnvironment(PropertySource commandLineProperties) {
|
|
||||||
MutablePropertySources propertySources = getPropertySources();
|
|
||||||
propertySources.addFirst(commandLineProperties);
|
|
||||||
try {
|
|
||||||
propertySources.addLast(defaultProperties());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw new BisqException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getProperty(PropertySource properties, String propertyKey, String defaultValue) {
|
|
||||||
return properties.containsProperty(propertyKey) ? (String) properties.getProperty(propertyKey) : defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
private PropertySource<?> defaultProperties() {
|
|
||||||
return new PropertiesPropertySource(BISQ_DEFAULT_PROPERTY_SOURCE_NAME, new Properties() {
|
|
||||||
{
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -41,8 +41,6 @@ import bisq.common.handlers.ResultHandler;
|
|||||||
import bisq.common.proto.persistable.PersistedDataHost;
|
import bisq.common.proto.persistable.PersistedDataHost;
|
||||||
import bisq.common.setup.GracefulShutDownHandler;
|
import bisq.common.setup.GracefulShutDownHandler;
|
||||||
|
|
||||||
import org.springframework.core.env.JOptCommandLinePropertySource;
|
|
||||||
|
|
||||||
import joptsimple.OptionException;
|
import joptsimple.OptionException;
|
||||||
import joptsimple.OptionParser;
|
import joptsimple.OptionParser;
|
||||||
import joptsimple.OptionSet;
|
import joptsimple.OptionSet;
|
||||||
@ -58,10 +56,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import static bisq.core.app.BisqEnvironment.BISQ_COMMANDLINE_PROPERTY_SOURCE_NAME;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static java.lang.String.format;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSetup.BisqSetupListener {
|
public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSetup.BisqSetupListener {
|
||||||
|
|
||||||
@ -76,7 +70,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
|||||||
|
|
||||||
protected Injector injector;
|
protected Injector injector;
|
||||||
protected AppModule module;
|
protected AppModule module;
|
||||||
protected BisqEnvironment bisqEnvironment;
|
|
||||||
protected Config config;
|
protected Config config;
|
||||||
|
|
||||||
public BisqExecutable(String fullName, String scriptName, String appName, String version) {
|
public BisqExecutable(String fullName, String scriptName, String appName, String version) {
|
||||||
@ -129,8 +122,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
protected void doExecute(OptionSet options) {
|
protected void doExecute(OptionSet options) {
|
||||||
bisqEnvironment = new BisqEnvironment(
|
|
||||||
new JOptCommandLinePropertySource(BISQ_COMMANDLINE_PROPERTY_SOURCE_NAME, checkNotNull(options)));
|
|
||||||
configUserThread();
|
configUserThread();
|
||||||
CoreSetup.setup(config);
|
CoreSetup.setup(config);
|
||||||
addCapabilities();
|
addCapabilities();
|
||||||
|
@ -95,7 +95,7 @@ public class BisqHeadlessAppMain extends BisqExecutable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AppModule getModule() {
|
protected AppModule getModule() {
|
||||||
return new CoreModule(bisqEnvironment, config);
|
return new CoreModule(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,8 +45,6 @@ import bisq.common.crypto.PubKeyRingProvider;
|
|||||||
import bisq.common.proto.network.NetworkProtoResolver;
|
import bisq.common.proto.network.NetworkProtoResolver;
|
||||||
import bisq.common.proto.persistable.PersistenceProtoResolver;
|
import bisq.common.proto.persistable.PersistenceProtoResolver;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import static bisq.common.config.Config.*;
|
import static bisq.common.config.Config.*;
|
||||||
@ -54,13 +52,12 @@ import static com.google.inject.name.Names.named;
|
|||||||
|
|
||||||
public class CoreModule extends AppModule {
|
public class CoreModule extends AppModule {
|
||||||
|
|
||||||
public CoreModule(Environment environment, Config config) {
|
public CoreModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(BisqEnvironment.class).toInstance((BisqEnvironment) environment);
|
|
||||||
bind(Config.class).toInstance(config);
|
bind(Config.class).toInstance(config);
|
||||||
|
|
||||||
bind(BridgeAddressProvider.class).to(Preferences.class);
|
bind(BridgeAddressProvider.class).to(Preferences.class);
|
||||||
@ -83,15 +80,15 @@ public class CoreModule extends AppModule {
|
|||||||
|
|
||||||
|
|
||||||
// ordering is used for shut down sequence
|
// ordering is used for shut down sequence
|
||||||
install(new TradeModule(environment, config));
|
install(new TradeModule(config));
|
||||||
install(new EncryptionServiceModule(environment, config));
|
install(new EncryptionServiceModule(config));
|
||||||
install(new OfferModule(environment, config));
|
install(new OfferModule(config));
|
||||||
install(new P2PModule(environment, config));
|
install(new P2PModule(config));
|
||||||
install(new BitcoinModule(environment, config));
|
install(new BitcoinModule(config));
|
||||||
install(new DaoModule(environment, config));
|
install(new DaoModule(config));
|
||||||
install(new AlertModule(environment, config));
|
install(new AlertModule(config));
|
||||||
install(new FilterModule(environment, config));
|
install(new FilterModule(config));
|
||||||
install(new CorePresentationModule(environment, config));
|
install(new CorePresentationModule(config));
|
||||||
bind(PubKeyRing.class).toProvider(PubKeyRingProvider.class);
|
bind(PubKeyRing.class).toProvider(PubKeyRingProvider.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package bisq.core.app.misc;
|
package bisq.core.app.misc;
|
||||||
|
|
||||||
import bisq.core.alert.AlertModule;
|
import bisq.core.alert.AlertModule;
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.app.TorSetup;
|
import bisq.core.app.TorSetup;
|
||||||
import bisq.core.btc.BitcoinModule;
|
import bisq.core.btc.BitcoinModule;
|
||||||
import bisq.core.dao.DaoModule;
|
import bisq.core.dao.DaoModule;
|
||||||
@ -46,8 +45,6 @@ import bisq.common.crypto.PubKeyRingProvider;
|
|||||||
import bisq.common.proto.network.NetworkProtoResolver;
|
import bisq.common.proto.network.NetworkProtoResolver;
|
||||||
import bisq.common.proto.persistable.PersistenceProtoResolver;
|
import bisq.common.proto.persistable.PersistenceProtoResolver;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -57,13 +54,12 @@ import static com.google.inject.name.Names.named;
|
|||||||
|
|
||||||
public class ModuleForAppWithP2p extends AppModule {
|
public class ModuleForAppWithP2p extends AppModule {
|
||||||
|
|
||||||
public ModuleForAppWithP2p(Environment environment, Config config) {
|
public ModuleForAppWithP2p(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(BisqEnvironment.class).toInstance((BisqEnvironment) environment);
|
|
||||||
bind(Config.class).toInstance(config);
|
bind(Config.class).toInstance(config);
|
||||||
|
|
||||||
bind(KeyStorage.class).in(Singleton.class);
|
bind(KeyStorage.class).in(Singleton.class);
|
||||||
@ -86,14 +82,14 @@ public class ModuleForAppWithP2p extends AppModule {
|
|||||||
bindConstant().annotatedWith(named(REFERRAL_ID)).to(config.getReferralId());
|
bindConstant().annotatedWith(named(REFERRAL_ID)).to(config.getReferralId());
|
||||||
|
|
||||||
// ordering is used for shut down sequence
|
// ordering is used for shut down sequence
|
||||||
install(new TradeModule(environment, config));
|
install(new TradeModule(config));
|
||||||
install(new EncryptionServiceModule(environment, config));
|
install(new EncryptionServiceModule(config));
|
||||||
install(new OfferModule(environment, config));
|
install(new OfferModule(config));
|
||||||
install(new P2PModule(environment, config));
|
install(new P2PModule(config));
|
||||||
install(new BitcoinModule(environment, config));
|
install(new BitcoinModule(config));
|
||||||
install(new DaoModule(environment, config));
|
install(new DaoModule(config));
|
||||||
install(new AlertModule(environment, config));
|
install(new AlertModule(config));
|
||||||
install(new FilterModule(environment, config));
|
install(new FilterModule(config));
|
||||||
bind(PubKeyRing.class).toProvider(PubKeyRingProvider.class);
|
bind(PubKeyRing.class).toProvider(PubKeyRingProvider.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,6 @@ import bisq.core.provider.price.PriceFeedService;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
@ -52,8 +50,8 @@ import static com.google.inject.name.Names.named;
|
|||||||
|
|
||||||
public class BitcoinModule extends AppModule {
|
public class BitcoinModule extends AppModule {
|
||||||
|
|
||||||
public BitcoinModule(Environment environment, Config config) {
|
public BitcoinModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,16 +88,14 @@ import bisq.core.dao.state.unconfirmed.UnconfirmedBsqChangeOutputListService;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import static com.google.inject.name.Names.named;
|
import static com.google.inject.name.Names.named;
|
||||||
|
|
||||||
public class DaoModule extends AppModule {
|
public class DaoModule extends AppModule {
|
||||||
|
|
||||||
public DaoModule(Environment environment, Config config) {
|
public DaoModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package bisq.core.dao.state.model.governance;
|
package bisq.core.dao.state.model.governance;
|
||||||
|
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.dao.governance.param.Param;
|
import bisq.core.dao.governance.param.Param;
|
||||||
import bisq.core.dao.governance.proposal.IssuanceProposal;
|
import bisq.core.dao.governance.proposal.IssuanceProposal;
|
||||||
import bisq.core.dao.governance.proposal.ProposalType;
|
import bisq.core.dao.governance.proposal.ProposalType;
|
||||||
|
@ -20,8 +20,6 @@ package bisq.core.filter;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import static bisq.common.config.Config.IGNORE_DEV_MSG;
|
import static bisq.common.config.Config.IGNORE_DEV_MSG;
|
||||||
@ -29,8 +27,8 @@ import static com.google.inject.name.Names.named;
|
|||||||
|
|
||||||
public class FilterModule extends AppModule {
|
public class FilterModule extends AppModule {
|
||||||
|
|
||||||
public FilterModule(Environment environment, Config config) {
|
public FilterModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,8 +20,6 @@ package bisq.core.offer;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -29,8 +27,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class OfferModule extends AppModule {
|
public class OfferModule extends AppModule {
|
||||||
|
|
||||||
public OfferModule(Environment environment, Config config) {
|
public OfferModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,14 +20,12 @@ package bisq.core.presentation;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
public class CorePresentationModule extends AppModule {
|
public class CorePresentationModule extends AppModule {
|
||||||
|
|
||||||
public CorePresentationModule(Environment environment, Config config) {
|
public CorePresentationModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,8 +31,6 @@ import bisq.core.trade.statistics.TradeStatisticsManager;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import static bisq.common.config.Config.DUMP_STATISTICS;
|
import static bisq.common.config.Config.DUMP_STATISTICS;
|
||||||
@ -40,8 +38,8 @@ import static com.google.inject.name.Names.named;
|
|||||||
|
|
||||||
public class TradeModule extends AppModule {
|
public class TradeModule extends AppModule {
|
||||||
|
|
||||||
public TradeModule(Environment environment, Config config) {
|
public TradeModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,15 +17,12 @@
|
|||||||
|
|
||||||
package bisq.core.util.coin;
|
package bisq.core.util.coin;
|
||||||
|
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.util.FormattingUtils;
|
import bisq.core.util.FormattingUtils;
|
||||||
import bisq.core.util.coin.CoinFormatter;
|
|
||||||
|
|
||||||
import org.bitcoinj.core.Coin;
|
import org.bitcoinj.core.Coin;
|
||||||
import org.bitcoinj.utils.MonetaryFormat;
|
import org.bitcoinj.utils.MonetaryFormat;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of Bisq.
|
|
||||||
*
|
|
||||||
* Bisq is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or (at
|
|
||||||
* your option) any later version.
|
|
||||||
*
|
|
||||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
|
||||||
* License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package bisq.core.app;
|
|
||||||
|
|
||||||
import org.springframework.core.env.ConfigurableEnvironment;
|
|
||||||
import org.springframework.core.env.MutablePropertySources;
|
|
||||||
import org.springframework.core.env.PropertySource;
|
|
||||||
import org.springframework.mock.env.MockPropertySource;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static bisq.core.app.BisqEnvironment.*;
|
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.springframework.core.env.PropertySource.named;
|
|
||||||
|
|
||||||
public class BisqEnvironmentTests {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPropertySourcePrecedence() {
|
|
||||||
PropertySource commandlineProps = new MockPropertySource(BISQ_COMMANDLINE_PROPERTY_SOURCE_NAME)
|
|
||||||
.withProperty("key.x", "x.commandline");
|
|
||||||
|
|
||||||
ConfigurableEnvironment bisqEnvironment = new BisqEnvironment(commandlineProps);
|
|
||||||
MutablePropertySources propertySources = bisqEnvironment.getPropertySources();
|
|
||||||
|
|
||||||
assertThat(propertySources.precedenceOf(named(BISQ_COMMANDLINE_PROPERTY_SOURCE_NAME)), equalTo(0));
|
|
||||||
assertThat(propertySources.precedenceOf(named(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(1));
|
|
||||||
assertThat(propertySources.precedenceOf(named(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(2));
|
|
||||||
assertThat(propertySources.precedenceOf(named(BISQ_DEFAULT_PROPERTY_SOURCE_NAME)), equalTo(3));
|
|
||||||
|
|
||||||
// we removed support for the rest
|
|
||||||
/* assertThat(propertySources.precedenceOf(named(BISQ_APP_DIR_PROPERTY_SOURCE_NAME)), equalTo(3));
|
|
||||||
assertThat(propertySources.precedenceOf(named(BISQ_HOME_DIR_PROPERTY_SOURCE_NAME)), equalTo(4));
|
|
||||||
assertThat(propertySources.precedenceOf(named(BISQ_CLASSPATH_PROPERTY_SOURCE_NAME)), equalTo(5));*/
|
|
||||||
assertThat(propertySources.size(), equalTo(4));
|
|
||||||
|
|
||||||
assertThat(bisqEnvironment.getProperty("key.x"), equalTo("x.commandline")); // commandline value wins due to precedence
|
|
||||||
|
|
||||||
//TODO check why it fails
|
|
||||||
//assertThat(bisqEnvironment.getProperty("key.y"), equalTo("y.bisqEnvironment")); // bisqEnvironment value wins because it's the only one available
|
|
||||||
}
|
|
||||||
}
|
|
@ -75,7 +75,7 @@ public class BisqDaemonMain extends BisqHeadlessAppMain implements BisqSetup.Bis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AppModule getModule() {
|
protected AppModule getModule() {
|
||||||
return new CoreModule(bisqEnvironment, config);
|
return new CoreModule(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,8 +27,6 @@ import bisq.core.locale.Res;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
@ -38,9 +36,8 @@ import static bisq.common.config.Config.APP_NAME;
|
|||||||
|
|
||||||
public class DesktopModule extends AppModule {
|
public class DesktopModule extends AppModule {
|
||||||
|
|
||||||
|
public DesktopModule(Config config) {
|
||||||
public DesktopModule(Environment environment, Config config) {
|
super(config);
|
||||||
super(environment, config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,7 +104,7 @@ public class BisqAppMain extends BisqExecutable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AppModule getModule() {
|
protected AppModule getModule() {
|
||||||
return new BisqAppModule(bisqEnvironment, config);
|
return new BisqAppModule(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,17 +24,15 @@ import bisq.core.app.CoreModule;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
public class BisqAppModule extends AppModule {
|
public class BisqAppModule extends AppModule {
|
||||||
|
|
||||||
public BisqAppModule(Environment environment, Config config) {
|
public BisqAppModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
install(new CoreModule(environment, config));
|
install(new CoreModule(config));
|
||||||
install(new DesktopModule(environment, config));
|
install(new DesktopModule(config));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import bisq.desktop.app.BisqAppMain;
|
|||||||
import bisq.desktop.components.AutoTooltipToggleButton;
|
import bisq.desktop.components.AutoTooltipToggleButton;
|
||||||
import bisq.desktop.main.overlays.Overlay;
|
import bisq.desktop.main.overlays.Overlay;
|
||||||
|
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.locale.GlobalSettings;
|
import bisq.core.locale.GlobalSettings;
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import bisq.desktop.main.overlays.Overlay;
|
|||||||
import bisq.desktop.util.FormBuilder;
|
import bisq.desktop.util.FormBuilder;
|
||||||
import bisq.desktop.util.GUIUtil;
|
import bisq.desktop.util.GUIUtil;
|
||||||
|
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
import bisq.core.user.DontShowAgainLookup;
|
import bisq.core.user.DontShowAgainLookup;
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import bisq.desktop.main.overlays.Overlay;
|
|||||||
import bisq.desktop.main.overlays.popups.Popup;
|
import bisq.desktop.main.overlays.popups.Popup;
|
||||||
|
|
||||||
import bisq.core.alert.Alert;
|
import bisq.core.alert.Alert;
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
|
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
@ -17,7 +17,6 @@ import bisq.desktop.main.presentation.MarketPricePresentation;
|
|||||||
import bisq.desktop.util.Transitions;
|
import bisq.desktop.util.Transitions;
|
||||||
|
|
||||||
import bisq.core.app.AvoidStandbyModeService;
|
import bisq.core.app.AvoidStandbyModeService;
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.app.P2PNetworkSetup;
|
import bisq.core.app.P2PNetworkSetup;
|
||||||
import bisq.core.app.TorSetup;
|
import bisq.core.app.TorSetup;
|
||||||
import bisq.core.app.WalletAppSetup;
|
import bisq.core.app.WalletAppSetup;
|
||||||
@ -62,8 +61,6 @@ import bisq.common.proto.persistable.PersistenceProtoResolver;
|
|||||||
import bisq.common.storage.CorruptedDatabaseFilesHandler;
|
import bisq.common.storage.CorruptedDatabaseFilesHandler;
|
||||||
import bisq.common.storage.Storage;
|
import bisq.common.storage.Storage;
|
||||||
|
|
||||||
import org.springframework.mock.env.MockPropertySource;
|
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
@ -83,7 +80,7 @@ public class GuiceSetupTest {
|
|||||||
Res.setup();
|
Res.setup();
|
||||||
CurrencyUtil.setup();
|
CurrencyUtil.setup();
|
||||||
|
|
||||||
injector = Guice.createInjector(new BisqAppModule(new BisqEnvironment(new MockPropertySource()), new TestConfig()));
|
injector = Guice.createInjector(new BisqAppModule(new TestConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -4,7 +4,6 @@ import bisq.desktop.main.offer.MakerFeeProvider;
|
|||||||
import bisq.desktop.util.validation.SecurityDepositValidator;
|
import bisq.desktop.util.validation.SecurityDepositValidator;
|
||||||
|
|
||||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.btc.model.AddressEntry;
|
import bisq.core.btc.model.AddressEntry;
|
||||||
import bisq.core.btc.wallet.BsqWalletService;
|
import bisq.core.btc.wallet.BsqWalletService;
|
||||||
import bisq.core.btc.wallet.BtcWalletService;
|
import bisq.core.btc.wallet.BtcWalletService;
|
||||||
@ -22,9 +21,7 @@ import bisq.core.provider.price.MarketPrice;
|
|||||||
import bisq.core.provider.price.PriceFeedService;
|
import bisq.core.provider.price.PriceFeedService;
|
||||||
import bisq.core.user.Preferences;
|
import bisq.core.user.Preferences;
|
||||||
import bisq.core.user.User;
|
import bisq.core.user.User;
|
||||||
import bisq.core.util.coin.ImmutableCoinFormatter;
|
|
||||||
import bisq.core.util.coin.BsqFormatter;
|
import bisq.core.util.coin.BsqFormatter;
|
||||||
import bisq.core.util.coin.CoinFormatter;
|
|
||||||
import bisq.core.util.validation.InputValidator;
|
import bisq.core.util.validation.InputValidator;
|
||||||
|
|
||||||
import org.bitcoinj.core.Coin;
|
import org.bitcoinj.core.Coin;
|
||||||
|
@ -20,14 +20,12 @@ package bisq.network.crypto;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
public class EncryptionServiceModule extends AppModule {
|
public class EncryptionServiceModule extends AppModule {
|
||||||
|
|
||||||
public EncryptionServiceModule(Environment environment, Config config) {
|
public EncryptionServiceModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,8 +35,6 @@ import bisq.network.p2p.storage.persistence.ResourceDataStoreService;
|
|||||||
import bisq.common.app.AppModule;
|
import bisq.common.app.AppModule;
|
||||||
import bisq.common.config.Config;
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
@ -53,8 +51,8 @@ import static com.google.inject.util.Providers.of;
|
|||||||
|
|
||||||
public class P2PModule extends AppModule {
|
public class P2PModule extends AppModule {
|
||||||
|
|
||||||
public P2PModule(Environment environment, Config config) {
|
public P2PModule(Config config) {
|
||||||
super(environment, config);
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
package bisq.seednode;
|
package bisq.seednode;
|
||||||
|
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.app.BisqExecutable;
|
|
||||||
import bisq.core.app.misc.ExecutableForAppWithP2p;
|
import bisq.core.app.misc.ExecutableForAppWithP2p;
|
||||||
import bisq.core.app.misc.ModuleForAppWithP2p;
|
import bisq.core.app.misc.ModuleForAppWithP2p;
|
||||||
|
|
||||||
@ -86,7 +84,7 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AppModule getModule() {
|
protected AppModule getModule() {
|
||||||
return new ModuleForAppWithP2p(bisqEnvironment, config);
|
return new ModuleForAppWithP2p(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package bisq.seednode;
|
package bisq.seednode;
|
||||||
|
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.app.misc.AppSetupWithP2PAndDAO;
|
import bisq.core.app.misc.AppSetupWithP2PAndDAO;
|
||||||
import bisq.core.app.misc.ModuleForAppWithP2p;
|
import bisq.core.app.misc.ModuleForAppWithP2p;
|
||||||
import bisq.core.locale.CurrencyUtil;
|
import bisq.core.locale.CurrencyUtil;
|
||||||
@ -8,8 +7,6 @@ import bisq.core.locale.Res;
|
|||||||
|
|
||||||
import bisq.common.config.TestConfig;
|
import bisq.common.config.TestConfig;
|
||||||
|
|
||||||
import org.springframework.mock.env.MockPropertySource;
|
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -20,7 +17,7 @@ public class GuiceSetupTest {
|
|||||||
Res.setup();
|
Res.setup();
|
||||||
CurrencyUtil.setup();
|
CurrencyUtil.setup();
|
||||||
|
|
||||||
ModuleForAppWithP2p module = new ModuleForAppWithP2p(new BisqEnvironment(new MockPropertySource()), new TestConfig());
|
ModuleForAppWithP2p module = new ModuleForAppWithP2p(new TestConfig());
|
||||||
Guice.createInjector(module).getInstance(AppSetupWithP2PAndDAO.class);
|
Guice.createInjector(module).getInstance(AppSetupWithP2PAndDAO.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package bisq.statistics;
|
package bisq.statistics;
|
||||||
|
|
||||||
import bisq.core.app.BisqEnvironment;
|
|
||||||
import bisq.core.app.misc.ExecutableForAppWithP2p;
|
import bisq.core.app.misc.ExecutableForAppWithP2p;
|
||||||
import bisq.core.app.misc.ModuleForAppWithP2p;
|
import bisq.core.app.misc.ModuleForAppWithP2p;
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ public class StatisticsMain extends ExecutableForAppWithP2p {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AppModule getModule() {
|
protected AppModule getModule() {
|
||||||
return new ModuleForAppWithP2p(bisqEnvironment, config);
|
return new ModuleForAppWithP2p(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user