Package kgp.jetty

Source Code of kgp.jetty.JettyRunner

package kgp.jetty;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.webapp.WebAppContext;

public class JettyRunner {

  public static final Log log = LogFactory.getLog(JettyRunner.class);
 
  public static void main(String... args){
    log.info("Starting server");
    Server server = new Server();
    SocketConnector connector = new SocketConnector();
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(8008);
    server.setConnectors(new Connector[] {connector});
   
    WebAppContext webAppContext = new WebAppContext("src/main/webapp", "/");
    webAppContext.setConfigurationClasses(new String[] {
        "org.mortbay.jetty.webapp.WebInfConfiguration",
        "org.mortbay.jetty.plus.webapp.EnvConfiguration",
        "org.mortbay.jetty.plus.webapp.Configuration",
        "org.mortbay.jetty.webapp.JettyWebXmlConfiguration"
    });
   
    server.addHandler(webAppContext);
   
    try {
      server.start();
      log.debug("Server started");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
TOP

Related Classes of kgp.jetty.JettyRunner

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.