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

📄 smscenter.java~155~

📁 短信网关发送接受平台。
💻 JAVA~155~
字号:
package smscenter;import cmpp12.*;import com.newpalm.smsgwapi.*;import com.newpalm.log.BatchLog;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author unascribed * @version 1.0 */import java.net.*;import java.io.*;public class SMSCenter extends Engine{    public SpConnector12 spConnector = null;    getIniString ini =null;    int logret = -1;    public SMSCenter() {        super("SMSCenter");        setDaemon(true);    }    public void run(){        ini = new getIniString();        ReadIni();        spConnector = new SpConnector12(Config.server_host,Config.server_port,Config.SocketTimeout,Config.Source_Addr,Config.Shared_Secret,Config.version,Config.LogFlag);        ActiveTest activeTest = new ActiveTest(spConnector);        SendThread send = new SendThread(spConnector);        GetDeliverThread getDeliverThread = new GetDeliverThread(spConnector);        GetFailedSms getFailedSms = new GetFailedSms();        GetNewSms getNewSms = new GetNewSms();        MoThread moThread = new MoThread();        WriteLog logThread = new WriteLog();        TempThread tempThread = new TempThread();        tempThread.startup() ;        try{            Thread.sleep(5000);        }catch(Exception e){}        while(isRunning()){            //双机热被线程            //System.out.println("读入config.ini文件 "+ReadIni());            System.out.println("-------短信发送接收平台-------SMSCenter1.0-------");            while(Config.isActive && !spConnector.ifConnected()){                System.out.println("Try to Connecte Gateway Socket Port :)");                connectGatewayCenter();                /*activeTest.startup();                send.startup() ;                getDeliverThread.startup() ;                getNewSms.startup() ;                getFailedSms.startup() ;                moThread.startup() ;                logThread.startup() ;*/                if(Config.IfConnected){                    System.out.println("Connecte Gateway Socket Port OK!");                }                try{                    sleep(TimeConfig.TIME_ONE_SECOND*5);                }catch(Exception e){                    System.out.println("Exception In SMSCenter.connectGatewayCenter() : "+e.toString() );                }            }                activeTest.startup();                send.startup() ;                getDeliverThread.startup() ;                getNewSms.startup() ;                getFailedSms.startup() ;                moThread.startup() ;                logThread.startup() ;            /*                监控各个线程            */            if(Config.isActive){                if(!activeTest.isAlive() || !activeTest.isRunning() ){                    try{                        activeTest.shutdown();                        activeTest.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString());                    }                    activeTest.startup();                }                if(!send.isAlive() || !send.isRunning() ){                    try{                        send.shutdown();                        send.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                    send.startup();                }                if(!getDeliverThread.isAlive() || !getDeliverThread.isRunning() ){                    try{                        getDeliverThread.shutdown();                        getDeliverThread.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                    getDeliverThread.startup();                }                if(!getNewSms.isAlive() || !getNewSms.isRunning() ){                    try{                        getNewSms.shutdown();                        getNewSms.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                    getNewSms.startup();                }                if(!getFailedSms.isAlive() || !getFailedSms.isRunning() ){                    try{                        getFailedSms.shutdown();                        getFailedSms.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                    getFailedSms.startup();                }                if(!moThread.isAlive() || !moThread.isRunning() ){                    try{                        moThread.shutdown();                        moThread.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                    moThread.startup();                }                if(!logThread.isAlive() || !logThread.isRunning()){                    try{                        logThread.shutdown();                        logThread.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                    logThread.startup();                }            }else{                if(activeTest.isAlive() || activeTest.isRunning() ){                    try{                        activeTest.shutdown();                        activeTest.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString());                    }                }                if(send.isAlive() || send.isRunning() ){                    try{                        send.shutdown();                        send.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                }                if(getDeliverThread.isAlive() || getDeliverThread.isRunning() ){                    try{                        getDeliverThread.shutdown();                        getDeliverThread.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                }                if(getNewSms.isAlive() || getNewSms.isRunning() ){                    try{                        getNewSms.shutdown();                        getNewSms.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                }                if(getFailedSms.isAlive() || getFailedSms.isRunning() ){                    try{                        getFailedSms.shutdown();                        getFailedSms.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                }                if(moThread.isAlive() || moThread.isRunning() ){                    try{                        moThread.shutdown();                        moThread.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                }                if(logThread.isAlive() || logThread.isRunning()){                    try{                        logThread.shutdown();                        logThread.interrupt();                        Thread.sleep(1500);                    }catch(Exception e){                        Config.LogPool.push("Exception In SmsCenter : "+e.toString() );                    }                }                if(spConnector.ifConnected() ){                    try{spConnector.logout();}catch(Exception ex){}                }            }            /*                监控各个线程            */            try{                    sleep(TimeConfig.TIME_ONE_SECOND*5);            }catch(Exception e){                    System.out.println("Exception In SMSCenter.run() : "+e.toString() );            }        }//        try{spConnector.logout();}catch(Exception ex){}//        System.out.println("logout");        BatchLog.stopWrite();//stop Api logs output    }    public boolean connectGatewayCenter(){            if(!spConnector.ifConnected()){//if being not logined, try to login                try{                    logret = spConnector.login();                    if(logret == 0){                        Config.IfConnected = true;                        System.out.println("Connect NewPlam Ok!");                    }else{                        Config.IfConnected = false;                    }                }catch(Exception e){                    Config.IfConnected = false;                    System.out.println("Connect NewPlam NotOk!!");                }            }        return Config.IfConnected;   }   public  boolean ReadIni(){   try{     System.out.println("-------短信发送接收平台-------SMSCenter1.0-------");     System.out.println("请不要用鼠标点击command窗口。如果点击了,请回车!");     if(ini.getString("[SERVER]","isActive").equals("true")){         Config.isActive = true;     }else{         Config.isActive = false;     }     System.out.println(" isActive :"+Config.isActive );     Config.log.log(" isActive :"+Config.isActive );     Config.Exe_Id = ini.getString("[SERVER]","Exe_Id");     System.out.println(" Exe_Id : "+Config.Exe_Id);     Config.log.log(" Exe_Id : "+Config.Exe_Id);     Config.odbcstring = ini.getString("[LOCALDB]","odbcstring") ;       System.out.println(" 数据库连接驱动 : "+ Config.odbcstring );       Config.log.log(" 数据库连接驱动 : "+ Config.odbcstring);     Config.db_host=ini.getString("[LOCALDB]","db_host");       System.out.println(" 数据库IP地址 : "+Config.db_host);       Config.log.log(" 数据库IP地址 : "+Config.db_host);     Config.db_name=ini.getString("[LOCALDB]","db_name");       System.out.println(" 数据库名称 : "+Config.db_name);       Config.log.log(" 数据库名称 : "+Config.db_name);     Config.db_user=ini.getString("[LOCALDB]","db_user");       System.out.println(" 数据库用户名 : "+Config.db_user);       Config.log.log(" 数据库用户名 : "+Config.db_user);     Config.db_password=ini.getString("[LOCALDB]","db_password");       System.out.println(" 数据库密码  : "+Config.db_password );       Config.log.log(" 数据库用户名 : "+Config.db_user);     //万维的认证     Config.server_host = ini.getString("[GETWAY]","server_host");       System.out.println(" 网关IP  : "+Config.server_host );       Config.log.log(" 网关IP  : "+Config.server_host );     Config.server_port = Integer.parseInt(ini.getString("[GETWAY]","server_port"));       System.out.println(" 网关端口  : "+Config.server_port );       Config.log.log(" 网关端口  : "+Config.server_port );     Config.Source_Addr = ini.getString("[GETWAY]","Source_Addr");       System.out.println(" 用户名  : "+Config.Source_Addr );       Config.log.log(" 用户名  : "+Config.Source_Addr );     Config.Shared_Secret=ini.getString("[GETWAY]","Shared_Secret");       System.out.println(" 密码  : "+Config.Shared_Secret );       Config.log.log(" 密码  : "+Config.Shared_Secret );     Config.AlterTel = ini.getString("[ERR]","AlterTel");       System.out.println("报警号码 :"+Config.AlterTel);     Config.ErrServiceId = ini.getString("[ERR]","FREE-HFCX");       System.out.println("");     return true;   }catch(Exception e){       e.printStackTrace() ;     return false;   }  }    public static void main(String[] args) {        SMSCenter SMSCenter1 = new SMSCenter();        SMSCenter1.startup() ;        while(true){            if(!Config.hasNoError){                try{                         SMSCenter1.shutdown();                         SMSCenter1.interrupt();                         Thread.sleep(1500);                         SMSCenter1.startup() ;                     }catch(Exception e){                         Config.LogPool.push("Exception In SmsCenter.main() : "+e.toString() );                    }            }            try{                Thread.sleep(1000*5);            }catch(Exception e){}        }    }}

⌨️ 快捷键说明

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