Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
350 ashish 1
package in.shop2020.thrift.clients;
2
 
3
import in.shop2020.utils.ConfigClientKeys;
4
import in.shop2020.utils.ItemLogistics;
5
import in.shop2020.utils.Logger;
6
import in.shop2020.utils.HelperService.Client;
7
 
8
import java.util.List;
9
import java.util.Map;
10
 
11
import javax.annotation.PostConstruct;
12
import javax.annotation.PreDestroy;
13
 
14
import org.apache.thrift.transport.TTransportException;
15
 
16
public class HelperServiceClient extends GenericServiceClient{
17
	private Client client = null;
18
 
19
	public HelperServiceClient(String clientIdentifier,
20
			String hostConfigKey, String portConfigKey) throws Exception {
21
		super(clientIdentifier, hostConfigKey, portConfigKey);
22
		client = new Client(protocol);
23
 
24
	}
25
 
26
	public HelperServiceClient() throws Exception{
27
		this(HelperServiceClient.class.getSimpleName(), ConfigClientKeys.helper_service_hostname.toString(), ConfigClientKeys.helper_service_port.toString());
495 rajveer 28
		if(transport.isOpen()){
29
			Logger.log("Transport was already open", this);
30
		}
31
		try {
32
			transport.open();
33
			Logger.log("Transport opened", this);
34
		} catch (TTransportException e) {
35
			Logger.log("Encountered exception while open transport "+ e, this);
36
		}
350 ashish 37
	}
38
 
39
	@PostConstruct
40
	public void openTransport(){
41
		if(transport.isOpen()){
42
			Logger.log("Transport was already open", this);
43
		}
44
		try {
45
			transport.open();
46
		} catch (TTransportException e) {
47
			Logger.log("Encountered exception while open transport "+ e, this);
48
		}
49
	}
50
 
51
	@PreDestroy
52
	private void closeTransport(){
53
		if(transport != null && transport.isOpen()){
54
			Logger.log("Closing transport :", this);
55
			transport.close();
56
		}
57
	}
58
 
59
	public Client getClient(){
60
		return client;
61
	}
62
 
63
}