Package ru.headhunter.smsengine.server

Source Code of ru.headhunter.smsengine.server.SMSEngineServer

package ru.headhunter.smsengine.server;

import org.apache.log4j.Logger;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.ServletHttpContext;

import ru.headhunter.smsengine.SerialPortSMSTransport;


/**
* <p>The launcher class for SMS Engine service.<p>
* <p>Usage: <code>SMSEngineServer &lt;comm-port&gt; &lt;http-port&gt;</code></p>
* <p>&lt;comm-port&gt; - communication port at which GSM modem connected<br/>
* &lt;http-port&gt; - HTTP port of SMS service</p>
* <p>The URL of Hessian service: <code>http://host:http-port/sms-engine/service</code>
* Also there is URL of controller page: <code>http://host:http-port/sms-engine/controller</code></p>
* @author alsor
*/
public class SMSEngineServer {
 
  private static Logger log = Logger.getLogger(SMSEngineServer.class);
 
  private static Server server;
 
  private static SerialPortSMSTransport engine;
 
  public static SerialPortSMSTransport getEngine() {
    return engine;
  }
 
  public static void main (String[] args) throws Exception {
    if (args.length < 2) {
      System.out.println("Usage: SMSEngineServer comm-port http-port");
      return;
    }
   
    engine = new SerialPortSMSTransport(args[0]);
    try {
      engine.openPort ();
    } catch (Exception e) {
      return;
    }
    engine.start();
   
    server = new Server();
    server.addListener(args[1]);
    ServletHttpContext context = (ServletHttpContext)server.getContext("/sms-engine");
    context.addServlet("SMSEngineServiceController", "/controller", "ru.headhunter.smsengine.server.SMSEngineServiceController");
    context.addServlet("SMSEngineService", "/service", "ru.headhunter.smsengine.server.SMSEngineService");
    server.start();
   
  }
 
  public static void shutdown() {
    engine.shutdown();
    try {
      server.stop();
    } catch (InterruptedException e) {
      log.warn("Jetty server stop exception", e);
    }
  }

}
TOP

Related Classes of ru.headhunter.smsengine.server.SMSEngineServer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.