Class AbstractHttpServiceRegistrar
- All Implemented Interfaces:
Aware, BeanClassLoaderAware, BeanFactoryAware, ImportBeanDefinitionRegistrar, EnvironmentAware, ResourceLoaderAware
- Bean definitions for HTTP Service interface client proxies organized by
HttpServiceGroup. - Bean definition for an
HttpServiceProxyRegistryFactoryBeanthat initializes the infrastructure for each group,RestClientorWebClientand a proxy factory, necessary to create the proxies.
Subclasses determine the HTTP Service types (interfaces with
@HttpExchange methods) to register by implementing
registerHttpServices(AbstractHttpServiceRegistrar.GroupRegistry, 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, Stephane Nicoll
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceRegistry API to allow subclasses to register HTTP Services. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe bean name of theHttpServiceProxyRegistry. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidregisterBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry beanRegistry) Register bean definitions as necessary based on the given annotation metadata of the importing@Configurationclass.final voidregisterBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry, BeanNameGenerator generator) Register bean definitions as necessary based on the given annotation metadata of the importing@Configurationclass.protected abstract voidregisterHttpServices(AbstractHttpServiceRegistrar.GroupRegistry registry, AnnotationMetadata importingClassMetadata) This method is called before any bean definition registrations are made.voidsetBeanClassLoader(ClassLoader beanClassLoader) Callback that supplies the beanclass loaderto a bean instance.voidsetBeanFactory(BeanFactory beanFactory) Callback that supplies the owning factory to a bean instance.voidsetDefaultClientType(HttpServiceGroup.ClientType defaultClientType) Set the client type to use when an HTTP Service group's client type remainsHttpServiceGroup.ClientType.UNSPECIFIED.voidsetEnvironment(Environment environment) Set theEnvironmentthat this component runs in.voidsetResourceLoader(ResourceLoader resourceLoader) Set the ResourceLoader that this object runs in.
-
Field Details
-
HTTP_SERVICE_PROXY_REGISTRY_BEAN_NAME
The bean name of theHttpServiceProxyRegistry.- See Also:
-
-
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_CLIENTis used for any HTTP Service group whose client type remains unspecified. -
setEnvironment
Description copied from interface:EnvironmentAwareSet theEnvironmentthat this component runs in.- Specified by:
setEnvironmentin interfaceEnvironmentAware
-
setResourceLoader
Description copied from interface:ResourceLoaderAwareSet the ResourceLoader that this object runs in.This might be a ResourcePatternResolver, which can be checked through
instanceof ResourcePatternResolver. See also theResourcePatternUtils.getResourcePatternResolvermethod.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSetor a custom init-method. Invoked before ApplicationContextAware'ssetApplicationContext.- Specified by:
setResourceLoaderin interfaceResourceLoaderAware- Parameters:
resourceLoader- the ResourceLoader object to be used by this object- See Also:
-
setBeanFactory
Description copied from interface:BeanFactoryAwareCallback 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:
setBeanFactoryin interfaceBeanFactoryAware- Parameters:
beanFactory- owning BeanFactory (nevernull). The bean can immediately call methods on the factory.- Throws:
BeansException- in case of initialization errors- See Also:
-
setBeanClassLoader
Description copied from interface:BeanClassLoaderAwareCallback that supplies the beanclass loaderto a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean'sInitializingBean.afterPropertiesSet()method or a custom init-method.- Specified by:
setBeanClassLoaderin interfaceBeanClassLoaderAware- Parameters:
beanClassLoader- the owning class loader
-
registerBeanDefinitions
public final void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry, BeanNameGenerator generator) Description copied from interface:ImportBeanDefinitionRegistrarRegister bean definitions as necessary based on the given annotation metadata of the importing@Configurationclass.Note that
BeanDefinitionRegistryPostProcessortypes may not be registered here, due to lifecycle constraints related to@Configurationclass processing.The default implementation delegates to
ImportBeanDefinitionRegistrar.registerBeanDefinitions(AnnotationMetadata, BeanDefinitionRegistry).- Specified by:
registerBeanDefinitionsin 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_GENERATORby default, or a user-provided one ifConfigurationClassPostProcessor.setBeanNameGenerator(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:ImportBeanDefinitionRegistrarRegister bean definitions as necessary based on the given annotation metadata of the importing@Configurationclass.Note that
BeanDefinitionRegistryPostProcessortypes may not be registered here, due to lifecycle constraints related to@Configurationclass processing.The default implementation is empty.
- Specified by:
registerBeanDefinitionsin 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
-