Java Code Examples for org.springframework.core.env.Environment#getActiveProfiles()

The following examples show how to use org.springframework.core.env.Environment#getActiveProfiles() . These examples are extracted from open source projects. 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
@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
/**
 * 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 3
Source Project: flair-engine   File: DefaultProfileUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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
private boolean hasKubernetesProfile(Environment environment) {
    for (String activeProfile : environment.getActiveProfiles()) {
        if (KUBERNETES_PROFILE.equalsIgnoreCase(activeProfile)) {
            return true;
        }
    }
    return false;
}
 
Example 5
Source Project: cubeai   File: DefaultProfileUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 Project: cubeai   File: DefaultProfileUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 Project: cubeai   File: DefaultProfileUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 Project: Cheddar   File: RuntimeConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
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 9
/**
 * 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
/**
 * 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
/**
 * 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
@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 13
/**
 * 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
/**
 * 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 15
Source Project: tutorials   File: DefaultProfileUtil.java    License: MIT License 5 votes vote down vote up
/**
 * 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 Project: tutorials   File: DefaultProfileUtil.java    License: MIT License 5 votes vote down vote up
/**
 * 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
/**
 * 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
public ConfigClientProperties(Environment environment) {
	String[] profiles = environment.getActiveProfiles();
	if (profiles.length == 0) {
		profiles = environment.getDefaultProfiles();
	}
	this.setProfile(StringUtils.arrayToCommaDelimitedString(profiles));
}
 
Example 19
/**
 * 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 Project: spring-boot-seed   File: ProjectProperties.java    License: MIT License 4 votes vote down vote up
@Autowired
public ProjectProperties(Environment environment) {
    this.environment = environment;
    this.env = environment.getActiveProfiles();
}