Example #1
0
  @Bean
  public Set<Transaction> pendingTransactions() {
    String storage = "Redis";
    try {
      if (redisConnection.isAvailable()) {
        return redisConnection.createTransactionSet("pendingTransactions");
      }

      storage = "In memory";
      return Collections.synchronizedSet(new HashSet<Transaction>());
    } finally {
      logger.info(storage + " 'pendingTransactions' storage created.");
    }
  }
Example #2
0
  @Bean
  @Scope("prototype")
  public KeyValueDataSource keyValueDataSource() {
    String dataSource = CONFIG.getKeyValueDataSource();
    try {
      if ("redis".equals(dataSource) && redisConnection.isAvailable()) {
        // Name will be defined before initialization
        return redisConnection.createDataSource("");
      }

      dataSource = "leveldb";
      return new LevelDbDataSource();
    } finally {
      logger.info(dataSource + " key-value data source created.");
    }
  }