Java Code Examples for org.eclipse.jetty.client.HttpClient#setThreadPool()
The following examples show how to use
org.eclipse.jetty.client.HttpClient#setThreadPool() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamClientImpl.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException { this.configuration = configuration; log.info("Starting Jetty HttpClient..."); client = new HttpClient(); // Jetty client needs threads for its internal expiration routines, which we don't need but // can't disable, so let's abuse the request executor service for this client.setThreadPool( new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) { @Override protected void doStop() throws Exception { // Do nothing, don't shut down the Cling ExecutorService when Jetty stops! } } ); // These are some safety settings, we should never run into these timeouts as we // do our own expiration checking client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setMaxRetries(configuration.getRequestRetryCount()); try { client.start(); } catch (Exception ex) { throw new InitializationException( "Could not start Jetty HTTP client: " + ex, ex ); } }
Example 2
Source File: StreamClientImpl.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException { this.configuration = configuration; log.info("Starting Jetty HttpClient..."); client = new HttpClient(); // Jetty client needs threads for its internal expiration routines, which we don't need but // can't disable, so let's abuse the request executor service for this client.setThreadPool( new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) { @Override protected void doStop() throws Exception { // Do nothing, don't shut down the Cling ExecutorService when Jetty stops! } } ); // These are some safety settings, we should never run into these timeouts as we // do our own expiration checking client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setMaxRetries(configuration.getRequestRetryCount()); try { client.start(); } catch (Exception ex) { throw new InitializationException( "Could not start Jetty HTTP client: " + ex, ex ); } }