|
1 | 1 | /* |
2 | | - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * Copyright (c) 2019 Payara Foundation and/or its affiliates. All rights reserved. |
4 | 4 | * |
5 | 5 | * This program and the accompanying materials are made available under the |
|
24 | 24 | import java.util.List; |
25 | 25 | import java.util.Optional; |
26 | 26 | import java.util.Set; |
| 27 | +import java.util.logging.Level; |
| 28 | +import java.util.logging.Logger; |
27 | 29 | import java.util.stream.Collectors; |
28 | 30 |
|
29 | 31 | import javax.enterprise.context.spi.CreationalContext; |
30 | 32 | import javax.enterprise.inject.spi.BeanManager; |
| 33 | +import javax.enterprise.inject.spi.CDI; |
31 | 34 | import javax.ws.rs.Consumes; |
32 | 35 | import javax.ws.rs.Path; |
33 | 36 | import javax.ws.rs.Produces; |
|
56 | 59 | */ |
57 | 60 | class InterfaceModel { |
58 | 61 |
|
| 62 | + private static final Logger LOGGER = Logger.getLogger(InterfaceModel.class.getName()); |
| 63 | + |
59 | 64 | private final InjectionManager injectionManager; |
60 | 65 | private final Class<?> restClientClass; |
61 | 66 | private final String[] produces; |
@@ -336,9 +341,15 @@ Builder clientHeaders(ClientHeaderParam[] clientHeaderParams) { |
336 | 341 | } |
337 | 342 |
|
338 | 343 | Builder clientHeadersFactory(RegisterClientHeaders registerClientHeaders) { |
339 | | - clientHeadersFactory = registerClientHeaders != null |
340 | | - ? ReflectionUtil.createInstance(registerClientHeaders.value()) |
341 | | - : null; |
| 344 | + if (registerClientHeaders != null) { |
| 345 | + Class<? extends ClientHeadersFactory> value = registerClientHeaders.value(); |
| 346 | + try { |
| 347 | + clientHeadersFactory = CDI.current().select(value).get(); |
| 348 | + } catch (Exception ex) { |
| 349 | + LOGGER.log(Level.FINEST, ex, () -> "This class is not a CDI bean. " + value); |
| 350 | + clientHeadersFactory = ReflectionUtil.createInstance(value); |
| 351 | + } |
| 352 | + } |
342 | 353 | return this; |
343 | 354 | } |
344 | 355 |
|
|
0 commit comments