List of usage examples for org.springframework.beans MutablePropertyValues MutablePropertyValues
public MutablePropertyValues()
From source file:com.trigonic.utils.spring.cmdline.CommandLineBeanDefinition.java
private void populate(CommandLineMetaData metaData, OptionSet optionSet) { MutablePropertyValues propertyValues = new MutablePropertyValues(); for (OptionHandler handler : metaData.getOptionHandlers()) { handler.addPropertyValue(propertyValues, optionSet); }/*from ww w . jav a 2 s .c o m*/ for (OperandHandler handler : metaData.getOperandHandlers()) { if (!handler.addPropertyValue(propertyValues, optionSet) && handler.isRequired()) { throw new OperandException(String.format("Operand [%s] is required", handler.getName())); } } setPropertyValues(propertyValues); }
From source file:com.zuoxiaolong.niubi.job.spring.config.JobDrivenBeanDefinitionParser.java
@Override public BeanDefinition parse(Element element, ParserContext parserContext) { AbstractBeanDefinition beanDefinition = new GenericBeanDefinition(); MutablePropertyValues propertyValues = new MutablePropertyValues(); beanDefinition.setBeanClass(SpringContextJobDriver.class); propertyValues.addPropertyValue("packagesToScan", element.getAttribute("packagesToScan")); beanDefinition.setPropertyValues(propertyValues); beanDefinition.setInitMethodName("init"); BeanDefinitionReaderUtils.registerWithGeneratedName(beanDefinition, parserContext.getRegistry()); return beanDefinition; }
From source file:org.springmodules.cache.config.AnnotationsParserTests.java
public void testConfigureCachingInterceptor() { MutablePropertyValues propertyValues = new MutablePropertyValues(); parser.configureCachingInterceptor(propertyValues, registry); Class targetClass = AnnotationCachingAttributeSource.class; String beanName = targetClass.getName(); AbstractBeanDefinition definition = (AbstractBeanDefinition) registry.getBeanDefinition(beanName); ConfigAssert.assertBeanDefinitionWrapsClass(definition, targetClass); PropertyValue expected = new PropertyValue("cachingAttributeSource", new RuntimeBeanReference(beanName)); ConfigAssert.assertPropertyIsPresent(propertyValues, expected); }
From source file:com.bstek.dorado.spring.ClassTypeListShortCutDecorator.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) { AbstractBeanDefinition beanDef = (AbstractBeanDefinition) definition.getBeanDefinition(); MutablePropertyValues propertyValues = (beanDef.getPropertyValues() == null) ? new MutablePropertyValues() : beanDef.getPropertyValues(); ManagedList list = null;/*from w w w. j a va2 s.c o m*/ boolean firstPropertyValue = propertyValues.getPropertyValue(IMPL_TYPES) == null; if (!firstPropertyValue) { list = (ManagedList) (propertyValues.getPropertyValue(IMPL_TYPES).getValue()); } else { list = new ManagedList(); list.setSource(node); list.setMergeEnabled(true); propertyValues.addPropertyValue(IMPL_TYPES, list); beanDef.setPropertyValues(propertyValues); } Element el = (Element) node; String className = el.getAttribute("name"); try { list.add(Class.forName(className)); } catch (ClassNotFoundException e) { logger.warn(e, e); } return definition; }
From source file:com.sshdemo.common.schedule.generate.quartz.EwcmsQuartzJobBean.java
@SuppressWarnings("rawtypes") @Override/* w w w . j a v a 2s .c o m*/ public void execute(JobExecutionContext context) throws JobExecutionException { try { Scheduler scheduler = (Scheduler) ReflectionUtils.invokeMethod(getSchedulerMethod, context); Map mergedJobDataMap = (Map) ReflectionUtils.invokeMethod(getMergedJobDataMapMethod, context); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); MutablePropertyValues pvs = new MutablePropertyValues(); pvs.addPropertyValues(scheduler.getContext()); pvs.addPropertyValues(mergedJobDataMap); bw.setPropertyValues(pvs, true); } catch (SchedulerException ex) { throw new JobExecutionException(ex); } executeInternal(context); }
From source file:org.springmodules.cache.config.CommonsAttributesParserTests.java
/** * Verifies that the method// w w w .j a v a 2 s.c o m * <code>{@link CommonsAttributesParser}</code> adds a new property * with name "attributes" to the given set of property values. The * "attributes" properties should have a * <code>{@link RuntimeBeanReference}</code> to the bean declaration * describing an instance of <code>{@link CommonsAttributes}</code>. */ public void testConfigureCachingInterceptor() { MutablePropertyValues propertyValues = new MutablePropertyValues(); parser.configureCachingInterceptor(propertyValues, registry); assertAttributesPropertyIsPresent(propertyValues); }
From source file:org.browsexml.timesheetjob.web.SimpleWebApplicationContext.java
public void refresh() throws BeansException { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.addPropertyValue(new PropertyValue("commandClass", "org.springframework.beans.TestBean")); pvs.addPropertyValue(new PropertyValue("formView", "form")); //registerSingleton("/form.do", HoursWorkedFormController.class, pvs); //registerSingleton("/locale.do", LocaleChecker.class); //registerPrototype("/throwaway.do", TestThrowawayController.class); addMessage("test", Locale.ENGLISH, "test message"); addMessage("test", Locale.CANADA, "Canadian & test message"); addMessage("testArgs", Locale.ENGLISH, "test {0} message {1}"); addMessage("testArgsFormat", Locale.ENGLISH, "test {0} message {1,number,#.##} X"); registerSingleton(UiApplicationContextUtils.THEME_SOURCE_BEAN_NAME, DummyThemeSource.class); super.refresh(); }
From source file:com.github.xdcrafts.flower.spring.impl.DefaultActionDefinitionFactory.java
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { actions.entrySet().forEach(entry -> { final String name = entry.getKey(); final String qualifiedName = Named.qualifiedName(this.namespace, name); final Object method = entry.getValue(); final MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("method", method); final GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(DefaultActionFactory.class); beanDefinition.setPropertyValues(propertyValues); registry.registerBeanDefinition(qualifiedName, beanDefinition); });//from w w w .j a va2 s. c o m }
From source file:com.tacitknowledge.flip.spring.config.InterceptHandlerParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { XmlBeanFactory factory = new XmlBeanFactory( new ClassPathResource("com/tacitknowledge/flip/spring/context.xml")); BeanDefinitionBuilder beanBuilder = BeanDefinitionBuilder.rootBeanDefinition(FlipSpringAspect.class); String defaultUrlValue = element.getAttribute("default-url"); MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.addPropertyValue("defaultValue", defaultUrlValue); propertyValues.addPropertyValue(FlipSpringAspect.FEATURE_SERVICE_BEAN_NAME, new RuntimeBeanReference(FlipSpringAspect.FEATURE_SERVICE_BEAN_NAME)); beanBuilder.getRawBeanDefinition().setPropertyValues(propertyValues); for (String name : factory.getBeanDefinitionNames()) { parserContext.getRegistry().registerBeanDefinition(name, factory.getBeanDefinition(name)); }//from w w w.j av a 2 s . co m parserContext.getRegistry().registerBeanDefinition(FlipSpringAspect.ASPECT_BEAN_NAME, beanBuilder.getBeanDefinition()); return null; }
From source file:com.bstek.dorado.spring.MapEntryShortCutDecorator.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) { AbstractBeanDefinition beanDef = (AbstractBeanDefinition) definition.getBeanDefinition(); MutablePropertyValues propertyValues = (beanDef.getPropertyValues() == null) ? new MutablePropertyValues() : beanDef.getPropertyValues(); ManagedMap map = null;/* ww w. j a v a2 s . com*/ boolean firstPropertyValue = propertyValues.getPropertyValue(property) == null; if (!firstPropertyValue) { map = (ManagedMap) (propertyValues.getPropertyValue(property).getValue()); } else { map = new ManagedMap(); map.setSource(node); map.setMergeEnabled(true); propertyValues.addPropertyValue(property, map); beanDef.setPropertyValues(propertyValues); } Element el = (Element) node; String key = el.getAttribute("key"); String value = el.getAttribute("value"); String valueRef = el.getAttribute("value-ref"); Object entryValue = null; if (StringUtils.isNotEmpty(value)) { entryValue = value; } else if (StringUtils.isNotEmpty(valueRef)) { RuntimeBeanReference ref = new RuntimeBeanReference(valueRef); ref.setSource(parserContext.getReaderContext().extractSource(el)); entryValue = ref; } else { Element beanEl = DomUtils.getChildElementByTagName(el, "bean"); if (beanEl != null) { entryValue = parserContext.getDelegate().parseBeanDefinitionElement(beanEl); } } if (supportsMultiKey && StringUtils.isNotEmpty(key)) { for (String k : StringUtils.split(key, KEY_DELIM)) { map.put(k, entryValue); } } else { map.put(key, entryValue); } return definition; }