Search in sources :

Example 6 with BitsquareEnvironment

use of io.bitsquare.app.BitsquareEnvironment in project bitsquare by bitsquare.

the class StatisticsMain method main.

public static void main(String[] args) throws Exception {
    final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("Statistics").setDaemon(true).build();
    UserThread.setExecutor(Executors.newSingleThreadExecutor(threadFactory));
    // We don't want to do the full argument parsing here as that might easily change in update versions
    // So we only handle the absolute minimum which is APP_NAME, APP_DATA_DIR_KEY and USER_DATA_DIR
    BitsquareEnvironment.setDefaultAppName("Bitsquare_statistics");
    OptionParser parser = new OptionParser();
    parser.allowsUnrecognizedOptions();
    parser.accepts(AppOptionKeys.USER_DATA_DIR_KEY, description("User data directory", DEFAULT_USER_DATA_DIR)).withRequiredArg();
    parser.accepts(AppOptionKeys.APP_NAME_KEY, description("Application name", DEFAULT_APP_NAME)).withRequiredArg();
    OptionSet options;
    try {
        options = parser.parse(args);
    } catch (OptionException ex) {
        System.out.println("error: " + ex.getMessage());
        System.out.println();
        parser.printHelpOn(System.out);
        System.exit(EXIT_FAILURE);
        return;
    }
    BitsquareEnvironment bitsquareEnvironment = new BitsquareEnvironment(options);
    // need to call that before BitsquareAppMain().execute(args)
    BitsquareExecutable.initAppDir(bitsquareEnvironment.getProperty(AppOptionKeys.APP_DATA_DIR_KEY));
    // For some reason the JavaFX launch process results in us losing the thread context class loader: reset it.
    // In order to work around a bug in JavaFX 8u25 and below, you must include the following code as the first line of your realMain method:
    Thread.currentThread().setContextClassLoader(StatisticsMain.class.getClassLoader());
    new StatisticsMain().execute(args);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) OptionException(joptsimple.OptionException) BitsquareEnvironment(io.bitsquare.app.BitsquareEnvironment) OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser)

Example 7 with BitsquareEnvironment

use of io.bitsquare.app.BitsquareEnvironment in project bitsquare by bitsquare.

the class StatisticsModule method configure.

@Override
protected void configure() {
    bind(KeyStorage.class).in(Singleton.class);
    bind(KeyRing.class).in(Singleton.class);
    bind(User.class).in(Singleton.class);
    bind(Preferences.class).in(Singleton.class);
    bind(Clock.class).in(Singleton.class);
    File storageDir = new File(env.getRequiredProperty(Storage.DIR_KEY));
    bind(File.class).annotatedWith(named(Storage.DIR_KEY)).toInstance(storageDir);
    File keyStorageDir = new File(env.getRequiredProperty(KeyStorage.DIR_KEY));
    bind(File.class).annotatedWith(named(KeyStorage.DIR_KEY)).toInstance(keyStorageDir);
    bind(BitsquareEnvironment.class).toInstance((BitsquareEnvironment) env);
    // ordering is used for shut down sequence
    install(tradeModule());
    install(encryptionServiceModule());
    install(arbitratorModule());
    install(offerModule());
    install(torModule());
    install(bitcoinModule());
    install(alertModule());
    install(filterModule());
}
Also used : KeyRing(io.bitsquare.common.crypto.KeyRing) User(io.bitsquare.user.User) KeyStorage(io.bitsquare.common.crypto.KeyStorage) BitsquareEnvironment(io.bitsquare.app.BitsquareEnvironment) Preferences(io.bitsquare.user.Preferences) Clock(io.bitsquare.common.Clock) File(java.io.File)

Aggregations

BitsquareEnvironment (io.bitsquare.app.BitsquareEnvironment)7 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)4 ThreadFactory (java.util.concurrent.ThreadFactory)4 OptionException (joptsimple.OptionException)4 OptionParser (joptsimple.OptionParser)4 OptionSet (joptsimple.OptionSet)4 AppOptionKeys (io.bitsquare.app.AppOptionKeys)2 DEFAULT_APP_NAME (io.bitsquare.app.BitsquareEnvironment.DEFAULT_APP_NAME)2 DEFAULT_USER_DATA_DIR (io.bitsquare.app.BitsquareEnvironment.DEFAULT_USER_DATA_DIR)2 BitsquareExecutable (io.bitsquare.app.BitsquareExecutable)2 Clock (io.bitsquare.common.Clock)2 UserThread (io.bitsquare.common.UserThread)2 KeyRing (io.bitsquare.common.crypto.KeyRing)2 KeyStorage (io.bitsquare.common.crypto.KeyStorage)2 Profiler (io.bitsquare.common.util.Profiler)2 RestartUtil (io.bitsquare.common.util.RestartUtil)2 Preferences (io.bitsquare.user.Preferences)2 User (io.bitsquare.user.User)2 File (java.io.File)2 IOException (java.io.IOException)2