Add py4j gateway to Monitor

This commit is contained in:
Manfred Karrer 2016-07-08 23:05:23 +02:00
parent c957b53f3a
commit 55b9873d19
4 changed files with 37 additions and 1 deletions

View File

@ -6,6 +6,6 @@ import org.slf4j.LoggerFactory;
public class DevFlags {
private static final Logger log = LoggerFactory.getLogger(DevFlags.class);
public static final boolean STRESS_TEST_MODE = false;
public static final boolean STRESS_TEST_MODE = true;
public static final boolean DEV_MODE = STRESS_TEST_MODE || false;
}

View File

@ -81,5 +81,13 @@
<artifactId>core</artifactId>
<version>${project.parent.version}</version>
</dependency>
<!--py4j-->
<!-- http://mvnrepository.com/artifact/net.sf.py4j/py4j -->
<dependency>
<groupId>net.sf.py4j</groupId>
<artifactId>py4j</artifactId>
<version>0.10.1</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,26 @@
package io.bitsquare.monitor;
import io.bitsquare.trade.offer.Offer;
import io.bitsquare.trade.offer.OfferBookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import py4j.GatewayServer;
import java.util.List;
public class Gateway {
private static final Logger log = LoggerFactory.getLogger(Gateway.class);
private OfferBookService offerBookService;
public Gateway(OfferBookService offerBookService) {
this.offerBookService = offerBookService;
GatewayServer gatewayServer = new GatewayServer(this);
gatewayServer.start();
log.info("Gateway Server Started");
}
public List<Offer> getOffers() {
return offerBookService.getOffers();
}
}

View File

@ -24,6 +24,7 @@ public class Monitor {
private static Environment env;
private final Injector injector;
private final OfferBookService offerBookService;
private final Gateway gateway;
private P2PService p2pService;
@ -67,5 +68,6 @@ public class Monitor {
p2pService = injector.getInstance(P2PService.class);
offerBookService = injector.getInstance(OfferBookService.class);
p2pService.start(false, null);
gateway = new Gateway(offerBookService);
}
}