use of cn.taketoday.beans.factory.support.BeanNameGenerator in project today-infrastructure by TAKETODAY.
the class ApplicationTests method customBeanNameGeneratorWithNonWebApplication.
@Test
void customBeanNameGeneratorWithNonWebApplication() {
TestApplication application = new TestApplication(ExampleWebConfig.class);
application.setApplicationType(ApplicationType.NONE_WEB);
BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
application.setBeanNameGenerator(beanNameGenerator);
this.context = application.run();
then(application.getLoader()).should().setBeanNameGenerator(beanNameGenerator);
Object actualGenerator = this.context.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
assertThat(actualGenerator).isSameAs(beanNameGenerator);
}
use of cn.taketoday.beans.factory.support.BeanNameGenerator in project today-infrastructure by TAKETODAY.
the class ApplicationTests method customBeanNameGenerator.
@Test
void customBeanNameGenerator() {
TestApplication application = new TestApplication(ExampleWebConfig.class);
BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
application.setBeanNameGenerator(beanNameGenerator);
this.context = application.run();
then(application.getLoader()).should().setBeanNameGenerator(beanNameGenerator);
Object actualGenerator = this.context.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
assertThat(actualGenerator).isSameAs(beanNameGenerator);
}
use of cn.taketoday.beans.factory.support.BeanNameGenerator in project today-infrastructure by TAKETODAY.
the class MapperScannerBeanDefinitionParser method parseInternal.
/**
* {@inheritDoc}
*/
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class);
builder.addPropertyValue("processPropertyPlaceHolders", true);
try {
String annotationClassName = element.getAttribute(ATTRIBUTE_ANNOTATION);
if (StringUtils.hasText(annotationClassName)) {
Class<? extends Annotation> annotationClass = ClassUtils.forName(annotationClassName);
builder.addPropertyValue("annotationClass", annotationClass);
}
String markerInterfaceClassName = element.getAttribute(ATTRIBUTE_MARKER_INTERFACE);
if (StringUtils.hasText(markerInterfaceClassName)) {
Class<?> markerInterface = ClassUtils.forName(markerInterfaceClassName);
builder.addPropertyValue("markerInterface", markerInterface);
}
String nameGeneratorClassName = element.getAttribute(ATTRIBUTE_NAME_GENERATOR);
if (StringUtils.hasText(nameGeneratorClassName)) {
Class<BeanNameGenerator> nameGeneratorClass = ClassUtils.forName(nameGeneratorClassName);
BeanNameGenerator nameGenerator = BeanUtils.newInstance(nameGeneratorClass);
builder.addPropertyValue("nameGenerator", nameGenerator);
}
String mapperFactoryBeanClassName = element.getAttribute(ATTRIBUTE_MAPPER_FACTORY_BEAN_CLASS);
if (StringUtils.hasText(mapperFactoryBeanClassName)) {
Class<? extends MapperFactoryBean> mapperFactoryBeanClass = ClassUtils.forName(mapperFactoryBeanClassName);
builder.addPropertyValue("mapperFactoryBeanClass", mapperFactoryBeanClass);
}
} catch (Exception ex) {
XmlReaderContext readerContext = parserContext.getReaderContext();
readerContext.error(ex.getMessage(), readerContext.extractSource(element), ex.getCause());
}
builder.addPropertyValue("basePackage", element.getAttribute(ATTRIBUTE_BASE_PACKAGE));
builder.addPropertyValue("defaultScope", element.getAttribute(ATTRIBUTE_DEFAULT_SCOPE));
builder.addPropertyValue("sqlSessionFactoryBeanName", element.getAttribute(ATTRIBUTE_FACTORY_REF));
builder.addPropertyValue("lazyInitialization", element.getAttribute(ATTRIBUTE_LAZY_INITIALIZATION));
builder.addPropertyValue("sqlSessionTemplateBeanName", element.getAttribute(ATTRIBUTE_TEMPLATE_REF));
builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
return builder.getBeanDefinition();
}
use of cn.taketoday.beans.factory.support.BeanNameGenerator in project today-framework by TAKETODAY.
the class ApplicationTests method customBeanNameGenerator.
@Test
void customBeanNameGenerator() {
TestApplication application = new TestApplication(ExampleWebConfig.class);
BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
application.setBeanNameGenerator(beanNameGenerator);
this.context = application.run();
then(application.getLoader()).should().setBeanNameGenerator(beanNameGenerator);
Object actualGenerator = this.context.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
assertThat(actualGenerator).isSameAs(beanNameGenerator);
}
use of cn.taketoday.beans.factory.support.BeanNameGenerator in project today-framework by TAKETODAY.
the class ApplicationTests method customBeanNameGeneratorWithNonWebApplication.
@Test
void customBeanNameGeneratorWithNonWebApplication() {
TestApplication application = new TestApplication(ExampleWebConfig.class);
application.setApplicationType(ApplicationType.NONE_WEB);
BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
application.setBeanNameGenerator(beanNameGenerator);
this.context = application.run();
then(application.getLoader()).should().setBeanNameGenerator(beanNameGenerator);
Object actualGenerator = this.context.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
assertThat(actualGenerator).isSameAs(beanNameGenerator);
}
Aggregations