001    /*
002     * Copyright 2007-2008 The Kuali Foundation
003     * 
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     * http://www.opensource.org/licenses/ecl2.php
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.ken.util;
017    
018    import org.mortbay.jetty.Server;
019    import org.mortbay.jetty.deployer.WebAppDeployer;
020    
021    /**
022     * Starts up Jetty pointing to an existing installation location.
023     * This is useful for testing/debugging.  To use this class (with the default
024     * webapp dir location), generate a Quickstart in dist/ before running
025     * this class.
026     * Implementation derived from this discussion: http://www.nabble.com/Re:-Embedded-Jetty6-with-AXIS2-p8960637.html
027     * @author Kuali Rice Team (rice.collab@kuali.org)
028     */
029    public class NotificationServer {
030        public static void main(String[] args) throws Exception {
031            // default to quickstart location
032            String webappDir = "./dist/quickstart/webapps";
033            if (args.length > 0) {
034                webappDir = args[0];
035            }
036            int port = 8080;
037            if (args.length > 1) {
038                port = Integer.parseInt(args[1]);
039            }
040    
041            Server server = new Server(port);
042    
043            WebAppDeployer webAppDeployer = new WebAppDeployer();
044            webAppDeployer.setContexts(server);
045            webAppDeployer.setWebAppDir(webappDir);
046            webAppDeployer.setParentLoaderPriority(false); 
047            webAppDeployer.setExtract(true);
048    
049            server.addLifeCycle(webAppDeployer);
050    
051            server.setStopAtShutdown(true);
052            server.setSendServerVersion(true); 
053    
054            server.start();
055            server.join();
056        }
057    }