List of usage examples for org.springframework.beans.factory.support GenericBeanDefinition setFactoryBeanName
@Override public void setFactoryBeanName(@Nullable String factoryBeanName)
From source file:org.xeustechnologies.jcl.spring.JclBeanDefinitionDecorator.java
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder holder, ParserContext parserContext) { String jclRef = node.getAttributes().getNamedItem(JCL_REF).getNodeValue(); GenericBeanDefinition bd = new GenericBeanDefinition(); bd.setFactoryBeanName(JCL_FACTORY); bd.setFactoryMethodName(JCL_FACTORY_METHOD); bd.setConstructorArgumentValues(holder.getBeanDefinition().getConstructorArgumentValues()); bd.setPropertyValues(holder.getBeanDefinition().getPropertyValues()); bd.getConstructorArgumentValues().addIndexedArgumentValue(0, new ConstructorArgumentValues.ValueHolder(parserContext.getRegistry().getBeanDefinition(jclRef))); bd.getConstructorArgumentValues().addIndexedArgumentValue(1, new ConstructorArgumentValues.ValueHolder(holder.getBeanDefinition().getBeanClassName())); BeanDefinitionHolder newHolder = new BeanDefinitionHolder(bd, holder.getBeanName()); createDependencyOnJcl(node, newHolder, parserContext); return newHolder; }
From source file:pl.chilldev.web.spring.config.HandlePageModelBeanDefinitionParser.java
/** * {@inheritDoc}//w w w . j a v a 2 s . c o m * @since 0.0.1 */ @Override public BeanDefinition parse(Element element, ParserContext parserContext) { // page model bean prototype GenericBeanDefinition pageMetaModelBean = new GenericBeanDefinition(); pageMetaModelBean.setBeanClass(PageMetaModel.class); pageMetaModelBean.setScope(WebApplicationContext.SCOPE_REQUEST); pageMetaModelBean.setFactoryBeanName(PageMetaModelFactoryBean.class.getName()); pageMetaModelBean.setFactoryMethodName(HandlePageModelBeanDefinitionParser.METHOD_CREATEPAGEMETAMODEL); parserContext.getRegistry().registerBeanDefinition(PageMetaModel.class.getName(), pageMetaModelBean); parserContext.getRegistry().registerBeanDefinition(PageMetaModelFactoryBean.class.getName(), this.pageMetaModelFactoryBean); // XHTML switch needs to be handled with generator bean if (element.hasAttribute(HandlePageModelBeanDefinitionParser.ATTRIBUTE_XHTML)) { boolean xhtml = element.getAttribute(HandlePageModelBeanDefinitionParser.ATTRIBUTE_XHTML) .equals("true"); GenericBeanDefinition generatorBean = new GenericBeanDefinition(); generatorBean.setBeanClass(Generator.class); this.logger.info("Setting markup generator XHTML mode to {}.", xhtml); ConstructorArgumentValues arguments = generatorBean.getConstructorArgumentValues(); arguments.addGenericArgumentValue(xhtml); parserContext.getRegistry().registerBeanDefinition(Generator.class.getName(), generatorBean); arguments = pageMetaModelBean.getConstructorArgumentValues(); arguments.addGenericArgumentValue(new RuntimeBeanReference(Generator.class.getName())); } // register new resolving strategy PageMetaModelContextUtils.setPageMetaModelResolver(new SpringBeansJspPageMetaModelResolver()); pl.chilldev.web.faces.context.PageMetaModelContextUtils .setPageMetaModelResolver(new SpringBeansFacesPageMetaModelResolver()); return null; }
From source file:com.capgemini.boot.core.factory.internal.SettingBackedBeanFactoryPostProcessor.java
private BeanDefinition createBeanDefinition(Object settings, Object setting, String factoryBeanName, Method factoryMethod) {//from www .j a v a2s . c om final GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setFactoryBeanName(factoryBeanName); definition.setFactoryMethodName(factoryMethod.getName()); //Create method arguments (confusingly called constructor arguments in spring) final ConstructorArgumentValues arguments = new ConstructorArgumentValues(); arguments.addIndexedArgumentValue(0, setting); final int parameterCount = factoryMethod.getParameterTypes().length; if (parameterCount == 2) { arguments.addIndexedArgumentValue(1, settings); } else if (parameterCount > 2) { throw getExceptionFactory().createInvalidArgumentsException(factoryMethod); } //TODO more checking of method arguments to ensure they're correct definition.setConstructorArgumentValues(arguments); return definition; }
From source file:org.iff.infra.util.spring.script.ScriptFactoryPostProcessor.java
/** * Create a bean definition for the scripted object, based on the given script * definition, extracting the definition data that is relevant for the scripted * object (that is, everything but bean class and constructor arguments). * @param bd the full script bean definition * @param scriptFactoryBeanName the name of the internal ScriptFactory bean * @param scriptSource the ScriptSource for the scripted bean * @param interfaces the interfaces that the scripted bean is supposed to implement * @return the extracted ScriptFactory bean definition * @see org.springframework.scripting.ScriptFactory#getScriptedObject *///from w ww . jav a2 s .com protected BeanDefinition createScriptedObjectBeanDefinition(BeanDefinition bd, String scriptFactoryBeanName, ScriptSource scriptSource, Class<?>[] interfaces) { GenericBeanDefinition objectBd = new GenericBeanDefinition(bd); objectBd.setFactoryBeanName(scriptFactoryBeanName); objectBd.setFactoryMethodName("getScriptedObject"); objectBd.getConstructorArgumentValues().clear(); objectBd.getConstructorArgumentValues().addIndexedArgumentValue(0, scriptSource); objectBd.getConstructorArgumentValues().addIndexedArgumentValue(1, interfaces); return objectBd; }
From source file:com.dianping.avatar.cache.spring.CacheBeanDefinitionParser.java
/** * Register jms listener definition//from w w w .j a v a2s .com */ private void registerJmsDefinition(Element element, ParserContext parserContext) { GenericBeanDefinition definition = new GenericBeanDefinition(); MutablePropertyValues propertyValues = definition.getPropertyValues(); definition = new GenericBeanDefinition(); definition.setBeanClass(CacheKeyTypeVersionUpdateListener.class); propertyValues = definition.getPropertyValues(); propertyValues.addPropertyValue("cacheItemConfigManager", new RuntimeBeanReference(cacheItemConfigManager)); BeanDefinitionReaderUtils.registerBeanDefinition( new BeanDefinitionHolder(definition, "keyTypeVersionUpdateListener"), parserContext.getRegistry()); definition = new GenericBeanDefinition(); definition.setBeanClass(SingleCacheRemoveListener.class); propertyValues = definition.getPropertyValues(); propertyValues.addPropertyValue("cacheClientFactory", new RuntimeBeanReference(DEFAULT_CACHE_CLIENT_FACTORY_ID)); BeanDefinitionReaderUtils.registerBeanDefinition( new BeanDefinitionHolder(definition, "singleCacheRemoveListener"), parserContext.getRegistry()); definition = new GenericBeanDefinition(); definition.setBeanClass(CacheConfigurationUpdateListener.class); propertyValues = definition.getPropertyValues(); propertyValues.addPropertyValue("cacheClientFactory", new RuntimeBeanReference(DEFAULT_CACHE_CLIENT_FACTORY_ID)); BeanDefinitionReaderUtils.registerBeanDefinition( new BeanDefinitionHolder(definition, "cacheConfigUpdateListener"), parserContext.getRegistry()); definition = new GenericBeanDefinition(); definition.setBeanClass(CacheKeyConfigUpdateListener.class); propertyValues = definition.getPropertyValues(); propertyValues.addPropertyValue("cacheItemConfigManager", new RuntimeBeanReference(cacheItemConfigManager)); BeanDefinitionReaderUtils.registerBeanDefinition( new BeanDefinitionHolder(definition, "cacheKeyConfigUpdateListener"), parserContext.getRegistry()); definition = new GenericBeanDefinition(); definition.setBeanClass(MessageReceiver.class); propertyValues = definition.getPropertyValues(); propertyValues.addPropertyValue("mappingList[0]", new RuntimeBeanReference("keyTypeVersionUpdateListener")); propertyValues.addPropertyValue("mappingList[1]", new RuntimeBeanReference("singleCacheRemoveListener")); propertyValues.addPropertyValue("mappingList[2]", new RuntimeBeanReference("cacheConfigUpdateListener")); propertyValues.addPropertyValue("mappingList[3]", new RuntimeBeanReference("cacheKeyConfigUpdateListener")); BeanDefinitionReaderUtils.registerBeanDefinition( new BeanDefinitionHolder(definition, "dispatchMessageListener"), parserContext.getRegistry()); definition = new GenericBeanDefinition(); definition.setBeanClass(MongoMQService.class); ConstructorArgumentValues constructorArgumentValues = definition.getConstructorArgumentValues(); constructorArgumentValues.addGenericArgumentValue("${avatar-cache.swallow.url}", "java.lang.String"); BeanDefinitionReaderUtils.registerBeanDefinition(new BeanDefinitionHolder(definition, "MQService"), parserContext.getRegistry()); definition = new GenericBeanDefinition(); definition.setBeanClass(Destination.class); definition.setFactoryMethodName(DEFAULT_CACHE_JMS_MODE); constructorArgumentValues = definition.getConstructorArgumentValues(); constructorArgumentValues.addGenericArgumentValue(DEFAULT_CACHE_JMS_TOPIC_NAME, "java.lang.String"); BeanDefinitionReaderUtils.registerBeanDefinition(new BeanDefinitionHolder(definition, "CacheDestination"), parserContext.getRegistry()); definition = new GenericBeanDefinition(); // definition.setBeanClass(MongoMessageConsumer.class); definition.setFactoryBeanName("MQService"); definition.setFactoryMethodName("createConsumer"); constructorArgumentValues = definition.getConstructorArgumentValues(); //TODO where to get the DEFAULT_CACHE_JMS_TOPIC_NAME constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference("CacheDestination")); propertyValues = definition.getPropertyValues(); propertyValues.addPropertyValue("messageListener", new RuntimeBeanReference("dispatchMessageListener")); BeanDefinitionReaderUtils.registerBeanDefinition(new BeanDefinitionHolder(definition, "cacheConsumer"), parserContext.getRegistry()); }
From source file:org.springframework.scripting.support.ScriptFactoryPostProcessor.java
/** * Create a bean definition for the scripted object, based on the given script * definition, extracting the definition data that is relevant for the scripted * object (that is, everything but bean class and constructor arguments). * @param bd the full script bean definition * @param scriptFactoryBeanName the name of the internal ScriptFactory bean * @param scriptSource the ScriptSource for the scripted bean * @param interfaces the interfaces that the scripted bean is supposed to implement * @return the extracted ScriptFactory bean definition * @see org.springframework.scripting.ScriptFactory#getScriptedObject *//* w w w . j a va 2 s .co m*/ protected BeanDefinition createScriptedObjectBeanDefinition(BeanDefinition bd, String scriptFactoryBeanName, ScriptSource scriptSource, @Nullable Class<?>[] interfaces) { GenericBeanDefinition objectBd = new GenericBeanDefinition(bd); objectBd.setFactoryBeanName(scriptFactoryBeanName); objectBd.setFactoryMethodName("getScriptedObject"); objectBd.getConstructorArgumentValues().clear(); objectBd.getConstructorArgumentValues().addIndexedArgumentValue(0, scriptSource); objectBd.getConstructorArgumentValues().addIndexedArgumentValue(1, interfaces); return objectBd; }