reta commented on a change in pull request #482: [CXF-7926] Initial MP Rest
Client 1.2 impl
URL: https://github.com/apache/cxf/pull/482#discussion_r241992979
##########
File path:
rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
##########
@@ -20,22 +20,56 @@
import java.net.URI;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
+import java.util.ServiceLoader;
+import java.util.WeakHashMap;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.ws.rs.core.Configurable;
import javax.ws.rs.core.Configuration;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.client.spec.ClientImpl;
+import org.apache.cxf.microprofile.client.config.ConfigFacade;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
import org.eclipse.microprofile.rest.client.annotation.RegisterProvider;
+import org.eclipse.microprofile.rest.client.spi.RestClientListener;
public class CxfTypeSafeClientBuilder implements RestClientBuilder,
Configurable<RestClientBuilder> {
+ private static final Logger LOG =
LogUtils.getL7dLogger(CxfTypeSafeClientBuilder.class);
+ private static final String REST_CONN_TIMEOUT_FORMAT =
"%s/mp-rest/connectTimeout";
+ private static final String REST_READ_TIMEOUT_FORMAT =
"%s/mp-rest/readTimeout";
+ private static final Map<ClassLoader, Collection<RestClientListener>>
REST_CLIENT_LISTENERS =
+ new WeakHashMap<>();
+
private String baseUri;
private ExecutorService executorService;
private final MicroProfileClientConfigurableImpl<RestClientBuilder>
configImpl =
new MicroProfileClientConfigurableImpl<>(this);
+ private static Collection<RestClientListener> listeners() {
+ ClassLoader threadContextClassLoader = AccessController.doPrivileged(
+ (PrivilegedAction<ClassLoader>)() ->
Thread.currentThread().getContextClassLoader());
+ synchronized (REST_CLIENT_LISTENERS) {
+ return
REST_CLIENT_LISTENERS.computeIfAbsent(threadContextClassLoader, key -> {
Review comment:
May be just with steams:
```
return REST_CLIENT_LISTENERS.computeIfAbsent(threadContextClassLoader, key
-> StreamSupport
.stream(ServiceLoader.load(RestClientListener.class).spliterator(),
false)
.collect(Collectors.toList())
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services