⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cncmain.java~5~

📁 cnc网通小灵通网关接口源码
💻 JAVA~5~
📖 第 1 页 / 共 2 页
字号:
package cncgw;/** * <p>Title: 小灵通网关</p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: yy</p> * @author lxf * @version 1.0 */import java.io.*;import java.net.*;import java.util.*;import org.apache.log4j.*;import cncgw.xsms.*;import cncgw.log.*;import cncgw.parser.*;import cncgw.smdb.*;public class cncMain {  public cncMain()  {    init();  }  static cncgw.log.Logger log = null;  static xsms xsms = new xsms();  static conn_desc conn = new conn_desc();  static PrintStream feelog = null;  static PrintStream errorlog = null;  public static Properties props = new Properties();  public static Vector threads = new Vector();  public static Vector submits = new Vector();  public static Vector delivers = new Vector();  public static Vector messages = new Vector();  public static PoolManager poolmanager;  static int timeout = 0;  static int workers = 5;  static String ismghost = "";  static int ismgport = 0;  public static String icpid = "";  public static String icpphone = "";  static String icpauth = "";  static String system_id = "";  static String system_type = "";  static String interface_version = "10";  static byte ton = 0;  static byte npi = 0;  static String address_range = "";    /* print to stdout */  public static void p(String s) {    System.out.println(s);  }  public static void init()  {  }  public static void feelog(String s) {    LoggerManager.getFeeLogger().info(s);  }  public static void errorlog(String s) {    LoggerManager.getErrorLogger().error(s);  }  /* add by simon zhen on 24/07/02 to process telephone number */  /* convert a string to byte array,add a zero indicate end of string */  public static byte[] str2byte(String s,int maxlen) {    byte[] temp = s.getBytes();    int strlen = s.length();    if (strlen >= maxlen) strlen = maxlen-1; //more than maxlen will be cut down    byte[] result = new byte[strlen +1];    for (int i=0;i<strlen;i++) //move source to dest      result[i]=temp[i];    result[strlen] = 0; //add zero to end    return result;  }  /* Convert ucs2 to ascii */  public static String ucs2ascii(byte[] b){    byte[] buffer = new byte[b.length];    int j = 0;    for (int i=0;i<b.length;i++){      if (b[i]!=0){        if ( (b[i]>='0'&&b[i]<='9') ||             (b[i]>='a'&&b[i]<='z') ||             (b[i]>='A'&&b[i]<='Z') ||             (b[i]=='.')){      buffer[j++] = b[i];    }else{      buffer[j++] = ' ';    }      }    }    return new String(buffer).trim();  }  /* Split input string to string array according to cutLenth */  public static String[] split(String msg,int cutLength){    String[] ret = null;    String encoding = "UTF-16";    try {      int msgLength = msg.length();      byte[] b = msg.getBytes(encoding);      int orgLength = b.length;      int num =(int) Math.ceil((double) orgLength / (double) cutLength);      int uniLength = orgLength / num;      int remind = uniLength % 2;      if (remind!=0) uniLength++;      ret = new String[num];      byte[] temp = new byte[uniLength];      for (int i=0;i<num;i++){        for (int j=0;j<uniLength;j++){          if( (i * uniLength +j)< orgLength)            temp[j] = b[i * uniLength + j];        }        ret[i] = new String(temp,encoding);      }    }    catch( Exception e){    }    return ret;  }    /* load www-server.properties from java.home */  static void loadProps() throws IOException {    File f = new File    (System.getProperty("user.dir")+File.separator+    "conf"+File.separator+"ChinaCnc.properties");    if (f.exists()) {      InputStream is =new BufferedInputStream(new          FileInputStream(f));      props.load(is);      is.close();      String r = props.getProperty("timeout");      if (r != null) {        timeout = Integer.parseInt(r);      }      r = props.getProperty("workers");      if (r != null) {        workers = Integer.parseInt(r);      }      r = props.getProperty("ismghost");      if (r != null) {        ismghost = r;      }      r = props.getProperty("ismgport");      if (r != null) {        ismgport = Integer.parseInt(r);      }      r = props.getProperty("icpid");      if (r != null) {        icpid = r;      }      r = props.getProperty("icpphone");      if (r != null) {        icpphone = r;      }      r = props.getProperty("system_id");      if (r != null) {        system_id = r;      }      r = props.getProperty("interface_version");      if (r != null) {        interface_version = r;      }      r = props.getProperty("icpauth");      if (r != null) {        icpauth = r;      }      r = props.getProperty("driver");      if (r != null) {        PoolManager.driver = r;      }      r = props.getProperty("dburl");      if (r != null) {        PoolManager.url = r;      }      r = props.getProperty("dbuser");      if (r != null) {        PoolManager.user = r;      }      r = props.getProperty("dbpassword");      if (r != null) {        PoolManager.password = r;      }      r = props.getProperty("dbinitconn");      if (r != null) {        PoolManager.initconn = Integer.parseInt(r);      }      r = props.getProperty("dbmaxconns");      if (r != null) {              PoolManager.maxconns = Integer.parseInt(r);      }      r = props.getProperty("logintimeout");      if (r != null) {        PoolManager.logintimeout  = Integer.parseInt(r);      }    }        /* if no properties were specified, choose defaults */    if (feelog == null) {      p("记录日志到控制台");      feelog = System.out;    }    if (ismghost==null || ismghost.length()==0){      ismghost = "127.0.0.1";    }    if (icpid==null || icpid.length()==0){      icpid = "?????";    }    if (icpphone==null || icpphone.length()==0){      icpphone = "??????";    }    if (system_id==null || system_id.length()==0){      system_id = "310";    }    if (interface_version==null || interface_version.length()==0){      interface_version = "10";    }    if (icpauth==null || icpauth.length()==0){      icpauth = "?????";    }        poolmanager = PoolManager.getInstance();  }  static void printProps() {    p("网络连接超时设定="+timeout);    p("移动短信网关地址/域名="+ismghost);    p("移动短信网关端口="+ismgport);    p("服务提供商经营许可证编号="+icpid);    p("服务提供商特服号="+icpphone);    p("接口id="+system_id);    p("接口版本号="+interface_version);    p("数据库地址="+PoolManager.url);    p("数据库用户="+PoolManager.user);    p("数据库初始连接数="+PoolManager.initconn);    p("数据库最大连接数="+PoolManager.maxconns);  }  public static void main(String[] a) throws Exception {    loadProps();    printProps();    Connect();  //连接小灵通短信网关    System.out.println("绑定连接启动!");    ActiveTest At = new ActiveTest();    new Thread(At).start();  /* start connetion active test */    System.out.println("与小灵通网关交互启动!!");    Deliver deliverToDb = new Deliver();    new Thread(deliverToDb).start(); /* start process deliver request */    System.out.println("从发送数据库扫描发送信息启动!");    /* start put submit request from cnc_submit threads */    SubmitFromDb pp = new SubmitFromDb();    new Thread(pp).start();    System.out.println("向接受数据库放入接受信息启动!");//        SubmitDb submitdb = new SubmitDb();//        DeliverDb deliverdb = new DeliverDb();//        submitdb.updateHaveSent(2);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -