com.yumfee.extremeworld.QuickStartServer.java Source code

Java tutorial

Introduction

Here is the source code for com.yumfee.extremeworld.QuickStartServer.java

Source

/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yumfee.extremeworld;

import org.apache.commons.httpclient.util.DateUtil;
import org.eclipse.jetty.server.Server;
import org.springside.modules.test.jetty.JettyFactory;
import org.springside.modules.test.spring.Profiles;

import com.yumfee.extremeworld.util.DateUtils;

/**
 * Jetty?Web, Console?.
 * 
 * @author calvin
 */
public class QuickStartServer {

    public static final int PORT = 8023;
    public static final String CONTEXT = "/";
    public static final String[] TLD_JAR_NAMES = new String[] { "sitemesh", "spring-webmvc", "shiro-web",
            "springside-core" };

    public static void main(String[] args) throws Exception {
        // Springprofile
        Profiles.setProfileAsSystemProperty(Profiles.DEVELOPMENT);

        System.out.println(DateUtils.getTodayBeginDate().toString());

        // ?Jetty
        Server server = JettyFactory.createServerInSource(PORT, CONTEXT);
        JettyFactory.setTldJarNames(server, TLD_JAR_NAMES);

        try {
            server.start();

            System.out.println("[INFO] Server running at http://localhost:" + PORT + CONTEXT);
            System.out.println("[HINT] Hit Enter to reload the application quickly");

            // ?.
            while (true) {
                char c = (char) System.in.read();
                if (c == '\n') {
                    JettyFactory.reloadContext(server);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }
}