server setup refactor
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index 379a53f..41981d4 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -153,7 +153,7 @@
<goal>shade</goal>
</goals>
<configuration>
- <finalName>Kustvakt-core-${project.version}-light</finalName>
+ <finalName>Kustvakt-core-0.59.5-light</finalName>
<transformers>
<transformer>
<mainClass>de.ids_mannheim.korap.web.KustvaktBaseServer</mainClass>
diff --git a/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java b/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
index 03f051a..8dd27e3 100644
--- a/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
+++ b/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
@@ -25,11 +25,15 @@
* @author hanl
* @date 01/06/2015
*/
-public class KustvaktBaseServer {
+public abstract class KustvaktBaseServer {
public static void main (String[] args) throws Exception {
KustvaktConfiguration.loadLog4jLogger();
- KustvaktBaseServer server = new KustvaktBaseServer();
+ KustvaktBaseServer server = new KustvaktBaseServer() {
+ @Override
+ protected void setup() {
+ }
+ };
KustvaktArgs kargs = server.readAttributes(args);
if (kargs.config != null)
@@ -74,53 +78,11 @@
return kargs;
}
-
- public void runPreStart () {
- Set<Class<? extends BootableBeanInterface>> set = KustvaktClassLoader
- .loadSubTypes(BootableBeanInterface.class);
-
- List<BootableBeanInterface> list = new ArrayList<>(set.size());
- for (Class cl : set) {
- BootableBeanInterface iface;
- try {
- iface = (BootableBeanInterface) cl.newInstance();
- list.add(iface);
- }
- catch (InstantiationException | IllegalAccessException e) {
- continue;
- }
- }
- System.out.println("Found boot loading interfaces: " + list);
-
- while (!list.isEmpty()) {
- loop: for (BootableBeanInterface iface : new ArrayList<>(list)) {
- try {
- for (Class dep : iface.getDependencies()) {
- if (set.contains(dep))
- continue loop;
- }
- iface.load(BeansFactory.getKustvaktContext());
- list.remove(iface);
- set.remove(iface.getClass());
- System.out.println("Done with interface "
- + iface.getClass().getSimpleName());
- }
- catch (KustvaktException e) {
- // don't do anything!
- System.out.println("An error occurred in class "
- + iface.getClass().getSimpleName() + "!\n");
- System.exit(-1);
- }
- }
- }
- }
-
+ protected abstract void setup();
protected void startServer (KustvaktArgs kargs) {
- if (kargs.init) {
- runPreStart();
- AdminSetup.getInstance();
- }
+ if (kargs.init)
+ setup();
if (kargs.port == -1)
kargs.setPort(BeansFactory.getKustvaktContext().getConfiguration()