Subversion Repositories SmartDukaan

Rev

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

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