Skip to content
Snippets Groups Projects
Commit 778187e7 authored by Nikolaus Krismer's avatar Nikolaus Krismer
Browse files

added waiting thread for geoserver (now doing this in a separate

thread... see javadoc for more details)
parent ce87d209
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,8 @@ import org.slf4j.LoggerFactory;
public class StartupListener implements ServletContextListener {
private static final Logger LOGGER = LoggerFactory.getLogger(StartupListener.class.getName());
// Public methods
@Override
public void contextInitialized(final ServletContextEvent sce) {
LOGGER.info("Initializing context");
......@@ -24,15 +26,33 @@ public class StartupListener implements ServletContextListener {
// 4) Is the geoserver reachable?
// 5) Can we connect to the geoserver with given username/password?
final ConfigWeb config = ConfigurationContainer.getGlobalConfig();
final GeoserverHelper gh = new GeoserverHelper(config);
gh.waitForGeoserver();
gh.ensureEnvironment();
gh.performCleanup();
startGeoserverThread();
}
@Override
public void contextDestroyed(final ServletContextEvent sce) { }
// Private methods
/**
* Waits for geoserver and perform a cleanup.
* We do this in a separat thread so we do not get any problems if this webapp is hosted
* on the same servlet container as the geoserver (we have to do this, since there is no
* possibility to define an application startup order)
*/
private void startGeoserverThread() {
final Thread t = new Thread() {
@Override
public void run() {
final ConfigWeb config = ConfigurationContainer.getGlobalConfig();
final GeoserverHelper gh = new GeoserverHelper(config);
gh.waitForGeoserver();
gh.ensureEnvironment();
gh.performCleanup();
}
};
t.start();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment