Skip to content

Commit 9dbe304

Browse files
committed
Revise method order in AbstractHttpServiceRegistrar
See gh-35244
1 parent 0fc9e4e commit 9dbe304

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

spring-web/src/main/java/org/springframework/web/service/registry/AbstractHttpServiceRegistrar.java

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ public final void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefin
163163
}));
164164
}
165165

166+
/**
167+
* This method is called before any bean definition registrations are made.
168+
* Subclasses must implement it to register the HTTP Services for which bean
169+
* definitions for which proxies need to be created.
170+
* @param registry to perform HTTP Service registrations with
171+
* @param importingClassMetadata annotation metadata of the importing class
172+
*/
173+
protected abstract void registerHttpServices(
174+
GroupRegistry registry, AnnotationMetadata importingClassMetadata);
175+
166176
private RootBeanDefinition createOrGetRegistry(BeanDefinitionRegistry beanRegistry) {
167177
if (!beanRegistry.containsBeanDefinition(HTTP_SERVICE_PROXY_REGISTRY_BEAN_NAME)) {
168178
RootBeanDefinition proxyRegistryBeanDef = new RootBeanDefinition();
@@ -177,21 +187,25 @@ private RootBeanDefinition createOrGetRegistry(BeanDefinitionRegistry beanRegist
177187
}
178188
}
179189

180-
/**
181-
* This method is called before any bean definition registrations are made.
182-
* Subclasses must implement it to register the HTTP Services for which bean
183-
* definitions for which proxies need to be created.
184-
* @param registry to perform HTTP Service registrations with
185-
* @param importingClassMetadata annotation metadata of the importing class
186-
*/
187-
protected abstract void registerHttpServices(
188-
GroupRegistry registry, AnnotationMetadata importingClassMetadata);
190+
private void mergeGroups(RootBeanDefinition proxyRegistryBeanDef) {
191+
ConstructorArgumentValues args = proxyRegistryBeanDef.getConstructorArgumentValues();
192+
ConstructorArgumentValues.ValueHolder valueHolder = args.getArgumentValue(0, GroupsMetadata.class);
193+
Assert.state(valueHolder != null, "Expected GroupsMetadata constructor argument at index 0");
194+
GroupsMetadata target = (GroupsMetadata) valueHolder.getValue();
195+
Assert.state(target != null, "No constructor argument value");
196+
target.mergeWith(this.groupsMetadata);
197+
}
189198

199+
private Object getProxyInstance(String groupName, String httpServiceType) {
200+
Assert.state(this.beanFactory != null, "BeanFactory has not been set");
201+
HttpServiceProxyRegistry registry = this.beanFactory.getBean(HTTP_SERVICE_PROXY_REGISTRY_BEAN_NAME, HttpServiceProxyRegistry.class);
202+
return registry.getClient(groupName, ClassUtils.resolveClassName(httpServiceType, this.beanClassLoader));
203+
}
190204

191205
/**
192-
* Exposes the scan for HTTP Service types, looking for
206+
* Find HTTP Service types under the given base package, looking for
193207
* interfaces with type or method {@link HttpExchange} annotations.
194-
* @param basePackage the packages to look under
208+
* @param basePackage the names of packages to look under
195209
* @return match bean definitions
196210
*/
197211
protected Stream<BeanDefinition> findHttpServices(String basePackage) {
@@ -205,21 +219,6 @@ protected Stream<BeanDefinition> findHttpServices(String basePackage) {
205219
return this.scanner.findCandidateComponents(basePackage).stream();
206220
}
207221

208-
private void mergeGroups(RootBeanDefinition proxyRegistryBeanDef) {
209-
ConstructorArgumentValues args = proxyRegistryBeanDef.getConstructorArgumentValues();
210-
ConstructorArgumentValues.ValueHolder valueHolder = args.getArgumentValue(0, GroupsMetadata.class);
211-
Assert.state(valueHolder != null, "Expected GroupsMetadata constructor argument at index 0");
212-
GroupsMetadata target = (GroupsMetadata) valueHolder.getValue();
213-
Assert.state(target != null, "No constructor argument value");
214-
target.mergeWith(this.groupsMetadata);
215-
}
216-
217-
private Object getProxyInstance(String groupName, String httpServiceType) {
218-
Assert.state(this.beanFactory != null, "BeanFactory has not been set");
219-
HttpServiceProxyRegistry registry = this.beanFactory.getBean(HTTP_SERVICE_PROXY_REGISTRY_BEAN_NAME, HttpServiceProxyRegistry.class);
220-
return registry.getClient(groupName, ClassUtils.resolveClassName(httpServiceType, this.beanClassLoader));
221-
}
222-
223222

224223
/**
225224
* Registry API to allow subclasses to register HTTP Services.

0 commit comments

Comments
 (0)