| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import org.apache.thrift.protocol.TBinaryProtocol;
|
3 |
import org.apache.thrift.protocol.TBinaryProtocol;
|
| 4 |
import org.apache.thrift.protocol.TProtocolFactory;
|
4 |
import org.apache.thrift.protocol.TProtocolFactory;
|
| 5 |
import org.apache.thrift.server.TServer;
|
5 |
import org.apache.thrift.server.TServer;
|
| 6 |
import org.apache.thrift.server.TThreadPoolServer;
|
6 |
import org.apache.thrift.server.TThreadPoolServer;
|
| - |
|
7 |
import org.apache.thrift.server.TThreadPoolServer.Args;
|
| 7 |
import org.apache.thrift.transport.TFramedTransport;
|
8 |
import org.apache.thrift.transport.TFramedTransport;
|
| 8 |
import org.apache.thrift.transport.TServerSocket;
|
9 |
import org.apache.thrift.transport.TServerSocket;
|
| 9 |
import org.apache.thrift.transport.TServerTransport;
|
10 |
import org.apache.thrift.transport.TServerTransport;
|
| 10 |
import org.apache.thrift.transport.TTransportFactory;
|
11 |
import org.apache.thrift.transport.TTransportFactory;
|
| 11 |
import org.slf4j.Logger;
|
12 |
import org.slf4j.Logger;
|
| 12 |
import org.slf4j.LoggerFactory;
|
13 |
import org.slf4j.LoggerFactory;
|
| 13 |
|
14 |
|
| 14 |
import in.shop2020.payment.service.handler.PaymentServiceHandler;
|
15 |
import in.shop2020.payment.service.handler.PaymentServiceHandler;
|
| - |
|
16 |
import in.shop2020.payments.PaymentService.Iface;
|
| 15 |
import in.shop2020.payments.PaymentService.Processor;
|
17 |
import in.shop2020.payments.PaymentService.Processor;
|
| 16 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
18 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 17 |
import in.shop2020.utils.ConfigClientKeys;
|
19 |
import in.shop2020.utils.ConfigClientKeys;
|
| 18 |
|
20 |
|
| 19 |
public class PaymentServer {
|
21 |
public class PaymentServer {
|
| 20 |
private static Logger logger = LoggerFactory.getLogger(PaymentServer.class);
|
22 |
private static Logger logger = LoggerFactory.getLogger(PaymentServer.class);
|
| 21 |
|
23 |
|
| 22 |
private static PaymentServiceHandler handler;
|
24 |
private static PaymentServiceHandler handler;
|
| 23 |
|
25 |
|
| 24 |
private static Processor processor;
|
26 |
private static Processor<Iface> processor;
|
| 25 |
|
27 |
|
| 26 |
public static void main(String[] args){
|
28 |
public static void main(String[] args){
|
| 27 |
try{
|
29 |
try{
|
| 28 |
handler = new PaymentServiceHandler();
|
30 |
handler = new PaymentServiceHandler();
|
| 29 |
processor = new Processor(handler);
|
31 |
processor = new Processor<Iface>(handler);
|
| - |
|
32 |
|
| 30 |
|
33 |
|
| 31 |
int port = 9012;
|
34 |
int port = 9012;
|
| 32 |
try {
|
35 |
try {
|
| 33 |
String portNo = ConfigClient.getClient().get(ConfigClientKeys.payments_service_server_port.toString());
|
36 |
String portNo = ConfigClient.getClient().get(ConfigClientKeys.payments_service_server_port.toString());
|
| 34 |
port = Integer.parseInt(portNo);
|
37 |
port = Integer.parseInt(portNo);
|
| Line 37... |
Line 40... |
| 37 |
}
|
40 |
}
|
| 38 |
|
41 |
|
| 39 |
TServerTransport serverTransport = new TServerSocket(port);
|
42 |
TServerTransport serverTransport = new TServerSocket(port);
|
| 40 |
TTransportFactory tFactory = new TFramedTransport.Factory();
|
43 |
TTransportFactory tFactory = new TFramedTransport.Factory();
|
| 41 |
TProtocolFactory pFactory = new TBinaryProtocol.Factory();
|
44 |
TProtocolFactory pFactory = new TBinaryProtocol.Factory();
|
| - |
|
45 |
|
| - |
|
46 |
Args serverParams = new Args(serverTransport);
|
| - |
|
47 |
serverParams.processor(processor);
|
| - |
|
48 |
serverParams.transportFactory(tFactory);
|
| - |
|
49 |
serverParams.protocolFactory(pFactory);
|
| 42 |
TServer server = new TThreadPoolServer(processor, serverTransport, tFactory, pFactory);
|
50 |
TServer server = new TThreadPoolServer(serverParams);
|
| 43 |
|
51 |
|
| 44 |
logger.info("Payment service started on port 9012");
|
52 |
logger.info("Payment service started on port 9012");
|
| 45 |
server.serve();
|
53 |
server.serve();
|
| 46 |
}catch(Exception ex){
|
54 |
}catch(Exception ex){
|
| 47 |
ex.printStackTrace();
|
55 |
ex.printStackTrace();
|