Blame | Last modification | View Log | RSS feed
package in.shop2020.thrift.clients;import in.shop2020.model.v1.widgets.WidgetService.Client;import in.shop2020.utils.ConfigClientKeys;import in.shop2020.utils.Logger;import javax.annotation.PostConstruct;import javax.annotation.PreDestroy;import org.apache.thrift.transport.TTransportException;public class WidgetServiceClient extends GenericServiceClient{private Client client = null;public WidgetServiceClient(String clientIdentifier, String hostConfigKey,String portConfigKey) throws Exception {super(clientIdentifier, hostConfigKey, portConfigKey);client = new Client(protocol);}public WidgetServiceClient()throws Exception{this(WidgetServiceClient.class.getSimpleName(), ConfigClientKeys.widget_service_hostname.toString(), ConfigClientKeys.widget_service_port.toString());if(transport.isOpen()){Logger.log("Transport was already open", this);}try {transport.open();} catch (TTransportException e) {Logger.log("Encountered exception while open transport "+ e, this);}}@PostConstructprivate void openTransport(){if(transport.isOpen()){Logger.log("Transport was already open", this);}try {transport.open();} catch (TTransportException e) {Logger.log("Encountered exception while open transport "+ e, this);}}public Client getClient(){return client;}@PreDestroyprivate void closeTransport(){if(transport != null && transport.isOpen()){Logger.log("Closing transport :", this);transport.close();}}}