org.springframework.core.env.AbstractEnvironment源码实例Demo

类org.springframework.core.env.AbstractEnvironment源码实例Demo

下面列出了怎么用org.springframework.core.env.AbstractEnvironment的API类实例代码及写法,或者点击链接到github查看源代码。

@SuppressWarnings("rawtypes")
	@EventListener
	public void handleContextRefresh(ContextRefreshedEvent event) {
		final Environment environment = event.getApplicationContext().getEnvironment();
		LOGGER.info("====== Environment and configuration ======");
		LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
		final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
		StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
				.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
				.forEach(prop -> {
					LOGGER.info("{}", prop);
//					Object resolved = environment.getProperty(prop, Object.class);
//					if (resolved instanceof String) {
//						LOGGER.info("{}", environment.getProperty(prop));
//					}
				});
		LOGGER.info("===========================================");
	}
 
@SuppressWarnings("rawtypes")
	@EventListener
	public void handleContextRefresh(ContextRefreshedEvent event) {
		final Environment environment = event.getApplicationContext().getEnvironment();
		LOGGER.info("====== Environment and configuration ======");
		LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
		final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
		StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
				.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
				.forEach(prop -> {
					LOGGER.info("{}", prop);
//					Object resolved = environment.getProperty(prop, Object.class);
//					if (resolved instanceof String) {
//						LOGGER.info("{}", environment.getProperty(prop));
//					}
				});
		LOGGER.info("===========================================");
	}
 
@SuppressWarnings("rawtypes")
	@EventListener
	public void handleContextRefresh(ContextRefreshedEvent event) {
		final Environment environment = event.getApplicationContext().getEnvironment();
		LOGGER.info("====== Environment and configuration ======");
		LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
		final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
		StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
				.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
				.forEach(prop -> {
					LOGGER.info("{}", prop);
//					Object resolved = environment.getProperty(prop, Object.class);
//					if (resolved instanceof String) {
//						LOGGER.info("{}", environment.getProperty(prop));
//					}
				});
		LOGGER.info("===========================================");
	}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.info("====== Environment and configuration ======");
	LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> {
				Object resolved = environment.getProperty(prop, Object.class);
				if (resolved instanceof String) {
					LOGGER.info("{} - {}", prop, environment.getProperty(prop));
				} else {
					LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
				}
				
			});
	LOGGER.debug("===========================================");
}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.info("====== Environment and configuration ======");
	LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> {
				Object resolved = environment.getProperty(prop, Object.class);
				if (resolved instanceof String) {
					LOGGER.info("{} - {}", prop, environment.getProperty(prop));
				} else {
					LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
				}
				
			});
	LOGGER.debug("===========================================");
}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.info("====== Environment and configuration ======");
	LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> {
				Object resolved = environment.getProperty(prop, Object.class);
				if (resolved instanceof String) {
					LOGGER.info("{} - {}", prop, environment.getProperty(prop));
				} else {
					LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
				}
				
			});
	LOGGER.debug("===========================================");
}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.info("====== Environment and configuration ======");
	LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> {
				Object resolved = environment.getProperty(prop, Object.class);
				if (resolved instanceof String) {
					LOGGER.info("{} - {}", prop, environment.getProperty(prop));
				} else {
					LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
				}
				
			});
	LOGGER.debug("===========================================");
}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.info("====== Environment and configuration ======");
	LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> {
				Object resolved = environment.getProperty(prop, Object.class);
				if (resolved instanceof String) {
					LOGGER.info("{} - {}", prop, environment.getProperty(prop));
				} else {
					LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
				}
				
			});
	LOGGER.debug("===========================================");
}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.info("====== Environment and configuration ======");
	LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> {
				Object resolved = environment.getProperty(prop, Object.class);
				if (resolved instanceof String) {
					LOGGER.info("{} - {}", prop, environment.getProperty(prop));
				} else {
					LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
				}
				
			});
	LOGGER.debug("===========================================");
}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.info("====== Environment and configuration ======");
	LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> {
				Object resolved = environment.getProperty(prop, Object.class);
				if (resolved instanceof String) {
					LOGGER.info("{} - {}", prop, environment.getProperty(prop));
				} else {
					LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
				}
				
			});
	LOGGER.debug("===========================================");
}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.info("====== Environment and configuration ======");
	LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> {
				Object resolved = environment.getProperty(prop, Object.class);
				if (resolved instanceof String) {
					LOGGER.info("{} - {}", prop, environment.getProperty(prop));
				} else {
					LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
				}
				
			});
	LOGGER.debug("===========================================");
}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.info("====== Environment and configuration ======");
	LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> {
				Object resolved = environment.getProperty(prop, Object.class);
				if (resolved instanceof String) {
					LOGGER.info("{} - {}", prop, environment.getProperty(prop));
				} else {
					LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
				}
				
			});
	LOGGER.debug("===========================================");
}
 
@SuppressWarnings("rawtypes")
	@EventListener
	public void handleContextRefresh(ContextRefreshedEvent event) {
		final Environment environment = event.getApplicationContext().getEnvironment();
		LOGGER.debug("====== Environment and configuration ======");
		LOGGER.debug("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
		final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
		StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
				.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
				.forEach(prop -> {
					LOGGER.debug("{}", prop);
//					Object resolved = environment.getProperty(prop, Object.class);
//					if (resolved instanceof String) {
//						LOGGER.info("{}", environment.getProperty(prop));
//					}
				});
		LOGGER.debug("===========================================");
	}
 
@SuppressWarnings("rawtypes")
	@EventListener
	public void handleContextRefresh(ContextRefreshedEvent event) {
		final Environment environment = event.getApplicationContext().getEnvironment();
		LOGGER.debug("====== Environment and configuration ======");
		LOGGER.debug("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
		final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
		StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
				.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
				.forEach(prop -> {
					LOGGER.debug("{}", prop);
//					Object resolved = environment.getProperty(prop, Object.class);
//					if (resolved instanceof String) {
//						LOGGER.info("{}", environment.getProperty(prop));
//					}
				});
		LOGGER.debug("===========================================");
	}
 
@SuppressWarnings("rawtypes")
	@EventListener
	public void handleContextRefresh(ContextRefreshedEvent event) {
		final Environment environment = event.getApplicationContext().getEnvironment();
		LOGGER.debug("====== Environment and configuration ======");
		LOGGER.debug("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
		final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
		StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
				.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
				.forEach(prop -> {
					LOGGER.debug("{}", prop);
//					Object resolved = environment.getProperty(prop, Object.class);
//					if (resolved instanceof String) {
//						LOGGER.info("{}", environment.getProperty(prop));
//					}
				});
		LOGGER.debug("===========================================");
	}
 
源代码16 项目: Mahuta   文件: Application.java
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
    
    final Environment env = event.getApplicationContext().getEnvironment();
    log.trace("====== Environment and configuration ======");
    log.trace("Active profiles: {}", Arrays.toString(env.getActiveProfiles()));
    final MutablePropertySources sources = ((AbstractEnvironment) env).getPropertySources();
    StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
            .map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
            .filter(prop -> !(prop.contains("credentials") || prop.contains("password")))
            .forEach(prop -> log.trace("{}: {}", prop, env.getProperty(prop)));
    
    log.info("===========================================");
    
    log.info("Application [{} - version: {}, build time: {}] Started !", 
            buildProperties.getGroup() + ":" + buildProperties.getArtifact(), 
            buildProperties.getVersion(),
            buildProperties.getTime());
    
    log.info("===========================================");
}
 
源代码17 项目: c2mon   文件: DaqStartup.java
public static synchronized void start(String[] args) throws IOException {
  String daqName = getProperty("c2mon.daq.name");
  if (daqName == null) {
    throw new RuntimeException("Please specify the DAQ process name using 'c2mon.daq.name'");
  }

  // The JMS mode (single, double, test) is controlled via Spring profiles
  String mode = getProperty("c2mon.daq.jms.mode");
  if (mode != null) {
    System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, mode);
  }

  if (application == null) {
    application = new SpringApplicationBuilder(DaqStartup.class)
            .bannerMode(Banner.Mode.OFF)
            .build();
  }
  context = application.run(args);

  driverKernel = context.getBean(DriverKernel.class);
  driverKernel.init();

  log.info("DAQ core is now initialized");
}
 
private Map<String, String> getCurrentEnvironmentProperties() {
	Map<String, String> currentEnvironment = new HashMap<>();

	Set<String> keys = new HashSet<>();

	for (PropertySource<?> propertySource : ((AbstractEnvironment) this.environment)
			.getPropertySources()) {
		if (propertySource instanceof MapPropertySource) {
			keys.addAll(Arrays
					.asList(((MapPropertySource) propertySource).getPropertyNames()));
		}
	}

	for (String key : keys) {
		currentEnvironment.put(key, this.environment.getProperty(key));
	}

	return currentEnvironment;
}
 
源代码19 项目: alfresco-mvc   文件: DispatcherWebscript.java
protected void configureDispatcherServlet(DispatcherServlet dispatcherServlet) {
	if (inheritGlobalProperties) {
		final Properties globalProperties = (Properties) this.applicationContext.getBean("global-properties");

		ConfigurableEnvironment servletEnv = dispatcherServlet.getEnvironment();
		servletEnv.merge(new AbstractEnvironment() {
			@Override
			public MutablePropertySources getPropertySources() {
				MutablePropertySources mutablePropertySources = new MutablePropertySources();
				mutablePropertySources
						.addFirst(new PropertiesPropertySource("alfresco-global.properties", globalProperties));
				return mutablePropertySources;
			}
		});
	}
}
 
源代码20 项目: vividus   文件: BeanFactory.java
private static String[] getActiveProfiles()
{
    try
    {
        String value = ConfigurationResolver.getInstance().getProperties()
                .getProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME);
        return value != null ? value.split(",") : new String[]{};
    }
    catch (IOException e)
    {
        throw new IllegalStateException(e);
    }
}
 
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey() {
	SecurityManager securityManager = new SecurityManager() {
		@Override
		public void checkPermission(Permission perm) {
			// Disallowing access to System#getenv means that our
			// ReadOnlySystemAttributesMap will come into play.
			if ("getenv.*".equals(perm.getName())) {
				throw new AccessControlException("Accessing the system environment is disallowed");
			}
			// Disallowing access to the spring.profiles.active property means that
			// the BeanDefinitionReader won't be able to determine which profiles are
			// active. We should see an INFO-level message in the console about this
			// and as a result, any components marked with a non-default profile will
			// be ignored.
			if (("getenv." + AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME).equals(perm.getName())) {
				throw new AccessControlException(
						format("Accessing system environment variable [%s] is disallowed",
								AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
			}
		}
	};
	System.setSecurityManager(securityManager);

	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
	reader.register(C1.class);
	assertThat(bf.containsBean("c1"), is(false));
}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.info("====== Environment and configuration ======");
	LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> LOGGER.info("{}", prop));// environment.getProperty(prop)
	LOGGER.info("===========================================");
}
 
@Override
public Enumeration<?> propertyNames() {
    Set<String> names = new HashSet<>();
    for (PropertySource<?> propertySource : ((AbstractEnvironment) env).getPropertySources()) {
        if (propertySource instanceof EnumerablePropertySource) {
            Collections.addAll(names, ((EnumerablePropertySource) propertySource).getPropertyNames());
        }
    }
    return Collections.enumeration(names);
}
 
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
	final Environment environment = event.getApplicationContext().getEnvironment();
	LOGGER.debug("====== Environment and configuration ======");
	LOGGER.debug("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
	final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
	StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
			.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
			.forEach(prop -> LOGGER.debug("{}", prop));// environment.getProperty(prop)
	LOGGER.debug("===========================================");
}
 
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey() {
	SecurityManager securityManager = new SecurityManager() {
		@Override
		public void checkPermission(Permission perm) {
			// Disallowing access to System#getenv means that our
			// ReadOnlySystemAttributesMap will come into play.
			if ("getenv.*".equals(perm.getName())) {
				throw new AccessControlException("Accessing the system environment is disallowed");
			}
			// Disallowing access to the spring.profiles.active property means that
			// the BeanDefinitionReader won't be able to determine which profiles are
			// active. We should see an INFO-level message in the console about this
			// and as a result, any components marked with a non-default profile will
			// be ignored.
			if (("getenv." + AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME).equals(perm.getName())) {
				throw new AccessControlException(
						format("Accessing system environment variable [%s] is disallowed",
								AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
			}
		}
	};
	System.setSecurityManager(securityManager);

	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
	reader.register(C1.class);
	assertThat(bf.containsBean("c1"), is(false));
}
 
源代码26 项目: ambari-logsearch   文件: LogFeederProps.java
@PostConstruct
public void init() {
  properties = new Properties();
  MutablePropertySources propSrcs = ((AbstractEnvironment) env).getPropertySources();
  ResourcePropertySource propertySource = (ResourcePropertySource) propSrcs.get("class path resource [" +
    LogFeederConstants.LOGFEEDER_PROPERTIES_FILE + "]");
  if (propertySource != null) {
    Stream.of(propertySource)
      .map(MapPropertySource::getPropertyNames)
      .flatMap(Arrays::<String>stream)
      .forEach(propName -> properties.setProperty(propName, env.getProperty(propName)));
  } else {
    throw new IllegalArgumentException("Cannot find logfeeder.properties on the classpath");
  }
}
 
@Bean(name = BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME)
public PropertyResolver dubboScanBasePackagesPropertyResolver(ConfigurableEnvironment environment) {
    ConfigurableEnvironment propertyResolver = new AbstractEnvironment() {
        @Override
        protected void customizePropertySources(MutablePropertySources propertySources) {
            Map<String, Object> dubboScanProperties = getSubProperties(environment.getPropertySources(), DUBBO_SCAN_PREFIX);
            propertySources.addLast(new MapPropertySource("dubboScanProperties", dubboScanProperties));
        }
    };
    ConfigurationPropertySources.attach(propertyResolver);
    return new DelegatingPropertyResolver(propertyResolver);
}
 
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey() {
	SecurityManager securityManager = new SecurityManager() {
		@Override
		public void checkPermission(Permission perm) {
			// Disallowing access to System#getenv means that our
			// ReadOnlySystemAttributesMap will come into play.
			if ("getenv.*".equals(perm.getName())) {
				throw new AccessControlException("Accessing the system environment is disallowed");
			}
			// Disallowing access to the spring.profiles.active property means that
			// the BeanDefinitionReader won't be able to determine which profiles are
			// active. We should see an INFO-level message in the console about this
			// and as a result, any components marked with a non-default profile will
			// be ignored.
			if (("getenv." + AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME).equals(perm.getName())) {
				throw new AccessControlException(
						format("Accessing system environment variable [%s] is disallowed",
								AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
			}
		}
	};
	System.setSecurityManager(securityManager);

	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
	reader.register(C1.class);
	assertThat(bf.containsBean("c1"), is(false));
}
 
public EventBasedConfigurationChangeDetector(AbstractEnvironment environment,
		ConfigReloadProperties properties, KubernetesClient kubernetesClient,
		ConfigurationUpdateStrategy strategy,
		ConfigMapPropertySourceLocator configMapPropertySourceLocator,
		SecretsPropertySourceLocator secretsPropertySourceLocator) {
	super(environment, properties, kubernetesClient, strategy);

	this.configMapPropertySourceLocator = configMapPropertySourceLocator;
	this.secretsPropertySourceLocator = secretsPropertySourceLocator;
	this.watches = new HashMap<>();
}
 
public PollingConfigurationChangeDetector(AbstractEnvironment environment,
		ConfigReloadProperties properties, KubernetesClient kubernetesClient,
		ConfigurationUpdateStrategy strategy,
		ConfigMapPropertySourceLocator configMapPropertySourceLocator,
		SecretsPropertySourceLocator secretsPropertySourceLocator) {
	super(environment, properties, kubernetesClient, strategy);

	this.configMapPropertySourceLocator = configMapPropertySourceLocator;
	this.secretsPropertySourceLocator = secretsPropertySourceLocator;
}