Revise method order in AbstractHttpServiceRegistrar

See gh-35244
This commit is contained in:
rstoyanchev
2025-07-31 05:22:29 +01:00
parent 0fc9e4ec1c
commit 9dbe304cf6
@@ -163,6 +163,16 @@ public abstract class AbstractHttpServiceRegistrar implements
}));
}
/**
* This method is called before any bean definition registrations are made.
* Subclasses must implement it to register the HTTP Services for which bean
* definitions for which proxies need to be created.
* @param registry to perform HTTP Service registrations with
* @param importingClassMetadata annotation metadata of the importing class
*/
protected abstract void registerHttpServices(
GroupRegistry registry, AnnotationMetadata importingClassMetadata);
private RootBeanDefinition createOrGetRegistry(BeanDefinitionRegistry beanRegistry) {
if (!beanRegistry.containsBeanDefinition(HTTP_SERVICE_PROXY_REGISTRY_BEAN_NAME)) {
RootBeanDefinition proxyRegistryBeanDef = new RootBeanDefinition();
@@ -177,34 +187,6 @@ public abstract class AbstractHttpServiceRegistrar implements
}
}
/**
* This method is called before any bean definition registrations are made.
* Subclasses must implement it to register the HTTP Services for which bean
* definitions for which proxies need to be created.
* @param registry to perform HTTP Service registrations with
* @param importingClassMetadata annotation metadata of the importing class
*/
protected abstract void registerHttpServices(
GroupRegistry registry, AnnotationMetadata importingClassMetadata);
/**
* Exposes the scan for HTTP Service types, looking for
* interfaces with type or method {@link HttpExchange} annotations.
* @param basePackage the packages to look under
* @return match bean definitions
*/
protected Stream<BeanDefinition> findHttpServices(String basePackage) {
if (this.scanner == null) {
Assert.state(this.environment != null, "Environment has not been set");
Assert.state(this.resourceLoader != null, "ResourceLoader has not been set");
this.scanner = new HttpExchangeClassPathScanningCandidateComponentProvider();
this.scanner.setEnvironment(this.environment);
this.scanner.setResourceLoader(this.resourceLoader);
}
return this.scanner.findCandidateComponents(basePackage).stream();
}
private void mergeGroups(RootBeanDefinition proxyRegistryBeanDef) {
ConstructorArgumentValues args = proxyRegistryBeanDef.getConstructorArgumentValues();
ConstructorArgumentValues.ValueHolder valueHolder = args.getArgumentValue(0, GroupsMetadata.class);
@@ -220,6 +202,23 @@ public abstract class AbstractHttpServiceRegistrar implements
return registry.getClient(groupName, ClassUtils.resolveClassName(httpServiceType, this.beanClassLoader));
}
/**
* Find HTTP Service types under the given base package, looking for
* interfaces with type or method {@link HttpExchange} annotations.
* @param basePackage the names of packages to look under
* @return match bean definitions
*/
protected Stream<BeanDefinition> findHttpServices(String basePackage) {
if (this.scanner == null) {
Assert.state(this.environment != null, "Environment has not been set");
Assert.state(this.resourceLoader != null, "ResourceLoader has not been set");
this.scanner = new HttpExchangeClassPathScanningCandidateComponentProvider();
this.scanner.setEnvironment(this.environment);
this.scanner.setResourceLoader(this.resourceLoader);
}
return this.scanner.findCandidateComponents(basePackage).stream();
}
/**
* Registry API to allow subclasses to register HTTP Services.