當前位置: 首頁>>代碼示例>>Java>>正文


Java Environment類代碼示例

本文整理匯總了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);
  }
 
開發者ID:eduyayo,項目名稱:gamesboard,代碼行數:22,代碼來源:SocialContext.java

示例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;
    }
 
開發者ID:juiser,項目名稱:juiser,代碼行數:22,代碼來源:JuiserSpringSecurityCondition.java

示例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();
}
 
開發者ID:Tristan971,項目名稱:Lyrebird,代碼行數:10,代碼來源:Twitter4JComponents.java

示例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;
}
 
開發者ID:xm-online,項目名稱:xm-ms-balance,代碼行數:8,代碼來源:DatabaseConfiguration.java

示例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);
}
 
開發者ID:IBM,項目名稱:Microservices-with-JHipster-and-Spring-Boot,代碼行數:33,代碼來源:BlogApp.java

示例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"));


}
 
開發者ID:tomoncle,項目名稱:JavaStudy,代碼行數:12,代碼來源:App.java

示例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);
}
 
開發者ID:membaza,項目名稱:users-service,代碼行數:13,代碼來源:UserController.java

示例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();
}
 
開發者ID:anand1st,項目名稱:sshd-shell-spring-boot,代碼行數:8,代碼來源:SshSessionInstance.java

示例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);
}
 
開發者ID:membaza,項目名稱:users-service,代碼行數:10,代碼來源:TokensPurgeService.java

示例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);
}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:9,代碼來源:GoogleConfigurerAdapter.java

示例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;
}
 
開發者ID:deepu105,項目名稱:spring-io,代碼行數:14,代碼來源:DefaultProfileUtil.java

示例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);
}
 
開發者ID:Camelion,項目名稱:cmeter,代碼行數:9,代碼來源:ClickHouseExporterAutoConfiguration.java

示例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);
}
 
開發者ID:deepu105,項目名稱:spring-io,代碼行數:33,代碼來源:GatewayApp.java

示例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));
}
 
開發者ID:chanjarster,項目名稱:spring-test-examples,代碼行數:13,代碼來源:TestPropertyTest.java


注:本文中的org.springframework.core.env.Environment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。