org.springframework.core.env.AbstractEnvironment Java Examples
The following examples show how to use
org.springframework.core.env.AbstractEnvironment.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnvironmentConfigurationLogger.java From kubernetes-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #2
Source File: Application.java From Mahuta with Apache License 2.0 | 6 votes |
@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("==========================================="); }
Example #3
Source File: SimpleEnvironmentVariablesProvider.java From spring-cloud-task with Apache License 2.0 | 6 votes |
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; }
Example #4
Source File: EnvironmentConfigurationLogger.java From docker-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #5
Source File: EnvironmentConfigurationLogger.java From docker-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #6
Source File: EnvironmentConfigurationLogger.java From docker-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #7
Source File: EnvironmentConfigurationLogger.java From kubernetes-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #8
Source File: EnvironmentConfigurationLogger.java From kubernetes-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #9
Source File: EnvironmentConfigurationLogger.java From kubernetes-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #10
Source File: EnvironmentConfigurationLogger.java From kubernetes-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #11
Source File: EnvironmentConfigurationLogger.java From kubernetes-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #12
Source File: EnvironmentConfigurationLogger.java From kubernetes-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #13
Source File: EnvironmentConfigurationLogger.java From kubernetes-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #14
Source File: EnvironmentConfigurationLogger.java From kubernetes-crash-course with MIT License | 6 votes |
@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("==========================================="); }
Example #15
Source File: EnvironmentConfigurationLogger.java From pcf-crash-course-with-spring-boot with MIT License | 6 votes |
@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("==========================================="); }
Example #16
Source File: DaqStartup.java From c2mon with GNU Lesser General Public License v3.0 | 6 votes |
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"); }
Example #17
Source File: EnvironmentConfigurationLogger.java From pcf-crash-course-with-spring-boot with MIT License | 6 votes |
@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("==========================================="); }
Example #18
Source File: EnvironmentConfigurationLogger.java From pcf-crash-course-with-spring-boot with MIT License | 6 votes |
@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("==========================================="); }
Example #19
Source File: DispatcherWebscript.java From alfresco-mvc with Apache License 2.0 | 6 votes |
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; } }); } }
Example #20
Source File: SpringProfileSpecificNameResolver.java From cuba with Apache License 2.0 | 5 votes |
public SpringProfileSpecificNameResolver(ServletContext servletContext) { activeProfiles = servletContext.getInitParameter(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME); if (StringUtils.isEmpty(activeProfiles)) { activeProfiles = System.getProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME); } if (StringUtils.isEmpty(activeProfiles)) { activeProfiles = System.getenv(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME); } if (StringUtils.isEmpty(activeProfiles)) { activeProfiles = System.getenv(UNIX_ENV_ACTIVE_PROFILES_PROPERTY_NAME); } }
Example #21
Source File: JettyEmbeddedContainer.java From gravitee-management-rest-api with Apache License 2.0 | 5 votes |
@Override protected void doStart() throws Exception { AbstractHandler noContentHandler = new NoContentOutputErrorHandler(); // This part is needed to avoid WARN while starting container. noContentHandler.setServer(server); server.addBean(noContentHandler); // Spring configuration System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "basic"); List<ServletContextHandler> contexts = new ArrayList<>(); if (startPortalAPI) { // REST configuration for Portal API ServletContextHandler portalContextHandler = configureAPI(portalEntrypoint, GraviteePortalApplication.class.getName(), SecurityPortalConfiguration.class); contexts.add(portalContextHandler); } if (startManagementAPI) { // REST configuration for Management API ServletContextHandler managementContextHandler = configureAPI(managementEntrypoint, GraviteeManagementApplication.class.getName(), SecurityManagementConfiguration.class); contexts.add(managementContextHandler); } if (contexts.isEmpty()) { throw new IllegalStateException("At least one API should be enabled"); } server.setHandler(new ContextHandlerCollection(contexts.toArray(new ServletContextHandler[contexts.size()]))); // start the server server.start(); }
Example #22
Source File: PollingConfigurationChangeDetector.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
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; }
Example #23
Source File: EventBasedConfigurationChangeDetector.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
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<>(); }
Example #24
Source File: EventBasedConfigurationChangeDetector.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
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<>(); }
Example #25
Source File: EnvironmentSecurityManagerIntegrationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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)); }
Example #26
Source File: TransportConfig.java From msf4j with Apache License 2.0 | 5 votes |
@PostConstruct public void init() { id = resolveId(); enabled = resolveEnabled(); port = resolvePort(); host = resolveHost(); if (isHTTPS()) { keyStoreFile = resolveKeyStoreFile(); keyStorePass = resolveKeyStorePass(); certPass = resolveKeyCertPass(); } for (Iterator it = ((AbstractEnvironment) env).getPropertySources().iterator(); it.hasNext(); ) { Object propertySource = it.next(); if (propertySource instanceof MapPropertySource && SpringConstants.APPLICATION_PROPERTIES.equals(((MapPropertySource) propertySource).getName())) { MapPropertySource mapPropertySource = (MapPropertySource) propertySource; for (Map.Entry<String, Object> entry : mapPropertySource.getSource().entrySet()) { String key = entry.getKey(); if (key.startsWith(getScheme()) && key.contains(SpringConstants.PARAMETER_STR)) { parameters.put(key.substring(key.indexOf(SpringConstants.PARAMETER_STR) + 11), (String) entry .getValue()); } } } } }
Example #27
Source File: PollingConfigurationChangeDetector.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
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; }
Example #28
Source File: DubboRelaxedBinding2AutoConfiguration.java From dubbo-spring-boot-project with Apache License 2.0 | 5 votes |
@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); }
Example #29
Source File: LogFeederProps.java From ambari-logsearch with Apache License 2.0 | 5 votes |
@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"); } }
Example #30
Source File: EnvironmentSecurityManagerIntegrationTests.java From java-technology-stack with MIT License | 5 votes |
@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)); }