Java Code Examples for org.springframework.beans.factory.support.BeanDefinitionBuilder#setFactoryMethod()
The following examples show how to use
org.springframework.beans.factory.support.BeanDefinitionBuilder#setFactoryMethod() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationDrivenBeanDefinitionParser.java From spring-analysis-note with MIT License | 6 votes |
private void registerAsyncExecutionAspect(Element element, ParserContext parserContext) { if (!parserContext.getRegistry().containsBeanDefinition(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ASYNC_EXECUTION_ASPECT_CLASS_NAME); builder.setFactoryMethod("aspectOf"); String executor = element.getAttribute("executor"); if (StringUtils.hasText(executor)) { builder.addPropertyReference("executor", executor); } String exceptionHandler = element.getAttribute("exception-handler"); if (StringUtils.hasText(exceptionHandler)) { builder.addPropertyReference("exceptionHandler", exceptionHandler); } parserContext.registerBeanComponent(new BeanComponentDefinition(builder.getBeanDefinition(), TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)); } }
Example 2
Source File: AnnotationDrivenBeanDefinitionParser.java From java-technology-stack with MIT License | 6 votes |
private void registerAsyncExecutionAspect(Element element, ParserContext parserContext) { if (!parserContext.getRegistry().containsBeanDefinition(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ASYNC_EXECUTION_ASPECT_CLASS_NAME); builder.setFactoryMethod("aspectOf"); String executor = element.getAttribute("executor"); if (StringUtils.hasText(executor)) { builder.addPropertyReference("executor", executor); } String exceptionHandler = element.getAttribute("exception-handler"); if (StringUtils.hasText(exceptionHandler)) { builder.addPropertyReference("exceptionHandler", exceptionHandler); } parserContext.registerBeanComponent(new BeanComponentDefinition(builder.getBeanDefinition(), TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)); } }
Example 3
Source File: AnnotationDrivenBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 6 votes |
private void registerAsyncExecutionAspect(Element element, ParserContext parserContext) { if (!parserContext.getRegistry().containsBeanDefinition(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ASYNC_EXECUTION_ASPECT_CLASS_NAME); builder.setFactoryMethod("aspectOf"); String executor = element.getAttribute("executor"); if (StringUtils.hasText(executor)) { builder.addPropertyReference("executor", executor); } String exceptionHandler = element.getAttribute("exception-handler"); if (StringUtils.hasText(exceptionHandler)) { builder.addPropertyReference("exceptionHandler", exceptionHandler); } parserContext.registerBeanComponent(new BeanComponentDefinition(builder.getBeanDefinition(), TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)); } }
Example 4
Source File: AnnotationDrivenBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void registerAsyncExecutionAspect(Element element, ParserContext parserContext) { if (!parserContext.getRegistry().containsBeanDefinition(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ASYNC_EXECUTION_ASPECT_CLASS_NAME); builder.setFactoryMethod("aspectOf"); String executor = element.getAttribute("executor"); if (StringUtils.hasText(executor)) { builder.addPropertyReference("executor", executor); } String exceptionHandler = element.getAttribute("exception-handler"); if (StringUtils.hasText(exceptionHandler)) { builder.addPropertyReference("exceptionHandler", exceptionHandler); } parserContext.registerBeanComponent(new BeanComponentDefinition(builder.getBeanDefinition(), TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)); } }
Example 5
Source File: PropertySourcesPlaceholderConfigurerConfigBean.java From config-toolkit with Apache License 2.0 | 6 votes |
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { builder.addPropertyValue("order", Integer.parseInt(element.getAttribute("order"))); builder.addPropertyValue("ignoreUnresolvablePlaceholders", Boolean.valueOf(element.getAttribute("ignore-unresolvable-placeholders"))); List<Object> list = parserContext.getDelegate().parseListElement(element, builder.getRawBeanDefinition()); // Register property sources BeanDefinitionBuilder configGroupSourceFactoryBuilder = BeanDefinitionBuilder.genericBeanDefinition(ConfigGroupSourceFactory.class); configGroupSourceFactoryBuilder.setFactoryMethod("create"); configGroupSourceFactoryBuilder.addConstructorArgValue(list); String generatedSourceFactoryName = parserContext.getReaderContext().generateBeanName(configGroupSourceFactoryBuilder.getRawBeanDefinition()); parserContext .registerBeanComponent(new BeanComponentDefinition(configGroupSourceFactoryBuilder.getBeanDefinition(), generatedSourceFactoryName)); builder.addPropertyValue("propertySources", new RuntimeBeanReference(generatedSourceFactoryName)); }
Example 6
Source File: MangoDaoAutoCreator.java From mango-spring-boot-starter with Apache License 2.0 | 5 votes |
/** * 向spring中注入mango实例 * @param beanFactory */ private void registryMangoInstance(DefaultListableBeanFactory beanFactory){ BeanDefinitionBuilder mangoBuilder = BeanDefinitionBuilder.rootBeanDefinition(Mango.class); mangoBuilder.setFactoryMethod("newInstance"); mangoBuilder.addPropertyValue("checkColumn",config.isCheckColumn()); mangoBuilder.addPropertyValue("compatibleWithEmptyList",config.isCompatibleWithEmptyList()); mangoBuilder.addPropertyValue("lazyInit",config.isLazyInit()); mangoBuilder.addPropertyValue("useActualParamName",config.isUseActualParamName()); mangoBuilder.addPropertyValue("useTransactionForBatchUpdate",config.isUseTransactionForBatchUpdate()); configCacheHandler(mangoBuilder); beanFactory.registerBeanDefinition(Mango.class.getName(),mangoBuilder.getBeanDefinition()); }
Example 7
Source File: RedissonDefinitionParser.java From redisson with Apache License 2.0 | 5 votes |
@Override public BeanDefinition parse(Element element, ParserContext parserContext) { //Sort out the Config Class BeanDefinitionBuilder configBuilder = helper.createBeanDefinitionBuilder(element, parserContext, Config.class); String configId = helper.getId(null, configBuilder, parserContext); helper.parseAttributes(element, parserContext, configBuilder); helper.registerBeanDefinition(configBuilder, configId, null, parserContext); //Do the main Redisson bean BeanDefinitionBuilder builder = helper.createBeanDefinitionBuilder(element, parserContext, Redisson.class); builder.setFactoryMethod("create"); builder.setDestroyMethodName("shutdown"); builder.addConstructorArgReference(configId); parserContext.getDelegate().parseQualifierElements(element, builder.getRawBeanDefinition()); String id = helper.getId(element, builder, parserContext); helper.parseAttributes(element, parserContext, configBuilder); //Sort out all the nested elements parseChildElements(element, configId, id, builder, parserContext); helper.registerBeanDefinition(builder, id, helper.parseAliase(element), parserContext); return builder.getBeanDefinition(); }