
/** On servlet startup, preload a few core resource bundles - to avoid first request locks*/
package org.greenstone.gsdl3;

import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
import jakarta.servlet.annotation.WebListener;
import java.util.Locale;
import java.util.Set;

@WebListener
public class ServletStartUpListener implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent sce) {

	System.err.println("in context initialized!!!");
	// All resources / locales your app needs
	// can we adapt these lists based on interface used, and common langs? maybe from global properties?

        Set<String> resources = Set.of("core_servlet_dictionary", "interface_default", "interface_aux_default",  "metadata_names");
        Set<String> langs = Set.of("en" );
	
        // Preload bundles
        org.greenstone.gsdl3.util.ResourceBundleManager.preloadBundles(resources, langs);
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        // Optional: cleanup code if needed
    }
}
