package com.axiomalaska.sos.injector.db;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.axiomalaska.sos.SosInjector;

public class DatabaseSosInjector {
    private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseSosInjector.class);
    private static final String MOCK = "mock";
    
    public static void main(String[] args){
        if (args.length > 0) {
            String configFile = args[0];
            DatabaseSosInjectorConfig.initialize(configFile);
        }

        try {        
            SosInjector sosInjector = null;
            if (System.getProperty(MOCK) != null) {
                //mock
                sosInjector = SosInjector.mock("mock-database-sos-injector",
                        new DatabaseStationRetriever(),
                        new DatabaseObservationRetriever(),
                        true);
                LOGGER.info("Mock SosInjector initialized");
            } else {
                sosInjector = new SosInjector("database-sos-injector",
                        DatabaseSosInjectorConfig.instance().getSosUrl(),
                        DatabaseSosInjectorConfig.instance().getSosAuthenticationToken(),
                        DatabaseSosInjectorConfig.instance().getPublisherInfo(),            
                        new DatabaseStationRetriever(),
                        new DatabaseObservationRetriever(),
                        null);
                
            }
            if (sosInjector == null) {
                throw new NullPointerException("sosInjector is null");
            }
            sosInjector.update();
        } catch (Exception e) {
            LOGGER.error("Sos injection failed", e);
        }
    }
}
@@ -35,16 +35,55 @@
 or.db;%0A%0A
+import java.util.concurrent.TimeUnit;%0A%0A
 import o
@@ -171,16 +171,57 @@
 njector;
+%0Aimport com.google.common.base.Stopwatch;
 %0A%0Apublic
@@ -583,16 +583,81 @@
      %7D%0A%0A
+        Stopwatch stopwatch = Stopwatch.createStarted();        %0A
         
@@ -661,32 +661,36 @@
    try %7B        
+    
 %0A            Sos
@@ -1721,32 +1721,33 @@
 ;%0A            %7D%0A
+%0A
             sosI
@@ -1764,16 +1764,118 @@
 date();%0A
+            LOGGER.info(%22SOS injection finished in %7B%7D seconds%22, stopwatch.elapsed(TimeUnit.SECONDS));%0A
         
@@ -1944,17 +1944,71 @@
 n failed
-%22
+ after %7B%7D seconds%22, stopwatch.elapsed(TimeUnit.SECONDS)
 , e);%0A  

Add stopwatch to log output and a finished message