KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > web > tool > Main


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.activemq.web.tool;
20
21 import org.mortbay.jetty.Connector;
22 import org.mortbay.jetty.Handler;
23 import org.mortbay.jetty.Server;
24 import org.mortbay.jetty.nio.SelectChannelConnector;
25 import org.mortbay.jetty.webapp.WebAppContext;
26
27
28 /**
29  * A simple bootstrap class for starting Jetty in your IDE using the local web application.
30  *
31  * @version $Revision: 426366 $
32  */

33 public class Main {
34     
35     public static final int PORT = 8080;
36
37     public static final String JavaDoc WEBAPP_DIR = "src/main/webapp";
38
39     public static final String JavaDoc WEBAPP_CTX = "/";
40
41     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
42         // now lets start the web server
43
int port = PORT;
44         if (args.length > 0) {
45             String JavaDoc text = args[0];
46             port = Integer.parseInt(text);
47         }
48         System.out.println("Starting Web Server on port: " + port);
49         Server server = new Server();
50         SelectChannelConnector connector = new SelectChannelConnector();
51         connector.setPort(port);
52         connector.setServer(server);
53         WebAppContext context = new WebAppContext();
54         
55         context.setResourceBase(WEBAPP_DIR);
56         context.setContextPath(WEBAPP_CTX);
57         context.setServer(server);
58         server.setHandlers(new Handler[]{context});
59         server.setConnectors(new Connector[]{connector});
60         server.start();
61         
62         System.out.println();
63         System.out.println("==============================================================================");
64         System.out.println("Started the ActiveMQ Console: point your web browser at http://localhost:" + port + "/");
65         System.out.println("==============================================================================");
66         System.out.println();
67     }
68 }
69
Popular Tags