Make --spring-config to expect an external file

instead of a classpath file

Change-Id: Ia515bbf347a7bfdc779d389ac13b1a7b0020f955
diff --git a/core/Changes b/core/Changes
index 3590c21..383f2b0 100644
--- a/core/Changes
+++ b/core/Changes
@@ -3,6 +3,8 @@
 - Support token array in matchinfo (fixes #570; diewald)
 - Added user info web-service (solved #566)
 - Implemented configurable resource filters for search and match info APIs
+- Make --spring-config to expect an external file instead of a classpath file
+
 
 # version 0.69.3
 
diff --git a/core/src/main/java/de/ids_mannheim/korap/server/KustvaktBaseServer.java b/core/src/main/java/de/ids_mannheim/korap/server/KustvaktBaseServer.java
index a5d6bca..b072f3c 100644
--- a/core/src/main/java/de/ids_mannheim/korap/server/KustvaktBaseServer.java
+++ b/core/src/main/java/de/ids_mannheim/korap/server/KustvaktBaseServer.java
@@ -4,9 +4,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
-import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
 import java.security.NoSuchAlgorithmException;
 import java.util.Scanner;
 
@@ -20,10 +18,9 @@
 import org.eclipse.jetty.server.handler.ShutdownHandler;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
-import org.springframework.web.context.ContextLoaderListener;
-
 import org.glassfish.jersey.server.ServerProperties;
 import org.glassfish.jersey.servlet.ServletContainer;
+import org.springframework.web.context.ContextLoaderListener;
 
 import de.ids_mannheim.korap.config.KustvaktConfiguration;
 import de.ids_mannheim.korap.encryption.RandomCodeGenerator;
@@ -61,7 +58,7 @@
                     StringBuffer b = new StringBuffer();
 
                     b.append("Parameter description: \n")
-                            .append("--spring-config  <Spring XML configuration filename in classpath>\n")
+                            .append("--spring-config  <Spring XML configuration>\n")
                             .append("--port  <Server port number>\n")
                             .append("--help : This help menu\n");
                     System.out.println(b.toString());
@@ -103,9 +100,15 @@
         ServletContextHandler contextHandler =
                 new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
         contextHandler.setContextPath("/");
-        contextHandler.setInitParameter("contextConfigLocation",
-                "classpath:" + kargs.getSpringConfig());
-
+        if (kargs.getSpringConfig()!=null) {
+            contextHandler.setInitParameter("contextConfigLocation",
+                    "file:" + kargs.getSpringConfig());
+        }
+        else {
+            contextHandler.setInitParameter("contextConfigLocation",
+                    "classpath:" + kargs.getSpringConfig());
+        }
+        
         ServletContextListener listener = new ContextLoaderListener();
         contextHandler.addEventListener(listener);
         contextHandler.setInitParameter("adminToken", adminToken);