1 package org.oxerr.chbtc.service.polling;
2
3 import org.oxerr.chbtc.CHBTCClient;
4 import org.oxerr.chbtc.CHBTCExchange;
5
6 import com.xeiam.xchange.Exchange;
7 import com.xeiam.xchange.ExchangeSpecification;
8
9 public class CHBTCBaseTradePollingService extends CHBTCBasePollingService {
10
11 protected final CHBTCClient client;
12
13 protected CHBTCBaseTradePollingService(Exchange exchange) {
14 super(exchange);
15 ExchangeSpecification spec = exchange.getExchangeSpecification();
16
17 final String tradeApiUrl = spec.getSslUri();
18 final String accessKey = spec.getApiKey();
19 final String secretKey = spec.getSecretKey();
20
21 final Integer socketTimeout = (Integer) spec
22 .getParameter(CHBTCExchange.SOCKET_TIMEOUT_PARAMETER);
23 final Integer connectTimeout = (Integer) spec
24 .getParameter(CHBTCExchange.CONNECT_TIMEOUT_PARAMETER);
25 final Integer connectionRequestTimeout = (Integer) spec
26 .getParameter(CHBTCExchange.CONNECTION_REQUEST_TIMEOUT_PARAMETER);
27
28 client = new CHBTCClient(
29 tradeApiUrl,
30 accessKey,
31 secretKey,
32 socketTimeout == null ? 0 : socketTimeout.intValue(),
33 connectTimeout == null ? 0 : connectTimeout.intValue(),
34 connectionRequestTimeout == null ? 0
35 : connectionRequestTimeout.intValue());
36 }
37
38
39
40
41 @Override
42 protected void finalize() throws Throwable {
43 this.client.close();
44 super.finalize();
45 }
46
47 }