001package org.nuxeo.webengine.gwt.codeserver; 002 003 004import com.google.gwt.dev.codeserver.CodeServer; 005import com.google.gwt.dev.codeserver.Options; 006import com.google.gwt.dev.codeserver.WebServer; 007 008public class CodeServerWrapper implements CodeServerLauncher { 009 010 WebServer server; 011 012 @Override 013 public void startup(String[] args) throws Exception { 014 Options options = new Options(); 015 016 if (!options.parseArgs(args)) { 017 throw new RuntimeException("Cannot parse gwt code server options"); 018 } 019 ClassLoader cl = Thread.currentThread().getContextClassLoader(); 020 Thread.currentThread().setContextClassLoader(CodeServerWrapper.class.getClassLoader()); 021 try { 022 server = CodeServer.start(options); 023 } finally { 024 Thread.currentThread().setContextClassLoader(cl); 025 } 026 } 027 028 @Override 029 public void shutdown() throws Exception { 030 if (server == null) { 031 return; 032 } 033 try { 034 server.stop(); 035 } finally { 036 server = null; 037 } 038 } 039 040}