Reworked GroovyDirectoryServer into a proper class.
This commit is contained in:
parent
be4d89abff
commit
f2bc4b34d0
@ -1,13 +1,12 @@
|
|||||||
#!/usr/bin/env groovy
|
|
||||||
|
|
||||||
package com.jdbernard.net
|
package com.jdbernard.net
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Server
|
import org.eclipse.jetty.server.Server
|
||||||
import org.eclipse.jetty.servlet.*
|
import org.eclipse.jetty.servlet.*
|
||||||
import groovy.servlet.*
|
import groovy.servlet.*
|
||||||
|
|
||||||
|
public class GroovyDirectoryServer {
|
||||||
|
|
||||||
def startJetty(int port) {
|
public static void runJetty(int port) {
|
||||||
def server = new Server(port)
|
def server = new Server(port)
|
||||||
|
|
||||||
def handler = new ServletContextHandler(ServletContextHandler.SESSIONS)
|
def handler = new ServletContextHandler(ServletContextHandler.SESSIONS)
|
||||||
@ -23,11 +22,21 @@ def startJetty(int port) {
|
|||||||
|
|
||||||
server.handler = handler
|
server.handler = handler
|
||||||
server.start()
|
server.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
def port = 9002
|
||||||
|
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
println "Usage: webServer.groovy <port>"
|
port = 9002
|
||||||
|
println "Defaulting to port 9002" }
|
||||||
|
|
||||||
|
else try { port = args[0] as int }
|
||||||
|
catch(Exception e) {
|
||||||
|
println "Usage: GroovyDirectoryServer.grooy <port>"
|
||||||
System.exit(1) }
|
System.exit(1) }
|
||||||
|
|
||||||
println "Starting Jetty, press Ctrl-C to stop."
|
println "Starting Jetty on port $port, press Ctrl-C to stop."
|
||||||
startJetty(Integer.parseInt(args[0]))
|
runJetty(port)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user