Example usage for org.springframework.integration.config IdGeneratorConfigurer generatorContextId

List of usage examples for org.springframework.integration.config IdGeneratorConfigurer generatorContextId

Introduction

In this page you can find the example usage for org.springframework.integration.config IdGeneratorConfigurer generatorContextId.

Prototype

Set generatorContextId

To view the source code for org.springframework.integration.config IdGeneratorConfigurer generatorContextId.

Click Source Link

Usage

From source file:org.springframework.integration.config.IdGeneratorConfigurer.java

public synchronized void onApplicationEvent(ApplicationContextEvent event) {
    ApplicationContext context = event.getApplicationContext();
    if (event instanceof ContextRefreshedEvent) {
        boolean contextHasIdGenerator = context.getBeanNamesForType(IdGenerator.class).length > 0;
        if (contextHasIdGenerator) {
            if (this.setIdGenerator(context)) {
                IdGeneratorConfigurer.generatorContextId.add(context.getId());
            }/*w ww . j  av  a2s.  c  om*/
        }
    } else if (event instanceof ContextClosedEvent) {
        if (IdGeneratorConfigurer.generatorContextId.contains(context.getId())) {
            if (IdGeneratorConfigurer.generatorContextId.size() == 1) {
                this.unsetIdGenerator();
            }
            IdGeneratorConfigurer.generatorContextId.remove(context.getId());
        }
    }
}