DATACMNS-660 - Web configuration support now picks up configuration annotated with @SpringDataWebConfigurationMixing.

Introduced @SpringDataWebConfigurationMixing that can be used on configuration classes that are supposed to contribute components to the Application context when @EnableSpringDataWebSupport is used.

SpringDataWebConfigurationImportSelector scans the org.springframework.data package for classes annotated with that annotation and adds them to the classes to be considered config classes.
This commit is contained in:
Oliver Gierke
2015-03-17 16:23:18 +01:00
parent d7adfbd859
commit 537fc430a9
5 changed files with 123 additions and 5 deletions

View File

@@ -172,6 +172,18 @@ public class EnableSpringDataWebSupportIntegrationTests {
andExpect(status().isOk());
}
/**
* @see DATACMNS-660
*/
@Test
public void picksUpWebConfigurationMixins() {
ApplicationContext context = WebTestUtils.createApplicationContext(SampleConfig.class);
List<String> names = Arrays.asList(context.getBeanDefinitionNames());
assertThat(names, hasItem("sampleBean"));
}
@SuppressWarnings("unchecked")
private static void assertResolversRegistered(ApplicationContext context, Class<?>... resolverTypes) {

View File

@@ -0,0 +1,30 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.web.config;
import org.springframework.context.annotation.Bean;
/**
* @author Oliver Gierke
*/
@SpringDataWebConfigurationMixin
public class SampleMixin {
@Bean
String sampleBean() {
return "sampleBean";
}
}