本文整理汇总了Java中org.springframework.cloud.context.scope.refresh.RefreshScope类的典型用法代码示例。如果您正苦于以下问题:Java RefreshScope类的具体用法?Java RefreshScope怎么用?Java RefreshScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RefreshScope类属于org.springframework.cloud.context.scope.refresh包,在下文中一共展示了RefreshScope类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: keysComputedWhenChangesInExternalProperties
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Test
public void keysComputedWhenChangesInExternalProperties() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class)
.web(WebApplicationType.NONE).bannerMode(Mode.OFF)
.properties("spring.cloud.bootstrap.name:none").run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
TestPropertyValues
.of("spring.cloud.bootstrap.sources="
+ ExternalPropertySourceLocator.class.getName())
.applyTo(this.context.getEnvironment(), Type.MAP, "defaultProperties");
ContextRefresher contextRefresher = new ContextRefresher(this.context, scope);
RefreshEndpoint endpoint = new RefreshEndpoint(contextRefresher);
Collection<String> keys = endpoint.refresh();
assertTrue("Wrong keys: " + keys, keys.contains("external.message"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:17,代码来源:RefreshEndpointTests.java
示例2: springMainSourcesEmptyInRefreshCycle
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Test
public void springMainSourcesEmptyInRefreshCycle() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class)
.web(WebApplicationType.NONE).bannerMode(Mode.OFF)
.properties("spring.cloud.bootstrap.name:none").run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
// spring.main.sources should be empty when the refresh cycle starts (we don't
// want any config files from the application context getting into the one used to
// construct the environment for refresh)
TestPropertyValues
.of("spring.main.sources="
+ ExternalPropertySourceLocator.class.getName())
.applyTo(this.context);
ContextRefresher contextRefresher = new ContextRefresher(this.context, scope);
RefreshEndpoint endpoint = new RefreshEndpoint(contextRefresher);
Collection<String> keys = endpoint.refresh();
assertFalse("Wrong keys: " + keys, keys.contains("external.message"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:20,代码来源:RefreshEndpointTests.java
示例3: main
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
public static void main(String[] args) {
try (final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:config-toolkit-simple.xml")) {
context.registerShutdownHook();
context.start();
ExampleBeanWithSpel bean = context.getBean(ExampleBeanWithSpel.class);
GeneralConfigGroup cg1 = (GeneralConfigGroup) context.getBean("propertyGroup1");
cg1.register(new IObserver() {
@Override
public void notified(String data, String value) {
context.getBean(RefreshScope.class).refresh("exampleBeanWithSpel");
}
});
while (true) {
bean.someMethod();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
}
开发者ID:dangdangdotcom,项目名称:config-toolkit,代码行数:27,代码来源:SpelSupportTest.java
示例4: main
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
/**
* Common
*/
ConfigurableApplicationContext commonContext =
new SpringApplicationBuilder(ApolloApplication.class).web(false).run(args);
commonContext.addApplicationListener(new ApplicationPidFileWriter());
logger.info(commonContext.getId() + " isActive: " + commonContext.isActive());
/**
* ConfigService
*/
if (commonContext.getEnvironment().containsProperty("configservice")) {
ConfigurableApplicationContext configContext =
new SpringApplicationBuilder(ConfigServiceApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
logger.info(configContext.getId() + " isActive: " + configContext.isActive());
}
/**
* AdminService
*/
if (commonContext.getEnvironment().containsProperty("adminservice")) {
ConfigurableApplicationContext adminContext =
new SpringApplicationBuilder(AdminServiceApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
logger.info(adminContext.getId() + " isActive: " + adminContext.isActive());
}
/**
* Portal
*/
if (commonContext.getEnvironment().containsProperty("portal")) {
ConfigurableApplicationContext portalContext =
new SpringApplicationBuilder(PortalApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
logger.info(portalContext.getId() + " isActive: " + portalContext.isActive());
}
}
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:40,代码来源:ApolloApplication.java
示例5: main
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
/**
* Common
*/
ConfigurableApplicationContext commonContext =
new SpringApplicationBuilder(ApolloApplication.class).web(false).run(args);
commonContext.addApplicationListener(new ApplicationPidFileWriter());
logger.info(commonContext.getId() + " isActive: " + commonContext.isActive());
/**
* ConfigService
*/
if (commonContext.getEnvironment().containsProperty("configservice")) {
ConfigurableApplicationContext configContext =
new SpringApplicationBuilder(ConfigServiceApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
logger.info(configContext.getId() + " isActive: " + configContext.isActive());
}
/**
* AdminService
*/
if (commonContext.getEnvironment().containsProperty("adminservice")) {
ConfigurableApplicationContext adminContext =
new SpringApplicationBuilder(AdminServiceApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
logger.info(adminContext.getId() + " isActive: " + adminContext.isActive());
}
/**
* Portal
*/
if (commonContext.getEnvironment().containsProperty("portal")) {
ConfigurableApplicationContext portalContext =
new SpringApplicationBuilder(PortalApplication.class).parent(commonContext).run(args);
logger.info(portalContext.getId() + " isActive: " + portalContext.isActive());
}
}
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:39,代码来源:LocalApolloApplication.java
示例6: postProcessBeanDefinitionRegistry
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry)
throws BeansException {
registry.registerBeanDefinition("refreshScope",
BeanDefinitionBuilder.genericBeanDefinition(RefreshScope.class)
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE)
.getBeanDefinition());
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:9,代码来源:RefreshAutoConfiguration.java
示例7: refreshScopeHealthIndicator
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
@ConditionalOnEnabledHealthIndicator("refresh")
RefreshScopeHealthIndicator refreshScopeHealthIndicator(ObjectProvider<RefreshScope> scope,
ConfigurationPropertiesRebinder rebinder) {
return new RefreshScopeHealthIndicator(scope, rebinder);
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:8,代码来源:RefreshEndpointAutoConfiguration.java
示例8: keysComputedWhenAdded
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Test
public void keysComputedWhenAdded() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class)
.web(WebApplicationType.NONE).bannerMode(Mode.OFF)
.properties("spring.cloud.bootstrap.name:none").run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
context.getEnvironment().setActiveProfiles("local");
ContextRefresher contextRefresher = new ContextRefresher(this.context, scope);
RefreshEndpoint endpoint = new RefreshEndpoint(contextRefresher);
Collection<String> keys = endpoint.refresh();
assertTrue("Wrong keys: " + keys, keys.contains("added"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:14,代码来源:RefreshEndpointTests.java
示例9: keysComputedWhenOveridden
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Test
public void keysComputedWhenOveridden() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class)
.web(WebApplicationType.NONE).bannerMode(Mode.OFF)
.properties("spring.cloud.bootstrap.name:none").run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
context.getEnvironment().setActiveProfiles("override");
ContextRefresher contextRefresher = new ContextRefresher(this.context, scope);
RefreshEndpoint endpoint = new RefreshEndpoint(contextRefresher);
Collection<String> keys = endpoint.refresh();
assertTrue("Wrong keys: " + keys, keys.contains("message"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:14,代码来源:RefreshEndpointTests.java
示例10: eventsPublishedInOrder
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Test
public void eventsPublishedInOrder() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class)
.web(WebApplicationType.NONE).bannerMode(Mode.OFF).run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
ContextRefresher contextRefresher = new ContextRefresher(this.context, scope);
RefreshEndpoint endpoint = new RefreshEndpoint(contextRefresher);
Empty empty = this.context.getBean(Empty.class);
endpoint.refresh();
int after = empty.events.size();
assertEquals("Shutdown hooks not cleaned on refresh", 2, after);
assertTrue(empty.events.get(0) instanceof EnvironmentChangeEvent);
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:15,代码来源:RefreshEndpointTests.java
示例11: shutdownHooksCleaned
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Test
public void shutdownHooksCleaned() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(Empty.class)
.web(WebApplicationType.NONE).bannerMode(Mode.OFF).run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(context);
ContextRefresher contextRefresher = new ContextRefresher(context, scope);
RefreshEndpoint endpoint = new RefreshEndpoint(contextRefresher);
int count = countShutdownHooks();
endpoint.refresh();
int after = countShutdownHooks();
assertEquals("Shutdown hooks not cleaned on refresh", count, after);
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:14,代码来源:RefreshEndpointTests.java
示例12: refreshScope
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public static RefreshScope refreshScope() {
return new RefreshScope();
}
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-mesos,代码行数:6,代码来源:TestConfig.java
示例13: contextRefresher
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Bean
public ContextRefresher contextRefresher(ConfigurableApplicationContext context,
RefreshScope scope) {
return new ContextRefresher(context, scope);
}
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:6,代码来源:ZookeeperPropertySourceLocatorTests.java
示例14: ContextRefresher
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
public ContextRefresher(ConfigurableApplicationContext context, RefreshScope scope) {
this.context = context;
this.scope = scope;
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:5,代码来源:ContextRefresher.java
示例15: contextRefresher
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public ContextRefresher contextRefresher(ConfigurableApplicationContext context,
RefreshScope scope) {
return new ContextRefresher(context, scope);
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:7,代码来源:RefreshAutoConfiguration.java
示例16: RefreshScopeHealthIndicator
import org.springframework.cloud.context.scope.refresh.RefreshScope; //导入依赖的package包/类
public RefreshScopeHealthIndicator(ObjectProvider<RefreshScope> scope,
ConfigurationPropertiesRebinder rebinder) {
this.scope = scope;
this.rebinder = rebinder;
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:6,代码来源:RefreshScopeHealthIndicator.java
注:本文中的org.springframework.cloud.context.scope.refresh.RefreshScope类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论