Subversion Repositories SmartDukaan

Rev

Rev 1021 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1021 Rev 3123
Line 1... Line 1...
1
package in.shop2020.thrift.clients;
1
package in.shop2020.thrift.clients;
2
 
2
 
-
 
3
 
3
import in.shop2020.payments.PaymentService.Client;
4
import in.shop2020.payments.PaymentService.Client;
4
import in.shop2020.utils.ConfigClientKeys;
5
import in.shop2020.utils.ConfigClientKeys;
5
import in.shop2020.utils.Logger;
-
 
6
 
-
 
7
import javax.annotation.PostConstruct;
-
 
8
import javax.annotation.PreDestroy;
-
 
9
 
6
 
10
import org.apache.thrift.TException;
7
import org.apache.thrift.TException;
11
import org.apache.thrift.transport.TTransportException;
8
import org.apache.thrift.transport.TTransportException;
12
 
9
 
13
public class PaymentServiceClient extends GenericServiceClient{
10
public class PaymentClient extends GenericClient{
14
 
11
 
15
private Client client = null;
12
	private Client client = null;
16
	
13
 
17
	public PaymentServiceClient(String clientIdentifier,
-
 
18
			String hostConfigKey, String portConfigKey) throws Exception {
-
 
19
		super(clientIdentifier, hostConfigKey, portConfigKey);
-
 
20
		client = new Client(protocol);
-
 
21
		
14
	/**
22
	}
-
 
23
	
-
 
24
	public PaymentServiceClient() throws Exception{
-
 
25
		this(PaymentServiceClient.class.getSimpleName(), ConfigClientKeys.payments_service_server_host.toString() , ConfigClientKeys.payments_service_server_port.toString());
-
 
26
		if(transport.isOpen()){
-
 
27
			Logger.log("Transport was already open", this);
-
 
28
		}
15
	 * 
29
		try {
-
 
30
			transport.open();
-
 
31
			Logger.log("Transport opened", this);
-
 
32
		} catch (TTransportException e) {
16
	 * @throws TTransportException
33
			Logger.log("Encountered exception while open transport "+ e, this);
-
 
34
		}
-
 
35
	}
-
 
36
	
-
 
37
	@PostConstruct
-
 
38
	private void openTransport(){
-
 
39
		if(transport.isOpen()){
-
 
40
			Logger.log("Transport was already open", this);
-
 
41
		}
17
	 */
42
		try {
-
 
43
			transport.open();
-
 
44
		} catch (TTransportException e) {
18
	public PaymentClient() throws TTransportException{
45
			Logger.log("Encountered exception while open transport "+ e, this);
19
		this(ConfigClientKeys.payments_service_server_host.toString(), ConfigClientKeys.payments_service_server_port.toString());
46
		}
-
 
47
	}
20
	}
48
	
21
 
49
	@PreDestroy
22
	/**
50
	private void closeTransport(){
23
	 * get the client for given hostkey and portkey
51
		if(transport != null && transport.isOpen()){
24
	 * @param hostConfigKey
52
			Logger.log("Closing transport :", this);
25
	 * @param portConfigKey
53
			transport.close();
26
	 * @throws TTransportException
54
		}
27
	 */
-
 
28
	public PaymentClient(String hostConfigKey, String portConfigKey) throws TTransportException{
-
 
29
		super(hostConfigKey, portConfigKey);
-
 
30
		client = new Client(protocol);
55
	}
31
	}
56
	
32
	
-
 
33
 
-
 
34
	/**
-
 
35
	 * Get the client
-
 
36
	 * @return
-
 
37
	 */
57
	public Client getClient(){
38
	public Client getClient(){
58
		return client;
39
		return client;
59
	}
40
	}
60
	
41
	
61
	@Override
42
	@Override
Line 64... Line 45...
64
			client.closeSession();
45
			client.closeSession();
65
		} catch (TException e) {
46
		} catch (TException e) {
66
			e.printStackTrace();
47
			e.printStackTrace();
67
		}
48
		}
68
	}
49
	}
-
 
50
 
69
}
51
}