List of usage examples for org.springframework.beans.factory.support GenericBeanDefinition getConstructorArgumentValues
@Override
public ConstructorArgumentValues getConstructorArgumentValues()
From source file:pl.chilldev.web.spring.config.StylesheetBeanDefinitionParser.java
/** * {@inheritDoc}//from w w w . jav a 2 s .co m * @since 0.0.2 */ @Override public BeanDefinition parse(Element element, ParserContext parserContext) { String href = element.getAttribute(LinkBeanDefinitionParser.ATTRIBUTE_HREF); GenericBeanDefinition stylesheet = new GenericBeanDefinition(); stylesheet.setBeanClass(Stylesheet.class); int i = 0; ConstructorArgumentValues arguments = stylesheet.getConstructorArgumentValues(); arguments.addIndexedArgumentValue(i++, href); arguments.addIndexedArgumentValue(i++, DomUtils.getRealAttributeValue(element, LinkBeanDefinitionParser.ATTRIBUTE_TYPE)); arguments.addIndexedArgumentValue(i++, DomUtils.getRealAttributeValue(element, LinkBeanDefinitionParser.ATTRIBUTE_MEDIA)); this.logger.info("Adding \"{}\" stylesheet.", href); this.stylesheets.add(stylesheet); return null; }
From source file:pl.chilldev.web.spring.config.ScriptBeanDefinitionParser.java
/** * {@inheritDoc}/*from w ww . ja va 2 s . c om*/ * @since 0.0.2 */ @Override public BeanDefinition parse(Element element, ParserContext parserContext) { String src = element.getAttribute(ScriptBeanDefinitionParser.ATTRIBUTE_SRC); GenericBeanDefinition script = new GenericBeanDefinition(); script.setBeanClass(Script.class); int i = 0; ConstructorArgumentValues arguments = script.getConstructorArgumentValues(); arguments.addIndexedArgumentValue(i++, src); arguments.addIndexedArgumentValue(i++, DomUtils.getRealAttributeValue(element, ScriptBeanDefinitionParser.ATTRIBUTE_TYPE)); arguments.addIndexedArgumentValue(i++, DomUtils.getRealAttributeValue(element, ScriptBeanDefinitionParser.ATTRIBUTE_FLOW)); arguments.addIndexedArgumentValue(i++, DomUtils.getRealAttributeValue(element, ScriptBeanDefinitionParser.ATTRIBUTE_CHARSET)); this.logger.info("Adding \"{}\" script.", src); this.scripts.add(script); return null; }
From source file:pl.chilldev.web.spring.config.LinkBeanDefinitionParser.java
/** * {@inheritDoc}/*w w w . j ava 2s. co m*/ * @since 0.0.2 */ @Override public BeanDefinition parse(Element element, ParserContext parserContext) { String href = element.getAttribute(LinkBeanDefinitionParser.ATTRIBUTE_HREF); Set<String> rels = new HashSet<String>(); for (Element child : DomUtils.getChildElementsByTagName(element, LinkBeanDefinitionParser.ELEMENT_REL)) { rels.add(DomUtils.getTextValue(child)); } GenericBeanDefinition link = new GenericBeanDefinition(); link.setBeanClass(Link.class); int i = 0; ConstructorArgumentValues arguments = link.getConstructorArgumentValues(); arguments.addIndexedArgumentValue(i++, href); arguments.addIndexedArgumentValue(i++, rels); arguments.addIndexedArgumentValue(i++, pl.chilldev.web.spring.util.DomUtils.getRealAttributeValue(element, LinkBeanDefinitionParser.ATTRIBUTE_TYPE)); arguments.addIndexedArgumentValue(i++, pl.chilldev.web.spring.util.DomUtils.getRealAttributeValue(element, LinkBeanDefinitionParser.ATTRIBUTE_MEDIA)); this.logger.info("Adding \"{}\" link.", href); this.links.add(link); return null; }
From source file:org.wallride.autoconfigure.WebAdminComponentScanRegistrar.java
private void addWebAdminComponentScanBeanPostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(WebAdminComponentScanBeanPostProcessor.class); beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(toArray(packagesToScan)); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); // We don't need this one to be post processed otherwise it can cause a // cascade of bean instantiation that we would rather avoid. beanDefinition.setSynthetic(true);//from w ww. jav a2 s . com registry.registerBeanDefinition(BEAN_NAME, beanDefinition); }
From source file:org.wallride.autoconfigure.WebGuestComponentScanRegistrar.java
private void addWebGuestComponentScanBeanPostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(WebGuestComponentScanBeanPostProcessor.class); beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(toArray(packagesToScan)); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); // We don't need this one to be post processed otherwise it can cause a // cascade of bean instantiation that we would rather avoid. beanDefinition.setSynthetic(true);//from w w w . ja va2s.com registry.registerBeanDefinition(BEAN_NAME, beanDefinition); }
From source file:com.dianping.zebra.monitor.spring.DataSourceAutoMonitor.java
private BeanDefinition createMonitorableBeanDefinition(String beanName, BeanDefinition dataSourceDefinition) { if (MonitorableDataSource.class.getName().equals(dataSourceDefinition.getBeanClassName()) || GroupDataSource.class.getName().equals(dataSourceDefinition.getBeanClassName())) { return dataSourceDefinition; }/*from w ww. j a v a 2s. com*/ String newBeanName = String.format("%s-z%d", beanName, nameId++); listableBeanFactory.registerBeanDefinition(newBeanName, dataSourceDefinition); GenericBeanDefinition monitorableDataSourceDefinition = new GenericBeanDefinition(); monitorableDataSourceDefinition.setBeanClass(MonitorableDataSource.class); monitorableDataSourceDefinition.getConstructorArgumentValues() .addGenericArgumentValue(new RuntimeBeanReference(newBeanName)); return monitorableDataSourceDefinition; }
From source file:pl.chilldev.web.spring.config.HandlePageModelBeanDefinitionParser.java
/** * {@inheritDoc}//from w w w .j a v a 2s .com * @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: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);/*from ww w . j ava2 s. c o m*/ 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:com.dianping.avatar.cache.spring.CacheBeanDefinitionParser.java
/** * Create cache pointcut definition//from w w w. ja v a 2s . c o m */ private void registerCachePointcutDefinition(Element element, ParserContext parserContext) { GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setBeanClass(AnnotationMatchingPointcut.class); definition.getConstructorArgumentValues().addGenericArgumentValue(new ValueHolder(null, "java.lang.Class")); definition.getConstructorArgumentValues().addGenericArgumentValue( new ValueHolder("com.dianping.avatar.cache.annotation.Cache", "java.lang.Class")); cachePointcutId = element.getAttribute(CACHE_POINTCUT_ID_ATTR); if (!StringUtils.hasText(cachePointcutId)) { cachePointcutId = DEFAULT_CACHE_POINTCUT_ID; } BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, this.cachePointcutId); BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry()); }
From source file:org.iff.infra.util.spring.script.ScriptFactoryPostProcessor.java
/** * Create a ScriptFactory bean definition based on the given script definition, * extracting only the definition data that is relevant for the ScriptFactory * (that is, only bean class and constructor arguments). * @param bd the full script bean definition * @return the extracted ScriptFactory bean definition * @see org.springframework.scripting.ScriptFactory *///from ww w. j a va 2 s .co m protected BeanDefinition createScriptFactoryBeanDefinition(BeanDefinition bd) { GenericBeanDefinition scriptBd = new GenericBeanDefinition(); scriptBd.setBeanClassName(bd.getBeanClassName()); scriptBd.getConstructorArgumentValues().addArgumentValues(bd.getConstructorArgumentValues()); return scriptBd; }