Spring Framework MapPropertySource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework MapPropertySource class.

This code example shows how to use the following methods:
		int availableServerSocket = SocketUtils.findAvailableServerSocket(5678);
 
		final Map<String, Object> sockets = new HashMap<String, Object>();
		sockets.put("availableServerSocket", availableServerSocket);
 
		final MapPropertySource propertySource = new MapPropertySource("sockets", sockets);
 
		context.getEnvironment().getPropertySources().addLast(propertySource);
 
		System.out.println("using port " + context.getEnvironment().getProperty("availableServerSocket"));
 
		context.load("classpath:META-INF/spring/integration/tcpClientServerDemo-context.xml");
		context.registerShutdownHook();
		context.refresh();
 
		return context;
	} 
} 
6
CodeRank
This code example shows how to use the following methods:
 
    @Test
    public void testNullProperties() throws Exception {
        EnvironmentPropertiesFactoryBean factory = new EnvironmentPropertiesFactoryBean();
        StandardEnvironment environment = new StandardEnvironment();
        environment.getPropertySources().addFirst(new MapPropertySource("foo", Collections.singletonMap("foo", null)));
        factory.setEnvironment(environment);
        Properties properties = factory.getObject();
        assertEquals("", properties.get("foo"));
    } 
 
    private Properties getProperties(String input) {
        Properties properties = StringUtils.splitArrayElementsIntoProperties(
                        StringUtils.commaDelimitedListToStringArray(input), "=");
        return properties;
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
     * @param name the name of this property source 
     * @param source the source map 
     */ 
    @SuppressWarnings("unchecked") 
    public NestedMapPropertySource(String name, Map<String, ?> source) {
        super(name, (Map<String, Object>) source);
    } 
 
    @Override 
    public Object getProperty(String name) {
        Object value = this.source.get(name);
        if (value != null) {
            return value;
        } 
        populateCache(); 
        value = this.cache.get(name);
        return value;
    } 
 
    @Override 
5
CodeRank
This code example shows how to use the following methods:
		result.setId(location);
 
		if (! stormConf.isEmpty()) {
			logger.debug("Providing Storm properties to '{}': {}", location, stormConf);
			Map<String,Object> checked = checkedMap(stormConf, String.class, Object.class);
			PropertySource source = new MapPropertySource("storm-configuration", checked);
			result.getEnvironment().getPropertySources().addLast(source);
		} 
 
		result.refresh();
		return result;
	} 
 
} 
4
CodeRank
This code example shows how to use the following methods:
	@Test
	public void serviceUrlWithCompositePropertySource() { 
		CompositePropertySource source = new CompositePropertySource("composite");
		context.getEnvironment().getPropertySources().addFirst(source);
		source.addPropertySource(new MapPropertySource("config", Collections
				.<String, Object> singletonMap("eureka.client.serviceUrl.defaultZone",
						"http://example.com"))); 
		context.register(PropertyPlaceholderAutoConfiguration.class,
				TestConfiguration.class); 
		context.refresh();
		assertEquals("{defaultZone=http://example.com}", 
				context.getBean(EurekaClientConfigBean.class).getServiceUrl().toString());
		assertEquals( 
				"[http://example.com]", 
				context.getBean(EurekaClientConfigBean.class)
						.getEurekaServerServiceUrls("defaultZone").toString()); 
	} 
 
	@Test
	public void serviceUrlWithDefault() { 
3
CodeRank