|
14 | 14 |
|
15 | 15 | import static java.util.logging.Level.FINE; |
16 | 16 | import static java.util.regex.Pattern.CASE_INSENSITIVE; |
| 17 | +import static java.util.stream.Collectors.toList; |
17 | 18 | import static org.omnifaces.util.Reflection.toClassOrNull; |
18 | 19 |
|
19 | 20 | import java.lang.annotation.Annotation; |
| 21 | +import java.util.List; |
20 | 22 | import java.util.Map; |
| 23 | +import java.util.Objects; |
21 | 24 | import java.util.logging.Logger; |
22 | 25 | import java.util.regex.Pattern; |
| 26 | +import java.util.stream.Stream; |
23 | 27 |
|
24 | 28 | import javax.enterprise.context.ContextNotActiveException; |
25 | 29 | import javax.enterprise.context.spi.AlterableContext; |
@@ -77,12 +81,12 @@ public final class Beans { |
77 | 81 |
|
78 | 82 | private static final Logger logger = Logger.getLogger(Beans.class.getName()); |
79 | 83 |
|
80 | | - private static final String[] PROXY_INTERFACE_NAMES = { |
81 | | - "org.jboss.weld.proxy.WeldConstruct", |
82 | | - "org.apache.webbeans.proxy.OwbNormalScopeProxy", |
83 | | - "io.quarkus.arc.ClientProxy", |
84 | | - "io.quarkus.arc.Subclass" |
85 | | - }; |
| 84 | + private static final List<Class<?>> PROXY_INTERFACES = Stream.of( |
| 85 | + toClassOrNull("org.jboss.weld.proxy.WeldConstruct"), |
| 86 | + toClassOrNull("org.apache.webbeans.proxy.OwbNormalScopeProxy"), |
| 87 | + toClassOrNull("io.quarkus.arc.ClientProxy"), |
| 88 | + toClassOrNull("io.quarkus.arc.Subclass") |
| 89 | + ).filter(Objects::nonNull).collect(toList()); |
86 | 90 |
|
87 | 91 | // Both Weld and OWB generate proxy class names as "BeanClassName[...]$$[...]Proxy[...]" with a "$$" and "Proxy" in it. |
88 | 92 | // Hopefully unknown CDI proxy implementations follow the same de-facto standard. |
@@ -275,14 +279,10 @@ public static <T> boolean isProxy(T object) { |
275 | 279 | return false; |
276 | 280 | } |
277 | 281 |
|
278 | | - Class<?> beanClass = (object instanceof Class) ? (Class<?>) object : object.getClass(); |
| 282 | + Class<?> beanClass = object instanceof Class ? (Class<?>) object : object.getClass(); |
279 | 283 |
|
280 | | - for (String proxyInterfaceName : PROXY_INTERFACE_NAMES) { |
281 | | - Class<?> proxyInterface = toClassOrNull(proxyInterfaceName); |
282 | | - |
283 | | - if (proxyInterface != null && proxyInterface.isAssignableFrom(beanClass)) { |
284 | | - return true; |
285 | | - } |
| 284 | + if (PROXY_INTERFACES.stream().anyMatch(proxyInterface -> proxyInterface.isAssignableFrom(beanClass))) { |
| 285 | + return true; |
286 | 286 | } |
287 | 287 |
|
288 | 288 | // Fall back for unknown CDI proxy implementations. |
|
0 commit comments