working on configuration

This commit is contained in:
2022-04-15 11:33:28 +02:00
parent 0b13726d25
commit 26df2e5654
12 changed files with 162 additions and 118 deletions

View File

@@ -3,7 +3,7 @@ package de.srsoftware.widerhall;
import de.srsoftware.widerhall.mail.Forwarder;
import de.srsoftware.widerhall.mail.ImapClient;
import de.srsoftware.widerhall.mail.MessageHandler;
import de.srsoftware.widerhall.web.Static;
import de.srsoftware.widerhall.web.Web;
import de.srsoftware.widerhall.web.Rest;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
@@ -11,18 +11,23 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.json.simple.JSONObject;
import java.io.File;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Application {
private static final Logger LOG = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) throws Exception {
var config = Configuration.setFile(new File("/tmp/config.json"));
var config = Configuration.instance();
// the following construct allows the initial config file to point to another config file, which is then loaded:
while (!config.configFile().equals(config.file())) config.load(config.configFile());
//startMailSystem(json);
startWebserver(config);
startWebserver();
}
private static void startWebserver(Configuration config) throws Exception {
private static void startWebserver() throws Exception {
var config = Configuration.instance();
var server = new Server();
var connector = new ServerConnector(server);
connector.setPort(config.serverPort());
@@ -31,7 +36,7 @@ public class Application {
server.setConnectors(new Connector[]{connector});
ServletContextHandler context = new ServletContextHandler(server, "/",sh,null,null,null);
context.addServlet(Rest.class,"/api");
context.addServlet(Static.class,"/static/*");
context.addServlet(Web.class,"/web/*");
server.start();
}