Subversion Repositories SmartDukaan

Rev

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

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