当前位置: 首页>>代码示例>>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;未经允许,请勿转载。