當前位置: 首頁>>代碼示例>>Java>>正文


Java MutablePropertyValues.addPropertyValue方法代碼示例

本文整理匯總了Java中org.springframework.beans.MutablePropertyValues.addPropertyValue方法的典型用法代碼示例。如果您正苦於以下問題:Java MutablePropertyValues.addPropertyValue方法的具體用法?Java MutablePropertyValues.addPropertyValue怎麽用?Java MutablePropertyValues.addPropertyValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.MutablePropertyValues的用法示例。


在下文中一共展示了MutablePropertyValues.addPropertyValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getValues

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
/**
 * Same as getValues(), but property keys are prefixed with the specified prefix.
 *
 * @param propertyKeyPrefix
 *
 */
public PropertyValues getValues(String propertyKeyPrefix) {
    if (propertyKeyPrefix == null) {
        propertyKeyPrefix = "";
    } else {
        propertyKeyPrefix += ".";
    }
    MutablePropertyValues props = new MutablePropertyValues();
    for (String propertyName : getParameterNames()) {
        String strVal = getParameterStringValue(propertyName);
        if (strVal != null) {
            props.addPropertyValue(propertyKeyPrefix + propertyName, strVal);
        }
    }
    return props;
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:22,代碼來源:ConfigurationHelper.java

示例2: getPropertyValuesForNamePrefix

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
private MutablePropertyValues getPropertyValuesForNamePrefix(
		MutablePropertyValues propertyValues) {
	if (!StringUtils.hasText(this.namePrefix) && !this.ignoreNestedProperties) {
		return propertyValues;
	}
	MutablePropertyValues rtn = new MutablePropertyValues();
	for (PropertyValue value : propertyValues.getPropertyValues()) {
		String name = value.getName();
		for (String prefix : new RelaxedNames(stripLastDot(this.namePrefix))) {
			for (String separator : new String[] { ".", "_" }) {
				String candidate = (StringUtils.hasLength(prefix) ? prefix + separator
						: prefix);
				if (name.startsWith(candidate)) {
					name = name.substring(candidate.length());
					if (!(this.ignoreNestedProperties && name.contains("."))) {
						PropertyOrigin propertyOrigin = OriginCapablePropertyValue
								.getOrigin(value);
						rtn.addPropertyValue(new OriginCapablePropertyValue(name,
								value.getValue(), propertyOrigin));
					}
				}
			}
		}
	}
	return rtn;
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:27,代碼來源:RelaxedDataBinder.java

示例3: addBindValues

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
/**
 * Merge URI variables into the property values to use for data binding.
 */
@Override
@SuppressWarnings("unchecked")
protected void addBindValues(MutablePropertyValues mpvs, ServletRequest request) {
	String attr = HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE;
	Map<String, String> uriVars = (Map<String, String>) request.getAttribute(attr);
	if (uriVars != null) {
		for (Entry<String, String> entry : uriVars.entrySet()) {
			if (mpvs.contains(entry.getKey())) {
				logger.warn("Skipping URI variable '" + entry.getKey()
						+ "' since the request contains a bind value with the same name.");
			}
			else {
				mpvs.addPropertyValue(entry.getKey(), entry.getValue());
			}
		}
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:21,代碼來源:ExtendedServletRequestDataBinder.java

示例4: testBeanNameViewResolver

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
@Test
public void testBeanNameViewResolver() throws ServletException {
	StaticWebApplicationContext wac = new StaticWebApplicationContext();
	wac.setServletContext(new MockServletContext());
	MutablePropertyValues pvs1 = new MutablePropertyValues();
	pvs1.addPropertyValue(new PropertyValue("url", "/example1.jsp"));
	wac.registerSingleton("example1", InternalResourceView.class, pvs1);
	MutablePropertyValues pvs2 = new MutablePropertyValues();
	pvs2.addPropertyValue(new PropertyValue("url", "/example2.jsp"));
	wac.registerSingleton("example2", JstlView.class, pvs2);
	BeanNameViewResolver vr = new BeanNameViewResolver();
	vr.setApplicationContext(wac);
	wac.refresh();

	View view = vr.resolveViewName("example1", Locale.getDefault());
	assertEquals("Correct view class", InternalResourceView.class, view.getClass());
	assertEquals("Correct URL", "/example1.jsp", ((InternalResourceView) view).getUrl());

	view = vr.resolveViewName("example2", Locale.getDefault());
	assertEquals("Correct view class", JstlView.class, view.getClass());
	assertEquals("Correct URL", "/example2.jsp", ((JstlView) view).getUrl());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:23,代碼來源:ViewResolverTests.java

示例5: testComplexObject

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
@Test
public void testComplexObject() {
	TestBean tb = new TestBean();
	String newName = "Rod";
	String tbString = "Kerry_34";

	BeanWrapper bw = new BeanWrapperImpl(tb);
	bw.registerCustomEditor(ITestBean.class, new TestBeanEditor());
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.addPropertyValue(new PropertyValue("age", new Integer(55)));
	pvs.addPropertyValue(new PropertyValue("name", newName));
	pvs.addPropertyValue(new PropertyValue("touchy", "valid"));
	pvs.addPropertyValue(new PropertyValue("spouse", tbString));
	bw.setPropertyValues(pvs);
	assertTrue("spouse is non-null", tb.getSpouse() != null);
	assertTrue("spouse name is Kerry and age is 34",
			tb.getSpouse().getName().equals("Kerry") && tb.getSpouse().getAge() == 34);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:19,代碼來源:CustomEditorTests.java

示例6: testAutowireWithUnsatisfiedConstructorDependency

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
@Test
public void testAutowireWithUnsatisfiedConstructorDependency() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.addPropertyValue(new PropertyValue("name", "Rod"));
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.setPropertyValues(pvs);
	lbf.registerBeanDefinition("rod", bd);
	assertEquals(1, lbf.getBeanDefinitionCount());
	try {
		lbf.autowire(UnsatisfiedConstructorDependency.class, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, true);
		fail("Should have unsatisfied constructor dependency on SideEffectBean");
	}
	catch (UnsatisfiedDependencyException ex) {
		// expected
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:DefaultListableBeanFactoryTests.java

示例7: testExtensiveCircularReference

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
@Test
public void testExtensiveCircularReference() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	for (int i = 0; i < 1000; i++) {
		MutablePropertyValues pvs = new MutablePropertyValues();
		pvs.addPropertyValue(new PropertyValue("spouse", new RuntimeBeanReference("bean" + (i < 99 ? i + 1 : 0))));
		RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
		bd.setPropertyValues(pvs);
		lbf.registerBeanDefinition("bean" + i, bd);
	}
	lbf.preInstantiateSingletons();
	for (int i = 0; i < 1000; i++) {
		TestBean bean = (TestBean) lbf.getBean("bean" + i);
		TestBean otherBean = (TestBean) lbf.getBean("bean" + (i < 99 ? i + 1 : 0));
		assertTrue(bean.getSpouse() == otherBean);
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:DefaultListableBeanFactoryTests.java

示例8: registerBeanDefinitions

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    Map<Object, Object> targetDataSources = new HashMap<Object, Object>();
    // 將主數據源添加到更多數據源中
    targetDataSources.put("dataSource", defaultDataSource);
    DynamicDataSourceContextHolder.dataSourceIds.add("dataSource");
    // 添加更多數據源
    targetDataSources.putAll(customDataSources);
    for (String key : customDataSources.keySet()) {
        DynamicDataSourceContextHolder.dataSourceIds.add(key);
    }

    // 創建DynamicDataSource
    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
    beanDefinition.setBeanClass(DynamicDataSource.class);
    beanDefinition.setSynthetic(true);
    MutablePropertyValues mpv = beanDefinition.getPropertyValues();
    mpv.addPropertyValue("defaultTargetDataSource", defaultDataSource);
    mpv.addPropertyValue("targetDataSources", targetDataSources);
    registry.registerBeanDefinition("dataSource", beanDefinition);

    logger.info("Dynamic DataSource Registry");
}
 
開發者ID:tinyoculus,項目名稱:Dynamic-data-sources,代碼行數:24,代碼來源:DynamicDataSourceRegister.java

示例9: initializeForProvider

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
public void initializeForProvider(ConfigurableListableBeanFactory beanFactory, String application, String refBeanName)
		throws BeansException {
	BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;

	// <dubbo:service interface="org.bytesoft.bytejta.supports.wire.RemoteCoordinator" group="org-bytesoft-bytetcc"
	// ref="dispatcherCoordinator" filter="compensable" loadbalance="compensable" cluster="failfast" />
	GenericBeanDefinition beanDef = new GenericBeanDefinition();
	beanDef.setBeanClass(com.alibaba.dubbo.config.spring.ServiceBean.class);

	MutablePropertyValues mpv = beanDef.getPropertyValues();
	mpv.addPropertyValue("interface", RemoteCoordinator.class.getName());
	mpv.addPropertyValue("ref", new RuntimeBeanReference(refBeanName));
	mpv.addPropertyValue("cluster", "failfast");
	mpv.addPropertyValue("loadbalance", "compensable");
	mpv.addPropertyValue("filter", "compensable");
	mpv.addPropertyValue("group", "org-bytesoft-bytetcc");
	mpv.addPropertyValue("retries", "0");
	mpv.addPropertyValue("timeout", "6000");

	String skeletonBeanId = String.format("[email protected]%s", RemoteCoordinator.class.getName());
	registry.registerBeanDefinition(skeletonBeanId, beanDef);
}
 
開發者ID:liuyangming,項目名稱:ByteTCC,代碼行數:23,代碼來源:CompensableConfigPostProcessor.java

示例10: parse

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    FieldDefine fieldDefine = parseFieldDefine(element);
    String id = fieldDefine.getId();
    if (StringUtils.isEmpty(id)) {
        id = fieldDefine.toString()+"-"+System.currentTimeMillis();
    }
    
    RootBeanDefinition beanDefinition = new RootBeanDefinition();
    beanDefinition.setBeanClass(FieldDefine.class);
    beanDefinition.setLazyInit(false);

    BeanDefinitionRegistry registry = parserContext.getRegistry();
    if (registry.containsBeanDefinition(id)) {
        throw new IllegalStateException("Duplicate spring bean id " + id);
    }
    registry.registerBeanDefinition(id, beanDefinition);

    MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
    propertyValues.addPropertyValue("id", id);
    propertyValues.addPropertyValue("name", fieldDefine.getName());
    propertyValues.addPropertyValue("type", fieldDefine.getType());
    propertyValues.addPropertyValue("selector", fieldDefine.getSelector());
    propertyValues.addPropertyValue("processor", fieldDefine.getProcessor());
    propertyValues.addPropertyValue("defines", fieldDefine.getDefines());

    return beanDefinition;
}
 
開發者ID:brucezee,項目名稱:jspider,代碼行數:29,代碼來源:FieldDefineBeanDefinitionParser.java

示例11: registryMangoDao

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
/**
 * 向spring中注入dao代理
 * @param beanFactory
 */
private void registryMangoDao(DefaultListableBeanFactory beanFactory){
    for (Class<?> daoClass : findMangoDaoClasses(config.getScanPackage())) {
        GenericBeanDefinition bf = new GenericBeanDefinition();
        bf.setBeanClassName(daoClass.getName());
        MutablePropertyValues pvs = bf.getPropertyValues();
        pvs.addPropertyValue("daoClass", daoClass);
        bf.setBeanClass(factoryBeanClass);
        bf.setPropertyValues(pvs);
        bf.setLazyInit(false);
        beanFactory.registerBeanDefinition(daoClass.getName(), bf);
    }
}
 
開發者ID:jfaster,項目名稱:mango-spring-boot-starter,代碼行數:17,代碼來源:MangoDaoAutoCreator.java

示例12: postProcessPropertyValues

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean,
		String beanName) throws BeansException {

	MutablePropertyValues newprops = new MutablePropertyValues(pvs);
	for (PropertyDescriptor pd : pds) {
		ServiceReference s = hasServiceProperty(pd);
		if (s != null && !pvs.contains(pd.getName())) {
			try {
				if (logger.isDebugEnabled())
					logger.debug("Processing annotation [" + s + "] for [" + beanName + "." + pd.getName() + "]");
				FactoryBean importer = getServiceImporter(s, pd.getWriteMethod(), beanName);
				// BPPs are created in stageOne(), even though they are run in stageTwo(). This check means that
				// the call to getObject() will not fail with ServiceUnavailable. This is safe to do because
				// ServiceReferenceDependencyBeanFactoryPostProcessor will ensure that mandatory services are
				// satisfied before stageTwo() is run.
				if (bean instanceof BeanPostProcessor) {
					ImporterCallAdapter.setCardinality(importer, Availability.OPTIONAL);
				}
				newprops.addPropertyValue(pd.getName(), importer.getObject());
			}
			catch (Exception e) {
				throw new FatalBeanException("Could not create service reference", e);
			}
		}
	}
	return newprops;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:28,代碼來源:ServiceReferenceInjectionBeanPostProcessor.java

示例13: createBeanReferenceDefinition

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
private AbstractBeanDefinition createBeanReferenceDefinition(String beanName, BeanDefinition actualDef) {
	GenericBeanDefinition def = new GenericBeanDefinition();
	def.setBeanClass(BeanReferenceFactoryBean.class);
	def.setAttribute(GENERATED_REF, Boolean.TRUE);
	def.setOriginatingBeanDefinition(actualDef);
	def.setDependsOn(new String[] { beanName });
	def.setSynthetic(true);
	MutablePropertyValues mpv = new MutablePropertyValues();
	mpv.addPropertyValue(TARGET_BEAN_NAME_PROP, beanName);
	def.setPropertyValues(mpv);
	return def;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:13,代碼來源:AbstractReferenceDefinitionParser.java

示例14: registerBeanDefinitions

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("動態數據源注冊開始>>>");
    }

    // 添加主數據源
    targetDataSources.put("master", DynamicDataSourceHolder.getMasterDS());
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("提供可選取Master數據源:{}", "master");
    }

    // 添加從數據源
    targetDataSources.putAll(DynamicDataSourceHolder.getSlaveDSMap());
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("提供可選取Slave數據源:{}", DynamicDataSourceHolder.getSlaveDSMap().keySet());
    }
    for (String key : DynamicDataSourceHolder.getSlaveDSMap().keySet()) {
        DynamicDataSourceHolder.getSlaveDSKeys().add(key);
    }

    // 創建DynamicDataSource
    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
    beanDefinition.setBeanClass(DynamicDataSource.class);
    beanDefinition.setSynthetic(true);

    MutablePropertyValues mpv = beanDefinition.getPropertyValues();
    mpv.addPropertyValue("defaultTargetDataSource", DynamicDataSourceHolder.getMasterDS());
    mpv.addPropertyValue("targetDataSources", targetDataSources);

    registry.registerBeanDefinition("dataSource", beanDefinition);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("<<<動態數據源注冊結束");
    }
}
 
開發者ID:lupindong,項目名稱:xq_seckill_microservice,代碼行數:36,代碼來源:DynamicDataSourceRegister.java

示例15: registerDynamicDataSourceBeanDefinition

import org.springframework.beans.MutablePropertyValues; //導入方法依賴的package包/類
/**
 * @Title: registerDynamicDataSourceBeanDefinition
 * @Description: 注冊動態數據源
 * @author Kola 6089555
 * @date 2017年4月26日 下午1:26:55
 * @param registry
 */
private void registerDynamicDataSourceBeanDefinition(BeanDefinitionRegistry registry) {
    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
    beanDefinition.setBeanClass(DynamicDataSource.class);
    beanDefinition.setSynthetic(true);
    beanDefinition.setPrimary(true);
    MutablePropertyValues mpv = beanDefinition.getPropertyValues();
    mpv.addPropertyValue("defaultTargetDataSource", defaultDataSource);
    mpv.addPropertyValue("targetDataSources", targetDataSources);
    registry.registerBeanDefinition("dataSource", beanDefinition);
    LOGGER.info("Dynamic DataSource Registry");
}
 
開發者ID:6089555,項目名稱:spring-boot-starter-dynamic-datasource,代碼行數:19,代碼來源:DynamicDataSourceRegister.java


注:本文中的org.springframework.beans.MutablePropertyValues.addPropertyValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。