mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-23 14:40:00 +00:00
Revise method order in AbstractHttpServiceRegistrar
See gh-35244
This commit is contained in:
+27
-28
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user