|
|
@ -5,7 +5,6 @@ import org.springframework.context.ApplicationListener;
|
|
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Application content post processor.
|
|
|
|
* Application content post processor.
|
|
|
@ -18,13 +17,15 @@ public class ApplicationContentPostProcessor implements ApplicationListener<Cont
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ApplicationContext applicationContext;
|
|
|
|
private ApplicationContext applicationContext;
|
|
|
|
|
|
|
|
|
|
|
|
private AtomicBoolean executeOnlyOnce = new AtomicBoolean(Boolean.TRUE);
|
|
|
|
private boolean executeOnlyOnce = true;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
|
|
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
|
|
|
if (event.getApplicationContext().getParent() == null && executeOnlyOnce.get()) {
|
|
|
|
synchronized (ApplicationContentPostProcessor.class) {
|
|
|
|
applicationContext.publishEvent(new ApplicationCompleteEvent(this));
|
|
|
|
if (executeOnlyOnce) {
|
|
|
|
executeOnlyOnce.set(Boolean.FALSE);
|
|
|
|
applicationContext.publishEvent(new ApplicationCompleteEvent(this));
|
|
|
|
|
|
|
|
executeOnlyOnce = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|