Subversion Repositories SmartDukaan

Rev

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

Rev 3093 Rev 3123
Line 1... Line -...
1
/**
-
 
2
 * 
-
 
3
 */
-
 
4
package in.shop2020.thrift.clients;
1
package in.shop2020.thrift.clients;
5
 
2
 
6
import in.shop2020.crm.CRMService.Client;
3
import in.shop2020.crm.CRMService.Client;
7
import in.shop2020.utils.ConfigClientKeys;
4
import in.shop2020.utils.ConfigClientKeys;
8
import in.shop2020.utils.Logger;
-
 
9
 
-
 
10
import javax.annotation.PostConstruct;
-
 
11
import javax.annotation.PreDestroy;
-
 
12
 
5
 
13
import org.apache.thrift.transport.TTransportException;
6
import org.apache.thrift.transport.TTransportException;
14
 
7
 
15
/**
-
 
16
 * @author mandeep
-
 
17
 * 
-
 
18
 */
-
 
19
public class CRMServiceClient extends GenericServiceClient {
8
public class CRMClient extends GenericClient{
20
 
9
 
21
    private Client client;
10
	private Client client = null;
22
 
11
 
23
    public CRMServiceClient(String clientIdentifier, String hostConfigKey,
-
 
24
            String portConfigKey) throws Exception {
-
 
25
        super(clientIdentifier, hostConfigKey, portConfigKey);
-
 
26
        client = new Client(protocol);
-
 
27
    }
12
	/**
28
 
-
 
29
    public CRMServiceClient() throws Exception {
-
 
30
        this(CRMServiceClient.class.getSimpleName(),
-
 
31
                ConfigClientKeys.crm_service_server_host.name(),
-
 
32
                ConfigClientKeys.crm_service_server_port.name());
-
 
33
 
13
	 * 
34
        if (transport.isOpen()) {
14
	 * @throws TTransportException
35
            Logger.log("Transport was already open", this);
-
 
36
        }
15
	 */
37
        try {
-
 
38
            transport.open();
-
 
39
            Logger.log("Transport opened", this);
-
 
40
        } catch (TTransportException e) {
16
	public CRMClient() throws TTransportException{
41
            Logger.log("Encountered exception while opening transport: ", e);
17
		this(ConfigClientKeys.crm_service_server_host.toString(), ConfigClientKeys.crm_service_server_port.toString());
42
        }
-
 
43
    }
18
	}
44
 
19
 
-
 
20
	/**
45
    @PostConstruct
21
	 * get the client for given hostkey and portkey
46
    private void openTransport() {
22
	 * @param hostConfigKey
47
        if (transport.isOpen()) {
23
	 * @param portConfigKey
48
            Logger.log("Transport was already open", this);
24
	 * @throws TTransportException
49
        }
25
	 */
50
        try {
-
 
51
            transport.open();
26
	public CRMClient(String hostConfigKey, String portConfigKey) throws TTransportException{
52
        } catch (TTransportException e) {
27
		super(hostConfigKey, portConfigKey);
53
            Logger.log("Encountered exception while open transport " + e, this);
28
		client = new Client(protocol);
54
        }
29
	}
55
    }
30
	
56
 
31
 
57
    @PreDestroy
32
	/**
58
    private void closeTransport() {
33
	 * Get the client
59
        if (transport != null && transport.isOpen()) {
-
 
60
            Logger.log("Closing transport :", this);
-
 
61
            transport.close();
-
 
62
        }
34
	 * @return
63
    }
35
	 */
64
 
-
 
65
    public Client getClient() {
36
	public Client getClient(){
66
        return client;
37
		return client;
67
    }
38
	}
68
 
39
	
69
    /*
-
 
70
     * (non-Javadoc)
-
 
71
     * 
-
 
72
     * @see in.shop2020.thrift.clients.GenericServiceClient#closeSession()
-
 
73
     */
-
 
74
    @Override
40
	@Override
75
    public void closeSession() {
41
	public void closeSession() {
76
        // TODO Auto-generated method stub
42
		return;
-
 
43
	}
77
 
44
 
78
    }
-
 
79
}
45
}