本文整理匯總了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));
}