Skip to content

Commit e4f5745

Browse files
jansupolsenivam
authored andcommitted
Move ConstraintTo check into ServiceFinder, to a single spot.
Filters ServiceFinder.toClassArray by ConstrainedTo ServiceFinder has a builder Signed-off-by: jansupol <[email protected]>
1 parent de109ab commit e4f5745

File tree

10 files changed

+291
-81
lines changed

10 files changed

+291
-81
lines changed

core-common/src/main/java/org/glassfish/jersey/AbstractFeatureConfigurator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2025 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -49,9 +49,11 @@ protected AbstractFeatureConfigurator(Class contract, RuntimeType runtimeType) {
4949
* @param loader specific classloader (must not be NULL)
5050
* @return list of found classes
5151
*/
52+
5253
protected List<Class<T>> loadImplementations(Map<String, Object> applicationProperties, ClassLoader loader) {
5354
if (PropertiesHelper.isMetaInfServicesEnabled(applicationProperties, getRuntimeType())) {
54-
return Stream.of(ServiceFinder.find(getContract(), loader, true).toClassArray())
55+
return Stream.of(ServiceFinder.service(getContract()).loader(loader).ignoreNotFound(true)
56+
.runtimeType(getRuntimeType()).find().toClassArray())
5557
.collect(Collectors.toList());
5658
}
5759
return Collections.emptyList();

core-common/src/main/java/org/glassfish/jersey/internal/AbstractServiceFinderConfigurator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2025 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -60,8 +60,8 @@ protected AbstractServiceFinderConfigurator(Class<T> contract, RuntimeType runti
6060
*/
6161
protected List<Class<T>> loadImplementations(Map<String, Object> applicationProperties) {
6262
if (PropertiesHelper.isMetaInfServicesEnabled(applicationProperties, runtimeType)) {
63-
return Stream.of(ServiceFinder.find(contract, true).toClassArray())
64-
.collect(Collectors.toList());
63+
return Stream.of(ServiceFinder.service(contract).ignoreNotFound(true).runtimeType(runtimeType)
64+
.find().toClassArray()).collect(Collectors.toList());
6565
}
6666
return Collections.emptyList();
6767
}

core-common/src/main/java/org/glassfish/jersey/internal/RuntimeDelegateDecorator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -114,7 +114,8 @@ private <T> HeaderDelegate<T> _createHeaderDelegate(final Class<T> type) {
114114

115115
static {
116116
Set<HeaderDelegateProvider> hps = new HashSet<HeaderDelegateProvider>();
117-
for (HeaderDelegateProvider provider : ServiceFinder.find(HeaderDelegateProvider.class, true)) {
117+
for (HeaderDelegateProvider provider : ServiceFinder
118+
.service(HeaderDelegateProvider.class).ignoreNotFound(true).find()) {
118119
hps.add(provider);
119120
}
120121
headerDelegateProviders = Collections.unmodifiableSet(hps);

0 commit comments

Comments
 (0)