List of usage examples for org.springframework.beans MutablePropertyValues add
public MutablePropertyValues add(String propertyName, @Nullable Object propertyValue)
From source file:co.paralleluniverse.common.spring.SpringContainerHelper.java
private static BeanDefinition getMBeanExporterBeanDefinition(String defaultDomain) { final AnnotationJmxAttributeSource annotationSource = new AnnotationJmxAttributeSource(); final GenericBeanDefinition bean = new GenericBeanDefinition(); bean.setBeanClass(MBeanExporter.class); MutablePropertyValues properties = new MutablePropertyValues(); properties.add("server", ManagementFactory.getPlatformMBeanServer()); properties.add("autodetectMode", MBeanExporter.AUTODETECT_ASSEMBLER); properties.add("assembler", new MetadataMBeanInfoAssembler(annotationSource)); properties.add("namingStrategy", new MBeanNamingStrategy(annotationSource).setDefaultDomain(defaultDomain)); bean.setPropertyValues(properties);// w ww .j a va 2 s .c om return bean; }
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); });/* ww w . j a v a 2 s. c om*/ }
From source file:org.jasig.springframework.web.portlet.SimplePortletApplicationContext.java
public void refresh() throws BeansException { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("commandClass", "org.jasig.springframework.beans.TestBean"); pvs.add("formView", "form"); registerSingleton("/form.do", SimpleFormController.class, pvs); registerSingleton("/locale.do", LocaleChecker.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); registerSingleton("handlerMapping", BeanNameUrlHandlerMapping.class); registerSingleton("viewResolver", InternalResourceViewResolver.class); pvs = new MutablePropertyValues(); pvs.add("location", "org/springframework/web/context/WEB-INF/sessionContext.xml"); registerSingleton("viewResolver2", XmlViewResolver.class, pvs); super.refresh(); }
From source file:org.hdiv.web.servlet.SimpleWebApplicationContext.java
public void refresh() throws BeansException { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("commandClass", "org.hdiv.beans.TestBean"); pvs.add("formView", "form"); registerSingleton("/form.do", SimpleFormController.class, pvs); registerSingleton("/locale.do", LocaleChecker.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); registerSingleton("handlerMapping", BeanNameUrlHandlerMapping.class); registerSingleton("viewResolver", InternalResourceViewResolver.class); pvs = new MutablePropertyValues(); pvs.add("location", "org/hdiv/web/context/WEB-INF/sessionContext.xml"); registerSingleton("viewResolver2", XmlViewResolver.class, pvs); super.refresh(); }
From source file:com.haulmont.cuba.core.sys.remoting.RemoteServicesBeanCreator.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { log.info("Configuring remote services"); BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; ApplicationContext coreContext = context.getParent(); Map<String, Object> services = coreContext.getBeansWithAnnotation(Service.class); for (Map.Entry<String, Object> entry : services.entrySet()) { String serviceName = entry.getKey(); Object service = entry.getValue(); List<Class> serviceInterfaces = new ArrayList<>(); List<Class> interfaces = ClassUtils.getAllInterfaces(service.getClass()); for (Class intf : interfaces) { if (intf.getName().endsWith("Service")) serviceInterfaces.add(intf); }// ww w . j a v a2 s .c o m String intfName = null; if (serviceInterfaces.size() == 0) { log.error("Bean " + serviceName + " has @Service annotation but no interfaces named '*Service'. Ignoring it."); } else if (serviceInterfaces.size() > 1) { intfName = findLowestSubclassName(serviceInterfaces); if (intfName == null) log.error("Bean " + serviceName + " has @Service annotation and more than one interface named '*Service', " + "but these interfaces are not from the same hierarchy. Ignoring it."); } else { intfName = serviceInterfaces.get(0).getName(); } if (intfName != null) { BeanDefinition definition = new RootBeanDefinition(HttpServiceExporter.class); MutablePropertyValues propertyValues = definition.getPropertyValues(); propertyValues.add("service", service); propertyValues.add("serviceInterface", intfName); registry.registerBeanDefinition("/" + serviceName, definition); log.debug("Bean " + serviceName + " configured for export via HTTP"); } } }
From source file:com.inspiresoftware.lib.dto.geda.config.XmlDrivenGeDABeanDefinitionParser.java
public BeanDefinitionHolder decorate(final Node node, final BeanDefinitionHolder definition, final ParserContext parserContext) { final BeanDefinition beanDefinition = definition.getBeanDefinition(); final String dtoSupportProperty = node.getAttributes().getNamedItem(XSD_ATTR__PROPERTY).getNodeValue(); final MutablePropertyValues properties = beanDefinition.getPropertyValues(); properties.add(dtoSupportProperty, new RuntimeBeanReference(dtoSupportBeanName)); return definition; }
From source file:com.trigonic.utils.spring.cmdline.AbstractOptionHandler.java
private boolean addPropertyValue(MutablePropertyValues propertyValues, OptionSet optionSet, String optionName) { boolean result = false; if (optionSet.has(optionName)) { propertyValues.add(propertyName, optionSet.valueOf(optionName)); result = true;/*w ww.j av a 2s. com*/ } return result; }
From source file:com.himanshu.spring.context.loader.sameconfigallcontext.bean.visitor.BeanVisitor.java
private void visitProperties(MutablePropertyValues propertyValues) { for (PropertyValue propertyValue : propertyValues.getPropertyValueList()) { Object resolvedValue = resolveValue(propertyValue.getValue()); propertyValues.add(propertyValue.getName(), resolvedValue); }/*from w ww . j a v a 2 s .c o m*/ }
From source file:org.brekka.stillingar.spring.pc.PropertyDefChangeListener.java
/** * Update the property with the new value *///w w w. ja v a 2 s. c o m @Override public void onChange(String newValue) { ConfigurableListableBeanFactory beanFactory = beanFactoryRef.get(); if (beanFactory == null) { return; } BeanDefinition beanDef = beanFactory.getMergedBeanDefinition(beanName); MutablePropertyValues mutablePropertyValues = beanDef.getPropertyValues(); PropertyValue propertyValue = mutablePropertyValues.getPropertyValue(propertyName); if (!ObjectUtils.nullSafeEquals(newValue, propertyValue.getValue())) { mutablePropertyValues.add(propertyValue.getName(), newValue); } }
From source file:com.trigonic.utils.spring.cmdline.AbstractOptionHandler.java
public boolean addPropertyValue(MutablePropertyValues propertyValues, OptionSet optionSet) { boolean result; if (hasValue()) { result = addPropertyValue(propertyValues, optionSet, option.shortName()) || addPropertyValue(propertyValues, optionSet, option.longName()); } else {/* w ww. ja v a 2 s. co m*/ propertyValues.add(propertyName, optionSet.has(option.shortName()) || optionSet.has(option.longName())); result = true; } return result; }