com.jd.httpservice.agent.HttpServiceConnection Maven / Gradle / Ivy
package com.jd.httpservice.agent;
import java.io.IOException;
import org.apache.http.impl.client.CloseableHttpClient;
class HttpServiceConnection implements ServiceConnection{
private ServiceEndpoint endpoint;
private CloseableHttpClient httpClient;
HttpServiceConnection(ServiceEndpoint endpoint, CloseableHttpClient httpClient) {
this.endpoint = endpoint;
this.httpClient = httpClient;
}
CloseableHttpClient getHttpClient() {
CloseableHttpClient cli = httpClient;
if (cli == null) {
throw new IllegalArgumentException("HttpServiceConnection has been closed!");
}
return cli;
}
@Override
public void close() {
CloseableHttpClient cli = httpClient;
if (cli != null) {
httpClient = null;
try {
cli.close();
} catch (IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
}
@Override
public ServiceEndpoint getEndpoint() {
return endpoint;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy