本文整理汇总了Java中org.springframework.core.env.Environment类的典型用法代码示例。如果您正苦于以下问题:Java Environment类的具体用法?Java Environment怎么用?Java Environment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Environment类属于org.springframework.core.env包,在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addConnectionFactories
import org.springframework.core.env.Environment; //导入依赖的package包/类
/**
* Configures the connection factories for Facebook and Twitter.
* @param cfConfig
* @param env
*/
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
cfConfig.addConnectionFactory(new TwitterConnectionFactory(
env.getProperty("twitter.consumer.key"),
env.getProperty("twitter.consumer.secret")
));
cfConfig.addConnectionFactory(new GoogleConnectionFactory(
env.getProperty("twitter.consumer.key"), //TODO !!!!!!!!!!
env.getProperty("twitter.consumer.secret") //TODO !!!!!!!!!!
));
FacebookConnectionFactory facebookFactory = new FacebookConnectionFactory(
env.getProperty("facebook.app.id"),
env.getProperty("facebook.app.secret"));
facebookFactory.setScope("public_profile,email,user_friends");
cfConfig.addConnectionFactory(facebookFactory);
}
示例2: isSpringSecurityEnabled
import org.springframework.core.env.Environment; //导入依赖的package包/类
private boolean isSpringSecurityEnabled(ConditionContext ctx) {
boolean enabled = true;
Environment env = ctx.getEnvironment();
for (String propName : props) {
if (env.containsProperty(propName)) {
if (!Boolean.parseBoolean(env.getProperty(propName))) {
enabled = false;
break;
}
}
}
if (enabled) {
enabled = ClassUtils.isPresent(SPRING_SEC_CLASS_NAME, ctx.getClassLoader());
}
return enabled;
}
示例3: configuration
import org.springframework.core.env.Environment; //导入依赖的package包/类
@Bean
public twitter4j.conf.Configuration configuration(final Environment environment) {
final ConfigurationBuilder cb = new ConfigurationBuilder();
final String consumerKey = environment.getProperty("twitter.consumerKey");
final String consumerSecret = environment.getProperty("twitter.consumerSecret");
cb.setOAuthConsumerSecret(consumerSecret);
cb.setOAuthConsumerKey(consumerKey);
return cb.build();
}
示例4: DatabaseConfiguration
import org.springframework.core.env.Environment; //导入依赖的package包/类
public DatabaseConfiguration(Environment env,
JpaProperties jpaProperties,
TenantListRepository tenantListRepository) {
this.env = env;
this.jpaProperties = jpaProperties;
this.tenantListRepository = tenantListRepository;
}
示例5: main
import org.springframework.core.env.Environment; //导入依赖的package包/类
/**
* Main method, used to run the application.
*
* @param args the command line arguments
* @throws UnknownHostException if the local host name could not be resolved into an address
*/
public static void main(String[] args) throws UnknownHostException {
SpringApplication app = new SpringApplication(BlogApp.class);
DefaultProfileUtil.addDefaultProfile(app);
Environment env = app.run(args).getEnvironment();
String protocol = "http";
if (env.getProperty("server.ssl.key-store") != null) {
protocol = "https";
}
log.info("\n----------------------------------------------------------\n\t" +
"Application '{}' is running! Access URLs:\n\t" +
"Local: \t\t{}://localhost:{}\n\t" +
"External: \t{}://{}:{}\n\t" +
"Profile(s): \t{}\n----------------------------------------------------------",
env.getProperty("spring.application.name"),
protocol,
env.getProperty("server.port"),
protocol,
InetAddress.getLocalHost().getHostAddress(),
env.getProperty("server.port"),
env.getActiveProfiles());
String configServerStatus = env.getProperty("configserver.status");
log.info("\n----------------------------------------------------------\n\t" +
"Config Server: \t{}\n----------------------------------------------------------",
configServerStatus == null ? "Not found or not setup for this application" : configServerStatus);
}
示例6: test
import org.springframework.core.env.Environment; //导入依赖的package包/类
@Test
public void test(){
ApplicationContext atc=new AnnotationConfigApplicationContext(SystemProperties.class);
SystemPropertiesMap map=(SystemPropertiesMap)atc.getBean("systemPropertiesMap");
PrinterUtils.printILog("SystemPropertiesMap toString:"+map.toString());
Environment environment=(Environment)atc.getBean("environment");
PrinterUtils.printILog("environment getBean password:"+environment.getProperty("password"));
}
示例7: UserController
import org.springframework.core.env.Environment; //导入依赖的package包/类
public UserController(Environment env,
MongoTemplate mongo,
DateService dates,
RandomService random,
EmailService email) {
this.env = requireNonNull(env);
this.mongo = requireNonNull(mongo);
this.dates = requireNonNull(dates);
this.random = requireNonNull(random);
this.email = requireNonNull(email);
}
示例8: start
import org.springframework.core.env.Environment; //导入依赖的package包/类
@Override
public void start(org.apache.sshd.server.Environment env) throws IOException {
terminalType = env.getEnv().get("TERM");
sshThread = new Thread(this, "ssh-cli " + session.getSession().getIoSession()
.getAttribute(Constants.USER));
sshThread.start();
}
示例9: TokensPurgeService
import org.springframework.core.env.Environment; //导入依赖的package包/类
public TokensPurgeService(
final DateService dates,
final MongoTemplate mongo,
final Environment env) {
this.dates = requireNonNull(dates);
this.mongo = requireNonNull(mongo);
this.env = requireNonNull(env);
}
示例10: VaultConnectorBootstrapConfiguration
import org.springframework.core.env.Environment; //导入依赖的package包/类
public VaultConnectorBootstrapConfiguration(
VaultConnectorGenericBackendProperties connectorVaultProperties,
VaultGenericBackendProperties genericBackendProperties,
Environment environment) {
this.connectorVaultProperties = connectorVaultProperties;
this.genericBackendProperties = genericBackendProperties;
this.environment = environment;
Cloud cloud;
VaultServiceInfo vaultServiceInfo = null;
try {
CloudFactory cloudFactory = new CloudFactory();
cloud = cloudFactory.getCloud();
List<ServiceInfo> serviceInfos = cloud.getServiceInfos(VaultOperations.class);
if (serviceInfos.size() == 1) {
vaultServiceInfo = (VaultServiceInfo) serviceInfos.get(0);
}
}
catch (CloudException e) {
// not running in a Cloud environment
}
this.vaultServiceInfo = vaultServiceInfo;
}
开发者ID:pivotal-cf,项目名称:spring-cloud-vault-connector,代码行数:28,代码来源:VaultConnectorBootstrapConfiguration.java
示例11: addConnectionFactories
import org.springframework.core.env.Environment; //导入依赖的package包/类
@Override
public void addConnectionFactories(
final ConnectionFactoryConfigurer configurer,
final Environment environment) {
final GoogleConnectionFactory factory = new GoogleConnectionFactory(
this.properties.getAppId(), this.properties.getAppSecret());
configurer.addConnectionFactory(factory);
}
示例12: getActiveProfiles
import org.springframework.core.env.Environment; //导入依赖的package包/类
/**
* 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;
}
示例13: clickHouseDataSource
import org.springframework.core.env.Environment; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public ClickHouseDataSource clickHouseDataSource(Environment environment,
ClickHouseProperties clickHouseProperties) {
return new ClickHouseDataSource(
environment.getProperty("clickhouse.metrics.datasource.url", CLICKHOUSE_JDBC_URL),
clickHouseProperties);
}
示例14: main
import org.springframework.core.env.Environment; //导入依赖的package包/类
/**
* Main method, used to run the application.
*
* @param args the command line arguments
* @throws UnknownHostException if the local host name could not be resolved into an address
*/
public static void main(String[] args) throws UnknownHostException {
SpringApplication app = new SpringApplication(GatewayApp.class);
DefaultProfileUtil.addDefaultProfile(app);
Environment env = app.run(args).getEnvironment();
String protocol = "http";
if (env.getProperty("server.ssl.key-store") != null) {
protocol = "https";
}
log.info("\n----------------------------------------------------------\n\t" +
"Application '{}' is running! Access URLs:\n\t" +
"Local: \t\t{}://localhost:{}\n\t" +
"External: \t{}://{}:{}\n\t" +
"Profile(s): \t{}\n----------------------------------------------------------",
env.getProperty("spring.application.name"),
protocol,
env.getProperty("server.port"),
protocol,
InetAddress.getLocalHost().getHostAddress(),
env.getProperty("server.port"),
env.getActiveProfiles());
String configServerStatus = env.getProperty("configserver.status");
log.info("\n----------------------------------------------------------\n\t" +
"Config Server: \t{}\n----------------------------------------------------------",
configServerStatus == null ? "Not found or not setup for this application" : configServerStatus);
}
示例15: setEnvironment
import org.springframework.core.env.Environment; //导入依赖的package包/类
@Override
public void setEnvironment(Environment environment) {
this.environment = environment;
Map<String, Object> systemEnvironment = ((ConfigurableEnvironment) environment).getSystemEnvironment();
System.out.println("=== System Environment ===");
System.out.println(getMapString(systemEnvironment));
System.out.println();
System.out.println("=== Java System Properties ===");
Map<String, Object> systemProperties = ((ConfigurableEnvironment) environment).getSystemProperties();
System.out.println(getMapString(systemProperties));
}