001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.activemq.tool; 018 019 import org.mortbay.jetty.Connector; 020 import org.mortbay.jetty.Server; 021 import org.mortbay.jetty.bio.SocketConnector; 022 import org.mortbay.jetty.webapp.WebAppContext; 023 024 /** 025 * @version $Revision$ 026 */ 027 public final class WebServer { 028 029 public static final int PORT = 8080; 030 // public static final String WEBAPP_DIR = "target/activemq"; 031 public static final String WEBAPP_DIR = "src/webapp"; 032 public static final String WEBAPP_CTX = "/"; 033 034 private WebServer() { 035 } 036 037 public static void main(String[] args) throws Exception { 038 Server server = new Server(); 039 Connector context = new SocketConnector(); 040 context.setServer(server); 041 context.setPort(PORT); 042 043 String webappDir = WEBAPP_DIR; 044 if (args.length > 0) { 045 webappDir = args[0]; 046 } 047 048 WebAppContext webapp = new WebAppContext(); 049 webapp.setServer(server); 050 webapp.setContextPath(WEBAPP_CTX); 051 webapp.setResourceBase(webappDir); 052 053 server.setHandler(webapp); 054 055 server.setConnectors(new Connector[] { 056 context 057 }); 058 server.start(); 059 060 } 061 }