Class AbstractHttpServiceRegistrar
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,ImportBeanDefinitionRegistrar
,EnvironmentAware
,ResourceLoaderAware
- Bean definitions for HTTP Service interface client proxies organized by
HttpServiceGroup
. - Bean definition for an
HttpServiceProxyRegistryFactoryBean
that initializes the infrastructure for each group,RestClient
orWebClient
and a proxy factory, necessary to create the proxies.
Subclasses determine the HTTP Service types (interfaces with
@HttpExchange
methods) to register by implementing
registerHttpServices(org.springframework.web.service.registry.AbstractHttpServiceRegistrar.GroupRegistry, org.springframework.core.type.AnnotationMetadata)
.
There is built-in support for declaring HTTP Services through
ImportHttpServices
annotations. It is also possible to perform
registrations directly, sourced in another way, by extending this class.
It is possible to import multiple instances of this registrar type.
Subsequent imports update the existing registry FactoryBean
definition, and likewise merge HTTP Service group definitions.
An application can autowire HTTP Service proxy beans, or autowire the
HttpServiceProxyRegistry
from which to obtain proxies.
- Since:
- 7.0
- Author:
- Rossen Stoyanchev, Phillip Webb, Olga Maciaszek-Sharma
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interface
Registry API to allow subclasses to register HTTP Services. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
registerBeanDefinitions
(AnnotationMetadata metadata, BeanDefinitionRegistry beanRegistry) Register bean definitions as necessary based on the given annotation metadata of the importing@Configuration
class.final void
registerBeanDefinitions
(AnnotationMetadata metadata, BeanDefinitionRegistry registry, BeanNameGenerator generator) Register bean definitions as necessary based on the given annotation metadata of the importing@Configuration
class.protected abstract void
registerHttpServices
(AbstractHttpServiceRegistrar.GroupRegistry registry, AnnotationMetadata importingClassMetadata) This method is called before any bean definition registrations are made.void
setBeanFactory
(BeanFactory beanFactory) Callback that supplies the owning factory to a bean instance.void
setDefaultClientType
(HttpServiceGroup.ClientType defaultClientType) Set the client type to use when an HTTP Service group's client type remainsHttpServiceGroup.ClientType.UNSPECIFIED
.void
setEnvironment
(Environment environment) Set theEnvironment
that this component runs in.void
setResourceLoader
(ResourceLoader resourceLoader) Set the ResourceLoader that this object runs in.
-
Constructor Details
-
AbstractHttpServiceRegistrar
public AbstractHttpServiceRegistrar()
-
-
Method Details
-
setDefaultClientType
Set the client type to use when an HTTP Service group's client type remainsHttpServiceGroup.ClientType.UNSPECIFIED
.By default, when this property is not set, then
REST_CLIENT
is used for any HTTP Service group whose client type remains unspecified. -
setEnvironment
Description copied from interface:EnvironmentAware
Set theEnvironment
that this component runs in.- Specified by:
setEnvironment
in interfaceEnvironmentAware
-
setResourceLoader
Description copied from interface:ResourceLoaderAware
Set the ResourceLoader that this object runs in.This might be a ResourcePatternResolver, which can be checked through
instanceof ResourcePatternResolver
. See also theResourcePatternUtils.getResourcePatternResolver
method.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSet
or a custom init-method. Invoked before ApplicationContextAware'ssetApplicationContext
.- Specified by:
setResourceLoader
in interfaceResourceLoaderAware
- Parameters:
resourceLoader
- the ResourceLoader object to be used by this object- See Also:
-
setBeanFactory
Description copied from interface:BeanFactoryAware
Callback that supplies the owning factory to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method.- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Parameters:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- Throws:
BeansException
- in case of initialization errors- See Also:
-
registerBeanDefinitions
public final void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry, BeanNameGenerator generator) Description copied from interface:ImportBeanDefinitionRegistrar
Register bean definitions as necessary based on the given annotation metadata of the importing@Configuration
class.Note that
BeanDefinitionRegistryPostProcessor
types may not be registered here, due to lifecycle constraints related to@Configuration
class processing.The default implementation delegates to
ImportBeanDefinitionRegistrar.registerBeanDefinitions(AnnotationMetadata, BeanDefinitionRegistry)
.- Specified by:
registerBeanDefinitions
in interfaceImportBeanDefinitionRegistrar
- Parameters:
metadata
- annotation metadata of the importing classregistry
- current bean definition registrygenerator
- the bean name generator strategy for imported beans:ConfigurationClassPostProcessor.IMPORT_BEAN_NAME_GENERATOR
by default, or a user-provided one ifConfigurationClassPostProcessor.setBeanNameGenerator(org.springframework.beans.factory.support.BeanNameGenerator)
has been set. In the latter case, the passed-in strategy will be the same used for component scanning in the containing application context (otherwise, the default component-scan naming strategy isAnnotationBeanNameGenerator.INSTANCE
).- See Also:
-
registerBeanDefinitions
public final void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry beanRegistry) Description copied from interface:ImportBeanDefinitionRegistrar
Register bean definitions as necessary based on the given annotation metadata of the importing@Configuration
class.Note that
BeanDefinitionRegistryPostProcessor
types may not be registered here, due to lifecycle constraints related to@Configuration
class processing.The default implementation is empty.
- Specified by:
registerBeanDefinitions
in interfaceImportBeanDefinitionRegistrar
- Parameters:
metadata
- annotation metadata of the importing classbeanRegistry
- current bean definition registry
-
registerHttpServices
protected abstract void registerHttpServices(AbstractHttpServiceRegistrar.GroupRegistry registry, AnnotationMetadata importingClassMetadata) 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.- Parameters:
registry
- to perform HTTP Service registrations withimportingClassMetadata
- annotation metadata of the importing class
-