Android Open Source - student_travel_app Driver






From Project

Back to project page student_travel_app.

License

The source code is released under:

Apache License

If you think the Android project student_travel_app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package driver;
/*from   w w w . j  av  a 2s  .c  om*/
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;

import model.CommitHandler;
import model.Constant;
import model.QueryHandler;
import model.Setting;
import model.SignupHandler;
import model.VerifyHandler;
import util.Util;

import com.sun.net.httpserver.HttpServer;

public class Driver
{
  public static void main(String[] args)
  {
    int level = 1;
    String logFilesDir = null;
    PrintStream out = System.out;
    
    try
    {

      try
      {
        for (int i = 0; i < args.length; i++) 
        {
          if (args[i].equals("-l")) 
          {
            level = Integer.parseInt(args[++ i]);
          }
          else if (args[i].equals("-o")) 
          {
            logFilesDir = args[++i];
          }
        }
      }
      catch (NumberFormatException e)
      {
        e.printStackTrace();
        System.out.println(usage());
        System.exit(0);
      }
      
      if (logFilesDir != null)
      {
        File logDir = new File(logFilesDir);
        
        if (!logDir.exists())
        {
          System.out.println("Dir not exsit");
          System.out.println(usage());
          System.exit(0);
        }
        else
        {
          File logFile = new File(logFilesDir + "/" + System.currentTimeMillis() + ".log");
          logFile.createNewFile();
          out = new PrintStream(logFile);
        }
      }

      Util.init(out, level);
      
      HttpServer server = HttpServer.create(new InetSocketAddress(Setting.SIGNUP_PORT), 0);
      server.createContext("/signup", new SignupHandler());
      server.createContext("/verify", new VerifyHandler());
      server.createContext("/query", new QueryHandler());
      server.createContext("/commit", new CommitHandler());
          server.setExecutor(Executors.newFixedThreadPool(Constant.THREAD_POOL_SIZE));
          server.start();
          Util.Log(Constant.LOG_LEVEL_INFO, "Server start", "Driver");
    }
    catch (IOException e)
    {
      Util.Log(Constant.LOG_LEVEL_ERROR, e.getMessage(), "Driver");
    }    
  }
  
  private static String usage() 
  {
    return ("\n"
        + "Usage:  java -jar StudentTravelAppServer.jar [-l LEVEL -o LOG_FILES_DIR]"
        + "\n");
  }
}




Java Source Code List

com.piasy.simpletravel.AllPlanActivity.java
com.piasy.simpletravel.HotelDetailActivity.java
com.piasy.simpletravel.LaunchActivity.java
com.piasy.simpletravel.MapViewActivity.java
com.piasy.simpletravel.MyListViewAdapter.java
com.piasy.simpletravel.PopMenu.java
com.piasy.simpletravel.ScrollRefreshListView.java
com.piasy.simpletravel.SearchActivity.java
com.piasy.simpletravel.SettingActivity.java
com.piasy.simpletravel.SignupActivity.java
com.piasy.simpletravel.SimpleTravelApplication.java
com.piasy.simpletravel.SingledayPlanActivity.java
com.piasy.simpletravel.SpotDetailActivity.java
com.piasy.simpletravel.controller.Controller.java
com.piasy.simpletravel.dao.DBHelper.java
com.piasy.simpletravel.dao.DBManager.java
com.piasy.simpletravel.model.CommitModule.java
com.piasy.simpletravel.model.Constant.java
com.piasy.simpletravel.model.Flag.java
com.piasy.simpletravel.model.HotelSeacher.java
com.piasy.simpletravel.model.ListViewItems.java
com.piasy.simpletravel.model.LocationModule.java
com.piasy.simpletravel.model.PlanGenerator.java
com.piasy.simpletravel.model.RouteEntry.java
com.piasy.simpletravel.model.Setting.java
com.piasy.simpletravel.model.SignupModule.java
com.piasy.simpletravel.model.SpotsSeacher.java
com.piasy.simpletravel.model.VerifyModule.java
com.piasy.simpletravel.util.Util.java
dao.DBManager.java
driver.Driver.java
model.CommitHandler.java
model.Constant.java
model.QueryHandler.java
model.Setting.java
model.SignupHandler.java
model.VerifyHandler.java
parser.Driver.java
parser.HotelSeacher.java
util.Util.java