Blame | Last modification | View Log | RSS feed
package in.shop2020.thrift.clients;import java.util.List;import java.util.Map;import javax.annotation.PostConstruct;import javax.annotation.PreDestroy;import org.apache.thrift.transport.TTransportException;import in.shop2020.utils.ConfigClientKeys;import in.shop2020.utils.ItemLogistics;import in.shop2020.utils.Logger;import in.shop2020.utils.EstimationService.Client;public class EstimationServiceClient extends GenericServiceClient {private Client client = null;public EstimationServiceClient(String clientIdentifier,String hostConfigKey, String portConfigKey) throws Exception {super(clientIdentifier, hostConfigKey, portConfigKey);client = new Client(protocol);}public EstimationServiceClient() throws Exception{this(EstimationServiceClient.class.getSimpleName(), ConfigClientKeys.estimation_service_hostname.toString(), ConfigClientKeys.estimation_service_port.toString());}@PostConstructpublic 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);}}List<ItemLogistics> getLogisticsEstimation(long itemId, Map<String, String> location) throws Exception{return client.getLogisticsEstimation(itemId, location);}@PreDestroyprivate void closeTransport(){if(transport != null && transport.isOpen()){Logger.log("Closing transport :", this);transport.close();}}}