package info.elexis.server.core.connector.elexis.internal;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import info.elexis.server.core.contrib.ApplicationShutdownRegistrar;
import info.elexis.server.core.contrib.IApplicationShutdownListener;

public class Activator implements BundleActivator {

	private Logger log = LoggerFactory.getLogger(Activator.class);

	private static BundleContext context;
	private static IApplicationShutdownListener iasl = new ApplicationShutdownListener();

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.
	 * BundleContext)
	 */
	public void start(BundleContext bundleContext) throws Exception {
		Activator.context = bundleContext;

//		new Timer().schedule(new TimerTask() {
//
//			@Override
//			public void run() {
//				Locale locale = Locale.getDefault();
//				String dbStoredLocale = ConfigService.INSTANCE.get(Preferences.CFG_LOCALE, null);
//				if (dbStoredLocale == null || !locale.toString().equals(dbStoredLocale)) {
//					log.error("System locale [{}] does not match required database locale [{}].", locale.toString(),
//							dbStoredLocale);
//					System.out.println("System locale does not match required database locale!");
//				}
//				// TOOD verify db version?
//			}
//		}, 1000);

		ApplicationShutdownRegistrar.addShutdownListener(iasl);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext bundleContext) throws Exception {
		ApplicationShutdownRegistrar.removeShutdownListener(iasl);

		Activator.context = null;
	}

}

@@ -53,16 +53,94 @@
 ernal;%0A%0A
+import java.util.Locale;%0Aimport java.util.Timer;%0Aimport java.util.TimerTask;%0A%0A
 import o
@@ -273,16 +273,133 @@
 ctory;%0A%0A
+import ch.elexis.core.constants.Preferences;%0Aimport info.elexis.server.core.connector.elexis.services.ConfigService;%0A
 import i
@@ -1000,18 +1000,16 @@
 ntext;%0A%0A
-//
 %09%09new Ti
@@ -1045,13 +1045,9 @@
 ) %7B%0A
-//%0A//
+%0A
 %09%09%09@
@@ -1055,18 +1055,16 @@
 verride%0A
-//
 %09%09%09publi
@@ -1074,26 +1074,24 @@
 oid run() %7B%0A
-//
 %09%09%09%09Locale l
@@ -1119,18 +1119,16 @@
 ault();%0A
-//
 %09%09%09%09Stri
@@ -1205,18 +1205,16 @@
  null);%0A
-//
 %09%09%09%09if (
@@ -1284,18 +1284,16 @@
 ale)) %7B%0A
-//
 %09%09%09%09%09log
@@ -1386,18 +1386,16 @@
 ring(),%0A
-//
 %09%09%09%09%09%09%09d
@@ -1410,18 +1410,16 @@
 ocale);%0A
-//
 %09%09%09%09%09Sys
@@ -1497,18 +1497,14 @@
 %22);%0A
-//
 %09%09%09%09%7D%0A
-//
 %09%09%09%09
@@ -1534,17 +1534,13 @@
 on?%0A
-//
 %09%09%09%7D%0A
-//
 %09%09%7D,

Revert "Remove Activator#checkLocale"