Fix creating Jetty server from config file
This commit is contained in:
parent
c087cb731e
commit
a943124d45
1 changed files with 8 additions and 5 deletions
|
@ -16,11 +16,12 @@
|
|||
|
||||
package helma.main;
|
||||
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.URLResourceFactory;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
import java.net.URL;
|
||||
|
@ -36,18 +37,20 @@ public class JettyServer {
|
|||
public static JettyServer init(Server server, ServerConfig config) throws IOException {
|
||||
File configFile = config.getConfigFile();
|
||||
if (configFile != null && configFile.exists()) {
|
||||
return new JettyServer(configFile.toURI().toURL());
|
||||
URLResourceFactory resourceFactory = new URLResourceFactory();
|
||||
Resource resource = resourceFactory.newResource(configFile.toURI());
|
||||
return new JettyServer(resource);
|
||||
} else if (config.hasWebsrvPort()) {
|
||||
return new JettyServer(config.getWebsrvPort(), server);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private JettyServer(URL url) throws IOException {
|
||||
private JettyServer(Resource resource) throws IOException {
|
||||
http = new org.eclipse.jetty.server.Server();
|
||||
|
||||
try {
|
||||
XmlConfiguration config = new XmlConfiguration(url);
|
||||
XmlConfiguration config = new XmlConfiguration(resource);
|
||||
config.configure(http);
|
||||
|
||||
} catch (IOException e) {
|
||||
|
@ -59,7 +62,7 @@ public class JettyServer {
|
|||
|
||||
private JettyServer(InetSocketAddress webPort, Server server)
|
||||
throws IOException {
|
||||
|
||||
|
||||
http = new org.eclipse.jetty.server.Server();
|
||||
|
||||
// start embedded web server if port is specified
|
||||
|
|
Loading…
Add table
Reference in a new issue