You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.5 KiB
45 lines
1.5 KiB
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.Rest; |
|
import org.eclipse.jetty.server.Connector; |
|
import org.eclipse.jetty.server.Server; |
|
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; |
|
|
|
public class Application { |
|
|
|
public static void main(String[] args) throws Exception { |
|
var config = Configuration.setFile(new File("/tmp/config.json")); |
|
//startMailSystem(json); |
|
startWebserver(config); |
|
} |
|
|
|
private static void startWebserver(Configuration config) throws Exception { |
|
var server = new Server(); |
|
var connector = new ServerConnector(server); |
|
connector.setPort(config.serverPort()); |
|
|
|
SessionHandler sh = new SessionHandler(); |
|
server.setConnectors(new Connector[]{connector}); |
|
ServletContextHandler context = new ServletContextHandler(server, "/",sh,null,null,null); |
|
context.addServlet(Rest.class,"/api"); |
|
context.addServlet(Static.class,"/static/*"); |
|
|
|
server.start(); |
|
} |
|
|
|
private static void startMailSystem(JSONObject json) { |
|
MessageHandler forward = new Forwarder(json); |
|
new ImapClient(json) |
|
.addListener(forward) |
|
.start(); |
|
} |
|
}
|
|
|