下面列出了怎么用org.apache.http.impl.conn.DefaultRoutePlanner的API类实例代码及写法,或者点击链接到github查看源代码。
private HttpRoutePlanner getRoutePlanner() {
if (isUsingProxy()) {
return new DefaultProxyRoutePlanner(new HttpHost(getProxyHost(), getProxyPort()));
} else {
return new DefaultRoutePlanner(null);
}
}
/**
* Initilisation procedure for this test case.
*
* @throws UnableToBuildSolRDFClientException in case the client cannot be built.
* @throws Exception in case of Solr startup failure.
*/
@BeforeClass
public static void initITTest() {
System.setProperty("tests.asserts", "false");
System.setProperty("jetty.port", "8080");
System.setProperty("solr.core.name", "store");
System.setProperty("solr.data.dir", initCoreDataDir.getAbsolutePath());
try {
SOLR = createJetty(
"target/solrdf-integration-tests-1.1-dev/solrdf",
JettyConfig.builder()
.setPort(8080)
.setContext("/solr")
.stopAtShutdown(true)
.build());
final HttpClient httpClient = HttpClientBuilder.create()
.setRoutePlanner(
new DefaultRoutePlanner(
new SchemePortResolver() {
@Override
public int resolve(final HttpHost host) throws UnsupportedSchemeException {
return SOLR.getLocalPort();
}
})).build();
SOLRDF_CLIENT = SolRDF.newBuilder()
.withEndpoint("http://127.0.0.1:8080/solr/store")
.withGraphStoreProtocolEndpointPath("/rdf-graph-store")
.withHttpClient(httpClient)
.withSPARQLEndpointPath("/sparql")
.build();
PLAIN_SOLR_CLIENT = new HttpSolrClient(SOLR_URI);
} catch (final Exception exception) {
throw new RuntimeException(exception);
}
}