|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -57,25 +57,38 @@ public JettyClientHttpConnector() {
|
57 | 57 | * Constructor with an {@link JettyResourceFactory} that will manage shared resources.
|
58 | 58 | * @param resourceFactory the {@link JettyResourceFactory} to use
|
59 | 59 | * @param customizer the lambda used to customize the {@link HttpClient}
|
| 60 | + * @deprecated in favor of {@link JettyClientHttpConnector#JettyClientHttpConnector(HttpClient, JettyResourceFactory)} |
60 | 61 | */
|
| 62 | + @Deprecated |
61 | 63 | public JettyClientHttpConnector(
|
62 | 64 | JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) {
|
63 |
| - |
64 |
| - HttpClient httpClient = new HttpClient(); |
65 |
| - httpClient.setExecutor(resourceFactory.getExecutor()); |
66 |
| - httpClient.setByteBufferPool(resourceFactory.getByteBufferPool()); |
67 |
| - httpClient.setScheduler(resourceFactory.getScheduler()); |
| 65 | + this(new HttpClient(), resourceFactory); |
68 | 66 | if (customizer != null) {
|
69 |
| - customizer.accept(httpClient); |
| 67 | + customizer.accept(this.httpClient); |
70 | 68 | }
|
71 |
| - this.httpClient = httpClient; |
72 | 69 | }
|
73 | 70 |
|
74 | 71 | /**
|
75 | 72 | * Constructor with an initialized {@link HttpClient}.
|
76 | 73 | */
|
77 | 74 | public JettyClientHttpConnector(HttpClient httpClient) {
|
| 75 | + this(httpClient, null); |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * Constructor with an initialized {@link HttpClient} and configures it |
| 80 | + * with the given {@link JettyResourceFactory}. |
| 81 | + * @param httpClient the {@link HttpClient} to use |
| 82 | + * @param resourceFactory the {@link JettyResourceFactory} to use |
| 83 | + */ |
| 84 | + public JettyClientHttpConnector(HttpClient httpClient, |
| 85 | + @Nullable JettyResourceFactory resourceFactory) { |
78 | 86 | Assert.notNull(httpClient, "HttpClient is required");
|
| 87 | + if (resourceFactory != null) { |
| 88 | + httpClient.setExecutor(resourceFactory.getExecutor()); |
| 89 | + httpClient.setByteBufferPool(resourceFactory.getByteBufferPool()); |
| 90 | + httpClient.setScheduler(resourceFactory.getScheduler()); |
| 91 | + } |
79 | 92 | this.httpClient = httpClient;
|
80 | 93 | }
|
81 | 94 |
|
|
0 commit comments