use setters from doStart

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2018-11-13 10:37:42 +01:00
parent 26eecd6f8e
commit fa38868406
1 changed files with 7 additions and 14 deletions

View File

@ -218,27 +218,20 @@ public class HttpClient extends ContainerLifeCycle
{ {
QueuedThreadPool threadPool = new QueuedThreadPool(); QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName(name); threadPool.setName(name);
executor = threadPool; setExecutor(threadPool);
addBean(executor);
} }
if (byteBufferPool == null) if (byteBufferPool == null)
{ setByteBufferPool(new MappedByteBufferPool(2048,
byteBufferPool = new MappedByteBufferPool(2048,
executor instanceof ThreadPool.SizedThreadPool executor instanceof ThreadPool.SizedThreadPool
? ((ThreadPool.SizedThreadPool)executor).getMaxThreads() / 2 ? ((ThreadPool.SizedThreadPool)executor).getMaxThreads() / 2
: ProcessorUtils.availableProcessors() * 2); : ProcessorUtils.availableProcessors() * 2));
addBean(byteBufferPool);
}
if (scheduler == null) if (scheduler == null)
setScheduler(new ScheduledExecutorScheduler(name + "-scheduler", false)); setScheduler(new ScheduledExecutorScheduler(name + "-scheduler", false));
if (resolver == null) if (resolver == null)
{ setSocketAddressResolver(new SocketAddressResolver.Async(executor, scheduler, getAddressResolutionTimeout()));
resolver = new SocketAddressResolver.Async(executor, scheduler, getAddressResolutionTimeout());
addBean(resolver);
}
handlers.put(new ContinueProtocolHandler()); handlers.put(new ContinueProtocolHandler());
handlers.put(new RedirectProtocolHandler(this)); handlers.put(new RedirectProtocolHandler(this));
@ -652,7 +645,7 @@ public class HttpClient extends ContainerLifeCycle
*/ */
public void setByteBufferPool(ByteBufferPool byteBufferPool) public void setByteBufferPool(ByteBufferPool byteBufferPool)
{ {
if (isRunning()) if (isStarted())
throw new IllegalStateException(getState()); throw new IllegalStateException(getState());
updateBean(this.byteBufferPool, byteBufferPool); updateBean(this.byteBufferPool, byteBufferPool);
this.byteBufferPool = byteBufferPool; this.byteBufferPool = byteBufferPool;
@ -806,7 +799,7 @@ public class HttpClient extends ContainerLifeCycle
*/ */
public void setExecutor(Executor executor) public void setExecutor(Executor executor)
{ {
if (isRunning()) if (isStarted())
throw new IllegalStateException(getState()); throw new IllegalStateException(getState());
updateBean(this.executor, executor); updateBean(this.executor, executor);
this.executor = executor; this.executor = executor;
@ -844,7 +837,7 @@ public class HttpClient extends ContainerLifeCycle
*/ */
public void setSocketAddressResolver(SocketAddressResolver resolver) public void setSocketAddressResolver(SocketAddressResolver resolver)
{ {
if (isRunning()) if (isStarted())
throw new IllegalStateException(getState()); throw new IllegalStateException(getState());
updateBean(this.resolver, resolver); updateBean(this.resolver, resolver);
this.resolver = resolver; this.resolver = resolver;