DATAREST-1567 - Polishing.
Tweaked test setups to work without the explicit component scanning. Original pull request: #382.
This commit is contained in:
@@ -61,7 +61,7 @@ public class RestControllerConfiguration {
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
@Bean
|
||||
protected RepositoryController repositoryController(EntityLinks entityLinks) {
|
||||
RepositoryController repositoryController(EntityLinks entityLinks) {
|
||||
return new RepositoryController(resourcesAssembler, repositories, entityLinks, resourceMappings);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class RestControllerConfiguration {
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
@Bean
|
||||
protected RepositoryEntityController repositoryEntityController(RepositoryEntityLinks entityLinks,
|
||||
RepositoryEntityController repositoryEntityController(RepositoryEntityLinks entityLinks,
|
||||
HttpHeadersPreparer headersPreparer) {
|
||||
return new RepositoryEntityController(repositories, restConfiguration, entityLinks, resourcesAssembler,
|
||||
headersPreparer);
|
||||
@@ -87,7 +87,7 @@ public class RestControllerConfiguration {
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
@Bean
|
||||
protected RepositoryPropertyReferenceController repositoryPropertyReferenceController(
|
||||
RepositoryPropertyReferenceController repositoryPropertyReferenceController(
|
||||
RepositoryInvokerFactory repositoryInvokerFactory) {
|
||||
return new RepositoryPropertyReferenceController(repositories, repositoryInvokerFactory, resourcesAssembler);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class RestControllerConfiguration {
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
@Bean
|
||||
protected RepositorySearchController repositorySearchController(RepositoryEntityLinks entityLinks,
|
||||
RepositorySearchController repositorySearchController(RepositoryEntityLinks entityLinks,
|
||||
HttpHeadersPreparer headersPreparer) {
|
||||
return new RepositorySearchController(resourcesAssembler, entityLinks, resourceMappings, headersPreparer);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class RestControllerConfiguration {
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
@Bean
|
||||
protected RepositorySchemaController repositorySchemaController(
|
||||
RepositorySchemaController repositorySchemaController(
|
||||
PersistentEntityToJsonSchemaConverter jsonSchemaConverter) {
|
||||
return new RepositorySchemaController(jsonSchemaConverter);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class RestControllerConfiguration {
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
@Bean
|
||||
protected AlpsController alpsController() {
|
||||
AlpsController alpsController() {
|
||||
return new AlpsController(restConfiguration);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public class RestControllerConfiguration {
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
@Bean
|
||||
protected ProfileController profileController() {
|
||||
ProfileController profileController() {
|
||||
return new ProfileController(restConfiguration, resourceMappings, repositories);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,8 @@ import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableHypermediaSupport(type = HypermediaType.HAL)
|
||||
@ImportResource("classpath*:META-INF/spring-data-rest/**/*.xml")
|
||||
@Import({ RestControllerImportSelector.class, SpringDataJacksonConfiguration.class,
|
||||
@Import({ RestControllerImportSelector.class, //
|
||||
SpringDataJacksonConfiguration.class, //
|
||||
EnableSpringDataWebSupport.QuerydslActivator.class })
|
||||
public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebConfiguration
|
||||
implements BeanClassLoaderAware {
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.context.annotation.ImportSelector;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.data.rest.webmvc.RestControllerConfiguration;
|
||||
@@ -25,10 +28,13 @@ import org.springframework.util.ClassUtils;
|
||||
* present.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Drotbohm
|
||||
* @since 3.4
|
||||
*/
|
||||
class RestControllerImportSelector implements ImportSelector {
|
||||
|
||||
private static final String HAL_EXPLORER_CONFIGURATION = "org.springframework.data.rest.webmvc.halexplorer.HalExplorerConfiguration";
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.context.annotation.ImportSelector#selectImports(org.springframework.core.type.AnnotationMetadata)
|
||||
@@ -36,13 +42,13 @@ class RestControllerImportSelector implements ImportSelector {
|
||||
@Override
|
||||
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
|
||||
|
||||
if (ClassUtils.isPresent("org.springframework.data.rest.webmvc.halexplorer.HalExplorerConfiguration",
|
||||
importingClassMetadata.getClass().getClassLoader())) {
|
||||
List<String> configurations = new ArrayList<>();
|
||||
configurations.add(RestControllerConfiguration.class.getName());
|
||||
|
||||
return new String[] { RestControllerConfiguration.class.getName(),
|
||||
"org.springframework.data.rest.webmvc.halexplorer.HalExplorerConfiguration" };
|
||||
if (ClassUtils.isPresent(HAL_EXPLORER_CONFIGURATION, importingClassMetadata.getClass().getClassLoader())) {
|
||||
configurations.add(HAL_EXPLORER_CONFIGURATION);
|
||||
}
|
||||
|
||||
return new String[] { RestControllerConfiguration.class.getName() };
|
||||
return configurations.toArray(new String[configurations.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user