Package org.springframework.core.env

Examples of org.springframework.core.env.MapPropertySource


      if(log.isDebugEnabled()) {
        log.debug("Adding afterCommandLineArgs property source after "
            + CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME);
      }
      propertySources.addAfter(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME,
          new MapPropertySource("afterCommandLineArgs", propertySourceMap));
    } else {
      if(log.isDebugEnabled()) {
        log.debug("Adding afterCommandLineArgs property source as first");
      }
      propertySources.addFirst(new MapPropertySource("afterCommandLineArgs", propertySourceMap));
    }
  }
View Full Code Here


    if (LOGGER.isInfoEnabled()) {
      LOGGER.info("Available Server Socket: " + availableServerSocket);
    }

    final MapPropertySource propertySource = new MapPropertySource("sockets", sockets);

    context.getEnvironment().getPropertySources().addLast(propertySource);
    super.loadBeanDefinitions(context, mergedConfig);
  }
View Full Code Here

    if (LOGGER.isInfoEnabled()) {
      LOGGER.info("Available server socket: " + availableServerSocket);
    }

    final MapPropertySource propertySource = new MapPropertySource("sockets", sockets);

    context.getEnvironment().getPropertySources().addLast(propertySource);
    super.loadBeanDefinitions(context, mergedConfig);
  }
View Full Code Here

    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"));
View Full Code Here

    }

    public void testOverridingDefaultTemplateViaConfig() throws Exception {
            ConfigObject config = new ConfigSlurper().parse("grails.sitemesh.default.layout='otherApplication'");
            MutablePropertySources propertySources = new MutablePropertySources();
            propertySources.addLast(new MapPropertySource("grails", config));

            GrailsWebRequest webRequest = buildMockRequest(new PropertySourcesConfig(propertySources));
            webRequest.setAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, Boolean.TRUE, RequestAttributes.SCOPE_REQUEST);
            MockApplicationContext appCtx = (MockApplicationContext)webRequest.getApplicationContext();
            appCtx.registerMockResource("/grails-app/views/layouts/application.gsp", "<html><body><h1>Default Layout</h1><g:layoutBody /></body></html>");
View Full Code Here

    @Test
    public void test() throws IOException {
        Map<String, Object> map = new HashMap<>();
        map.put("encoding", "gbk");
        PropertySource propertySource1 = new MapPropertySource("map", map);
        System.out.println(propertySource1.getProperty("encoding"));

        ResourcePropertySource propertySource2 = new ResourcePropertySource("resource", "classpath:resources.properties");
        System.out.println(propertySource2.getProperty("encoding"));
    }
View Full Code Here

    @Test
    public void test2() throws IOException {

        Map<String, Object> map = new HashMap<>();
        map.put("encoding", "gbk");
        PropertySource propertySource1 = new MapPropertySource("map", map);

        ResourcePropertySource propertySource2 = new ResourcePropertySource("resource", "classpath:resources.properties");

        CompositePropertySource compositePropertySource = new CompositePropertySource("composite");
        compositePropertySource.addPropertySource(propertySource1);
View Full Code Here

    @Test
    public void test3() throws IOException {

        Map<String, Object> map = new HashMap<>();
        map.put("encoding", "gbk");
        PropertySource propertySource1 = new MapPropertySource("map", map);

        ResourcePropertySource propertySource2 = new ResourcePropertySource(
                "resource", "classpath:resources.properties");

View Full Code Here

    localProps.put("resourceDirPlaceHolder", "myResourceDir");

    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.getEnvironment()
      .getPropertySources()
        .addFirst(new MapPropertySource("localProps", localProps));
    ctx.load("ReproTests-workaround.xml");
    ctx.refresh();
  }
View Full Code Here

  public void testEnvironmentAccess() throws Exception {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("key.foo", "value.foo");
    GenericApplicationContext wac = (GenericApplicationContext)
    context.getRequest().getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    wac.getEnvironment().getPropertySources().addFirst(new MapPropertySource("mapSource", map));
    wac.getDefaultListableBeanFactory().registerSingleton("bean2", context.getRequest().getAttribute("bean"));
    tag.setExpression("@environment['key.foo']");
    int action = tag.doStartTag();
    assertEquals(Tag.EVAL_BODY_INCLUDE, action);
    action = tag.doEndTag();
View Full Code Here

TOP

Related Classes of org.springframework.core.env.MapPropertySource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.