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

📄 guimsg.java~1~

📁 通讯采集软件
💻 JAVA~1~
📖 第 1 页 / 共 4 页
字号:
                if (objs[0] instanceof factory) {
                  Set key_set = m_HashMap.keySet();
                  Object[] keyArray = key_set.toArray();
                  if (keyArray.length > 0) {
                    for (int i = 0; i < keyArray.length; i++) {
                      Object key = keyArray[i];
                      factory m_factory = (factory) (m_HashMap.get(key));
                      if (m_factory != null) {
                        CollectorDefine.m_HashFactory.put(key, m_factory);
                      }
                    }
                  }
                  keyArray = null;
                  key_set = null;
                }
              }
              System.out.println("***************    收到 参数检测 ----- 要factory");
              System.out.println("***************    准备初始化参数检测界面");
            }
            break;
          }
          case 2: {
            HashMap m_HashMap = (HashMap) object;
            if (m_HashMap != null) {
              Object[] objs = m_HashMap.values().toArray();
              if (objs.length > 0) {
                if (objs[0] instanceof computer) {
                  Set key_set = m_HashMap.keySet();
                  Object[] keyArray = key_set.toArray();
                  if (keyArray.length > 0) {
                    for (int i = 0; i < keyArray.length; i++) {
                      Object key = keyArray[i];
                      computer m_computer = (computer) (m_HashMap.get(key));
                      if (m_computer != null) {
                        CollectorDefine.m_HashComputer.put(key, m_computer);
                      }
                    }
                  }
                  keyArray = null;
                  key_set = null;
                }
              }
            }
            System.out.println("***************    收到 参数检测 ----- 要computer");
            break;
          }
          case 3: {
            HashMap m_HashMap = (HashMap) object;
            if (m_HashMap != null) {
              Object[] objs = m_HashMap.values().toArray();
              if (objs.length > 0) {
                if (objs[0] instanceof channel) {
                  Set key_set = m_HashMap.keySet();
                  Object[] keyArray = key_set.toArray();
                  if (keyArray.length > 0) {
                    for (int i = 0; i < keyArray.length; i++) {
                      Object key = keyArray[i];
                      channel m_channel = (channel) (m_HashMap.get(key));
                      if (m_channel != null) {
                        CollectorDefine.m_HashChannel.put(key, m_channel);
                      }
                    }
                  }
                  keyArray = null;
                  key_set = null;
                }
              }
            }
            System.out.println("***************    收到 参数检测 ----- 要channel");
            break;
          }
          case 4: {
            HashMap m_HashMap = (HashMap) object;
            if (m_HashMap != null) {
              Object[] objs = m_HashMap.values().toArray();
              if (objs.length > 0) {
                if (objs[0] instanceof terminal_server) {
                  Set key_set = m_HashMap.keySet();
                  Object[] keyArray = key_set.toArray();
                  if (keyArray.length > 0) {
                    for (int i = 0; i < keyArray.length; i++) {
                      Object key = keyArray[i];
                      terminal_server m_terminal_server = (terminal_server) (
                          m_HashMap.get(key));
                      if (m_terminal_server != null) {
                        CollectorDefine.m_HashTs.put(key, m_terminal_server);
                      }
                    }
                  }
                  keyArray = null;
                  key_set = null;
                }
              }
            }
            System.out.println(
                "***************    收到 参数检测 ----- 要terminal_server");
            break;
          }
          case 5: {
            HashMap m_HashMap = (HashMap) object;
            if (m_HashMap != null) {
              Object[] objs = m_HashMap.values().toArray();
              if (objs.length > 0) {
                if (objs[0] instanceof protocol) {
                  Set key_set = m_HashMap.keySet();
                  Object[] keyArray = key_set.toArray();
                  if (keyArray.length > 0) {
                    for (int i = 0; i < keyArray.length; i++) {
                      Object key = keyArray[i];
                      protocol m_protocol = (protocol) (m_HashMap.get(key));
                      if (m_protocol != null) {
                        CollectorDefine.m_HashProtocol.put(key, m_protocol);
                      }
                    }
                  }
                  keyArray = null;
                  key_set = null;
                }
              }
            }
            System.out.println("***************    收到 参数检测 ----- 要protocol");
            break;
          }
          case 6: { //jmsobject----fac_id

            ArrayList m_list = (ArrayList) object;
            if (m_list != null) {
              if (m_list.size() > 0) {
                for (int i = 0; i < m_list.size(); i++) {
                  Object m_obj = m_list.get(i);
                  if (m_obj instanceof terminal) {
                    terminal m_terminal = (terminal) m_obj;
                    CollectorDefine.m_HashTerminal.put(new Long(m_terminal.
                        getTerminalId()), m_terminal);
                    //System.out.println("@@@@@@@@@@@@@@@@@@  terminal_name = "+m_terminal.getTerminalName());
                  }
                }
              }
            }
            break;
          }
        }
      }

      else if (report_type == CollectorDefine.QUIT_JMS_TYPE) {

      }
      else if (report_type == CollectorDefine.RESET_JMS_TYPE) {

      }
      else if (report_type == CollectorDefine.LOGOUT_JMS_TYPE) {

      }
      else if (report_type == CollectorDefine.ALIVE_JMS_TYPE) {

      }
      else if (report_type == CollectorDefine.WRITE_CHREPORT_JMS_TYPE) {

      }
      else if (report_type == CollectorDefine.WRITE_REPORT_JMS_TYPE) {

      }
      else if (report_type == CollectorDefine.WRITE_EXPLAIN_JMS_TYPE) {

      }
      //wj add
      /*
           else if (report_type == CollectorDefine.CHANNEL_TASK_ASSIGN_JMS_TYPE) {
          if (CollectorDefine.CHANNEL_TASK_ASSIGN_FLAG == false) {
              return -1;
          }
          HashMap m_HashMap = (HashMap) object;
          Set key_set = m_HashMap.keySet();
          Object[] keyArray = key_set.toArray();
          if (keyArray.length > 0) {
              for (int i = 0; i < keyArray.length; i++) {
                  Object key = keyArray[i];
                  computer m_computer = (computer) (m_HashMap.get(key));
                  if (m_computer != null) {
                      CollectorDefine.m_HashComputer.put(key, m_computer);
                  }
              }
          }
          keyArray = null;
          key_set = null;
          m_HashMap = null;
          if (FrontGuiDefine.m_FrontFrame != null) {
              if (this.InitFinished == true) {
                  FrontGuiDefine.m_FrontFrame.initComputersPanel(true);
              }
          }
          if (FrontGuiDefine.m_TaskAssignFrame != null) {
              FrontGuiDefine.m_TaskAssignFrame.initComputers();
              FrontGuiDefine.m_TaskAssignFrame.initLocalList();
          }
                   }
       */
      else if (report_type == CollectorDefine.CHANNEL_TASK_ASSIGN_JMS_TYPE) {
        if (CollectorDefine.CHANNEL_TASK_ASSIGN_FLAG == false) {
          CFunction.writeLog("guirec","Error in guimsg error #1",null);
          return -1;
        }
        computer m_computer = (computer) object;
        if (m_computer != null) {
          CollectorDefine.m_HashComputer.put(new Long(m_computer.getComputerId()),
                                             m_computer);
        }
        if (FrontGuiDefine.m_FrontFrame != null) {
          if (this.InitFinished == true) {
            if (CollectorDefine.LOGIN_FLAG == false) {
              FrontGuiDefine.m_FrontFrame.initComputersPanel(true);
            }
            else
               CFunction.writeLog("guirec","CollectorDefine.LOGIN_FLAG != false ",null);
          }
          else
            CFunction.writeLog("guirec","this.InitFinished != true ",null);
        }
        else
            CFunction.writeLog("guirec","Error in guimsg error #2",null);

        if (FrontGuiDefine.m_TaskAssignFrame != null) {
          FrontGuiDefine.m_TaskAssignFrame.initComputers();
          FrontGuiDefine.m_TaskAssignFrame.initLocalList();
        }
        else
          CFunction.writeLog("guirec","FrontGuiDefine.m_TaskAssignFrame == null",null);
      }

      //
      else if (report_type == CollectorDefine.TERMINAL_JMS_TYPE) {
        if (CollectorDefine.TERMINAL_FLAG == false) {
          return -1;
        }
        terminal m_terminal = (terminal) object;
        CollectorDefine.m_HashTerminal.put(new Long(terminalid), m_terminal);
        if (terminalid == PublicMethod.LastTerminalId) {
        }
      }
      else {
        CFunction.writeLog("guirec","run in TransGui Error #4 ",null);
      }
    }
    catch (Exception e) {
      CFunction.writeLog("guirec","run in TransGui Error #5 ",null);
      e.printStackTrace();
    }
    return 1;
  }

  public int initProcess() {
    initJms(CollectorDefine.APPSERVER_TYPE,
            CollectorDefine.JMS_INITIAL_CONTEXT_FACTORY,
            CollectorDefine.JMS_URL1, CollectorDefine.JMS_PORT1,
            CollectorDefine.JMS_URL2, CollectorDefine.JMS_PORT2,
            CollectorDefine.GUI_TOPICFACTORY, CollectorDefine.GUI_TOPIC);
// wj add
    initJms_1(CollectorDefine.APPSERVER_TYPE,
              CollectorDefine.JMS_INITIAL_CONTEXT_FACTORY,
              CollectorDefine.JMS_URL1, CollectorDefine.JMS_PORT1,
              CollectorDefine.JMS_URL2, CollectorDefine.JMS_PORT2,
              CollectorDefine.EVENT_TOPICFACTORY, CollectorDefine.EVENT_TOPIC);
//

    return 1;
  }

  public int initJms(String app_type,
                     String jms_init_context_factory,
                     String jms_url1, String jms_port1,
                     String jms_url2, String jms_port2,
                     String topicfactory, String tpoic) {
    this.m_jmsgui = new JmsSwitch(CollectorDefine.APPSERVER_CLUSTER);
    this.m_jmsgui.setJmsParam(app_type,
                              jms_init_context_factory,
                              jms_url1,
                              jms_port1,
                              jms_url2,
                              jms_port2);
    this.m_jmsgui.setJmsFrontParam(topicfactory,
                                   tpoic);
    this.m_jmsgui.setMachineSwitchWaitCounter(CollectorDefine.
                                              MACHINE_SWITCH_WAIT_COUNTER);
    if (this.m_jmsgui.initJmsSwitch() < 0) {
      CollectorDefine.SystemPrintln("initCollector In guimsg Error #1");
      return -1;
    }
    this.m_jmsgui.setGuiComputerFlag(true);
    return 1;
  }

  public int initJms_1(String app_type,
                       String jms_init_context_factory,
                       String jms_url1, String jms_port1,
                       String jms_url2, String jms_port2,
                       String topicfactory, String tpoic) {
    this.m_jmsswitch = new JmsSwitch(CollectorDefine.APPSERVER_CLUSTER);
    this.m_jmsswitch.setJmsParam(app_type,
                                 jms_init_context_factory,
                                 jms_url1,
                                 jms_port1,
                                 jms_url2,
                                 jms_port2);
    this.m_jmsswitch.setJmsFrontParam(topicfactory,
                                      tpoic);
    this.m_jmsswitch.setMachineSwitchWaitCounter(CollectorDefine.
                                                 MACHINE_SWITCH_WAIT_COUNTER);
    if (this.m_jmsswitch.initJmsSwitch() < 0) {
      CollectorDefine.SystemPrintln("initCollector In guimsg Error #1");
      return -1;
    }
    this.m_jmsswitch.setGuiComputerFlag(true);
    return 1;
  }

  /*
       private void adjustAlive() {
      if (CollectorDefine.ALIVE_FLAG == true) {
          CollectorDefine.ALIVE_FLAG = false;
          this.m_LastAliveTime = System.currentTimeMillis() / 1000;
      }
      this.m_nowTime = System.currentTimeMillis() / 1000;
      if (java.lang.Math.abs(m_nowTime - m_LastAliveTime) >
      CollectorDefine.MAX_COUNER_FOR_GUI) {
          CollectorDefine.QUIT_FLAG = true;
      }
       }
   */

  private boolean runflag = true;
  public boolean getFlag() {
    return this.runflag;
  }

  public void setFlag(boolean m_flag) {
    this.runflag = m_flag;
  }

  public void run() {
    ServerSocket ser = null;
    int no;
    int m_isLocal = CollectorDefine.AUTO_MODE;
    int flag = 0;
    long FiveMinute = 5 * 60 * 1000; //五分钟发一次==5*60*1000
    long currenttime = -1l;

    try {
      System.out.println("haha: ");
      resetAllFlag();
      resetFlag1();
      clearmsg();
      CollectorDefine.QUIT_FLAG = false;
      CollectorDefine.GUI_QUIT_FLAG = false;

      while (true) {
        while (runflag) {
          try {
            recMsgFromGui();
            currenttime = System.currentTimeMillis();
            if (currenttime % FiveMinute == 0) {
              //sendAliveMsg();
            }
          }
          catch (Exception e) {
            e.printStackTrace();
          }
          try {
            Thread.sleep(1000);
          }
          catch (Exception ee) {
          }
        }
        try {
          Thread.sleep(1000);
        }
        catch (Exception ee) {
        }
      }
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  public static void main(String[] args) {
    guimsg m_guimsg = null;
    try {
      m_guimsg = new guimsg(); //创建新线程
      m_guimsg.start();
    }
    catch (Exception e) {
      CFunction.writeLog("guirec","startTransGuiThread in Collector Error #1 ", e);
    }
    try {
      Thread.sleep(2000);
    }
    catch (Exception e) {
    }

    for (int i = 0; i < 100; i++) {
      try {
        Thread.sleep(200);
      }
      catch (Exception e) {
      }
    }
  }

}

⌨️ 快捷键说明

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