Sha256: f9e6353975bcf1dc634dcf22a6535d7a096e4b9e879560ff688bd329de8afa13

Contents?: true

Size: 1.84 KB

Versions: 12

Compression:

Stored size: 1.84 KB

Contents

import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.webapp.WebAppContext;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

public class JettyWarMain {

    public static void main(String[] args) throws Exception {
        if (args.length == 0) {
            throw new IllegalArgumentException("missing war file name");
        }

        // Ensure we have a "work" directory for the webapp
        if (System.getProperty("jetty.home") != null) {
            new File(System.getProperty("jetty.home"), "work").mkdirs();
        }

        WebAppContext webapp = new WebAppContext();
        webapp.setContextPath("/");
        webapp.setExtractWAR(true);
        webapp.setWar(args[0]);
        webapp.setDefaultsDescriptor(webdefaultPath());

        Server server = new Server();
        Connector connector = new SelectChannelConnector();
        connector.setPort(Integer.getInteger("jetty.port",8080).intValue());
        server.setConnectors(new Connector[]{connector});
        server.setHandler(webapp);
        server.start();
        server.join();
    }

    private static String webdefaultPath() throws Exception {
        String path = System.getProperty("jetty.home", System.getProperty("java.io.tmpdir")) + System.getProperty("file.separator") + "webdefault.xml";
        FileOutputStream out = new FileOutputStream(path);
        InputStream is = JettyWarMain.class.getResourceAsStream("/webdefault.xml");
        try {
            byte[] buf = new byte[4096];
            int bytesRead = 0;
            while ((bytesRead = is.read(buf)) != -1) {
                out.write(buf, 0, bytesRead);
            }
        } finally {
            is.close();
            out.close();
        }
        return path;
    }
}

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
warbler-1.4.5 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.4.4 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.4.3 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.4.2 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.4.1 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.4.0 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.4.0.beta2 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.4.0.beta1 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.3.8 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.3.7 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.3.6 ext/jetty/src/main/java/JettyWarMain.java
warbler-1.3.5 ext/jetty/src/main/java/JettyWarMain.java