#1817 - Improve JavaConfig to work on AOT.
This commit is contained in:
@@ -15,11 +15,13 @@
|
||||
*/
|
||||
package org.springframework.hateoas.config;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.hateoas.server.EntityLinks;
|
||||
import org.springframework.hateoas.server.core.DelegatingEntityLinks;
|
||||
import org.springframework.plugin.core.OrderAwarePluginRegistry;
|
||||
import org.springframework.plugin.core.PluginRegistry;
|
||||
import org.springframework.plugin.core.support.PluginRegistryFactoryBean;
|
||||
|
||||
@@ -33,13 +35,15 @@ import org.springframework.plugin.core.support.PluginRegistryFactoryBean;
|
||||
class EntityLinksConfiguration {
|
||||
|
||||
@Bean
|
||||
PluginRegistryFactoryBean<EntityLinks, Class<?>> entityLinksPluginRegistry() {
|
||||
OrderAwarePluginRegistry<EntityLinks, Class<?>> entityLinksPluginRegistry(ApplicationContext context) {
|
||||
|
||||
PluginRegistryFactoryBean<EntityLinks, Class<?>> registry = new PluginRegistryFactoryBean<>();
|
||||
registry.setApplicationContext(context);
|
||||
registry.setType(EntityLinks.class);
|
||||
registry.setExclusions(new Class[] { DelegatingEntityLinks.class });
|
||||
registry.afterPropertiesSet();
|
||||
|
||||
return registry;
|
||||
return registry.getObject();
|
||||
}
|
||||
|
||||
@Primary
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.springframework.hateoas.server.core.DelegatingLinkRelationProvider;
|
||||
import org.springframework.hateoas.server.core.EvoInflectorLinkRelationProvider;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.plugin.core.OrderAwarePluginRegistry;
|
||||
import org.springframework.plugin.core.PluginRegistry;
|
||||
import org.springframework.plugin.core.config.EnablePluginRegistries;
|
||||
import org.springframework.plugin.core.support.PluginRegistryFactoryBean;
|
||||
@@ -106,14 +107,15 @@ public class HateoasConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
PluginRegistryFactoryBean<LinkRelationProvider, LookupContext> relProviderPluginRegistry() {
|
||||
OrderAwarePluginRegistry<LinkRelationProvider, LookupContext> relProviderPluginRegistry(ApplicationContext context) {
|
||||
|
||||
PluginRegistryFactoryBean<LinkRelationProvider, LookupContext> factory = new PluginRegistryFactoryBean<>();
|
||||
|
||||
factory.setApplicationContext(context);
|
||||
factory.setType(LinkRelationProvider.class);
|
||||
factory.setExclusions(new Class[] { DelegatingLinkRelationProvider.class });
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
return factory;
|
||||
return factory.getObject();
|
||||
}
|
||||
|
||||
// LinkDiscoverers
|
||||
|
||||
Reference in New Issue
Block a user