Java Code Examples for org.springframework.core.env.Environment#getActiveProfiles()
The following examples show how to use
org.springframework.core.env.Environment#getActiveProfiles() .
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: GcpConfigProperties.java From spring-cloud-gcp with Apache License 2.0 | 6 votes |
@Override public void setEnvironment(Environment environment) { if (this.profile == null) { String[] profiles = environment.getActiveProfiles(); if (profiles.length == 0) { profiles = environment.getDefaultProfiles(); } if (profiles.length > 0) { this.profile = profiles[profiles.length - 1]; } else { this.profile = "default"; } } }
Example 2
Source File: SimpleFlowApplication.java From spring-in-action-5-samples with Apache License 2.0 | 5 votes |
@Bean public CommandLineRunner writeData(FileWriterGateway gateway, Environment env) { return args -> { String[] activeProfiles = env.getActiveProfiles(); if (activeProfiles.length > 0) { String profile = activeProfiles[0]; gateway.writeToFile("simple.txt", "Hello, Spring Integration! (" + profile + ")"); } else { System.out.println("No active profile set. Should set active profile to one of xmlconfig, javaconfig, or javadsl."); } }; }
Example 3
Source File: DefaultProfileUtil.java From e-commerce-microservice with Apache License 2.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 4
Source File: ConfigClientProperties.java From spring-cloud-config with Apache License 2.0 | 5 votes |
public ConfigClientProperties(Environment environment) { String[] profiles = environment.getActiveProfiles(); if (profiles.length == 0) { profiles = environment.getDefaultProfiles(); } this.setProfile(StringUtils.arrayToCommaDelimitedString(profiles)); }
Example 5
Source File: DefaultProfileUtil.java From e-commerce-microservice with Apache License 2.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 6
Source File: DefaultProfileUtil.java From tutorials with MIT License | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 7
Source File: DefaultProfileUtil.java From tutorials with MIT License | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 8
Source File: DefaultProfileUtil.java From ehcache3-samples with Apache License 2.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 9
Source File: DefaultProfileUtil.java From okta-jhipster-microservices-oauth-example with Apache License 2.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 10
Source File: DefaultProfileUtil.java From flair-registry with Apache License 2.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 11
Source File: DefaultProfileUtil.java From albedo with GNU Lesser General Public License v3.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 12
Source File: DefaultProfileUtil.java From Full-Stack-Development-with-JHipster with MIT License | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 13
Source File: DefaultProfileUtil.java From jhipster-microservices-example with Apache License 2.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 14
Source File: RuntimeConfiguration.java From Cheddar with Apache License 2.0 | 5 votes |
public static boolean isDeployedEnvironment(final Environment environment) { for (final String profile : environment.getActiveProfiles()) { if (profile.equalsIgnoreCase(CI_PROFILE) || profile.equalsIgnoreCase(UAT_PROFILE) || profile.equalsIgnoreCase(PRODUCTION_PROFILE)) { return true; } } return false; }
Example 15
Source File: DefaultProfileUtil.java From cubeai with Apache License 2.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 16
Source File: DefaultProfileUtil.java From cubeai with Apache License 2.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 17
Source File: DefaultProfileUtil.java From cubeai with Apache License 2.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 18
Source File: KubernetesProfileApplicationListener.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
private boolean hasKubernetesProfile(Environment environment) { for (String activeProfile : environment.getActiveProfiles()) { if (KUBERNETES_PROFILE.equalsIgnoreCase(activeProfile)) { return true; } } return false; }
Example 19
Source File: DefaultProfileUtil.java From flair-engine with Apache License 2.0 | 5 votes |
/** * Get the profiles that are applied else get default profiles. * * @param env spring environment * @return profiles */ public static String[] getActiveProfiles(Environment env) { String[] profiles = env.getActiveProfiles(); if (profiles.length == 0) { return env.getDefaultProfiles(); } return profiles; }
Example 20
Source File: ProjectProperties.java From spring-boot-seed with MIT License | 4 votes |
@Autowired public ProjectProperties(Environment environment) { this.environment = environment; this.env = environment.getActiveProfiles(); }