use of com.vip.saturn.embed.EmbeddedSaturn in project Saturn by vipshop.
the class EmbeddedSpringSaturnApplication method onApplicationEvent.
@Override
public void onApplicationEvent(ApplicationEvent event) {
try {
if (event instanceof ContextRefreshedEvent) {
ContextRefreshedEvent contextRefreshedEvent = (ContextRefreshedEvent) event;
applicationContext = contextRefreshedEvent.getApplicationContext();
if (embeddedSaturn == null) {
embeddedSaturn = new EmbeddedSaturn();
embeddedSaturn.setSaturnApplication(this);
embeddedSaturn.start();
}
} else if (event instanceof ContextClosedEvent) {
if (embeddedSaturn != null) {
embeddedSaturn.stopGracefully();
embeddedSaturn = null;
}
}
} catch (Exception e) {
logger.warn("exception happened on event: " + event, e);
if (!ignoreExceptions) {
throw new RuntimeException(e);
}
}
}
Aggregations