com.infobip.testcontainers.InitializerBase Maven / Gradle / Ivy
package com.infobip.testcontainers;
import org.springframework.context.*;
import org.springframework.context.event.ContextClosedEvent;
import org.testcontainers.lifecycle.Startable;
import java.util.concurrent.atomic.AtomicReference;
public abstract class InitializerBase
implements ApplicationContextInitializer, ApplicationListener {
private final AtomicReference container = new AtomicReference<>();
protected void start(C container) {
this.container.set(container);
container.start();
}
@Override
public void onApplicationEvent(ContextClosedEvent event) {
C value = container.get();
if(value != null) {
value.stop();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy