public class RestaurantCenterJettyStarter {
public static void main(String[] args) {
long start = System.currentTimeMillis();
try {
// set up files and urls
// URL[] urls;
// {
// urls = RefreshingURLClassLoader.getReloadableUrls();
// }
// deal with classloader
// ClassLoader parent = Thread.currentThread().getContextClassLoader();
//
// eclipse will recompile the class. so I disable this
//
// for (int i = 0; i < files.length; i++) {
// File file = files[i];
// CompilingClassLoader ccl = new CompilingClassLoader(parent,
// file);
// ccl.start();
// parent = ccl;
// }
// URLClassLoader urlCloader = new RefreshingURLClassLoader(urls, parent);
// Thread.currentThread().setContextClassLoader(urlCloader);
// finally, start the server!
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
connector.setReuseAddress(false); //这样就不能重复启动同一个 jetty 了. jetty starter 不检查 端口是否被占用
server.setConnectors(new Connector[] { connector });
// WebAppContext wac4 = new WebAppContext("./chatty", "/chatty");
// WebAppContext wac = new WebAppContext("/s100-webdata/photo",
// "/photo");
// WebAppContext wac2 = new WebAppContext("/s100-webdata/photo",
// "/video");
WebAppContext wac3 = new WebAppContext("./web", "/RestaurantCenter");
// wac.setClassLoader(urlCloader);
// wac2.setClassLoader(urlCloader);
// wac3.setClassLoader(urlCloader);
// wac4.setClassLoader(urlCloader);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(new Handler[] { wac3, /* wac, wac2,wac4 */}); // the
// order
// doesn't
// matter
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { contexts, new DefaultHandler() });
server.setHandler(handlers);
server.start();
long duration = System.currentTimeMillis() - start;
System.out.println("启动 Jetty 服务器 in " + duration + "ms");
System.out.println("Web Service is @ http://localhost:8080/RestaurantCenter/RestaurantWebService?wsdl" );
} catch (Exception e) {
e.printStackTrace();
}
}
}
posted on 2009-06-12 15:15
冰是没有未来的,因为它的永恒 阅读(433)
评论(0) 编辑 收藏 所属分类:
java 、
tool