コード例 #1
0
  /** Invoked for received messages */
  private void handleMapMessage(final MapMessage message) {
    try {
      final String text = message.getString(JMSLogMessage.TEXT);
      Runnable action = null;

      // Create action, or handle the message right away

      // Alarm state change?
      if (JMSAlarmMessage.TEXT_STATE.equals(text)) {
        // Received a state update from server, reset timeout
        timeout_timer.reset();
        action = new UpdateAction(AlarmUpdateInfo.fromMapMessage(message));
        model.updateServerState(false);
      } else if (JMSAlarmMessage.TEXT_STATE_MAINTENANCE.equals(text)) {
        timeout_timer.reset();
        action = new UpdateAction(AlarmUpdateInfo.fromMapMessage(message));
        model.updateServerState(true);
      }
      // Idle messages in absence of 'real' traffic?
      else if (JMSAlarmMessage.TEXT_IDLE.equals(text)) {
        timeout_timer.reset();
        model.updateServerState(false);
      } else if (JMSAlarmMessage.TEXT_IDLE_MAINTENANCE.equals(text)) {
        timeout_timer.reset();
        model.updateServerState(true);
      }
      // Enable/disable?
      else if (JMSAlarmMessage.TEXT_ENABLE.equals(text)) {
        timeout_timer.reset();
        final String name = message.getString(JMSLogMessage.NAME);
        action = new EnableAction(name, true);
      } else if (JMSAlarmMessage.TEXT_DISABLE.equals(text)) {
        timeout_timer.reset();
        final String name = message.getString(JMSLogMessage.NAME);
        action = new EnableAction(name, false);
      }
      // Configuration change
      else if (JMSAlarmMessage.TEXT_CONFIG.equals(text)) {
        final String name = message.getString(JMSLogMessage.NAME);
        model.readConfig(name);
      }
      // Debug trigger
      else if (JMSAlarmMessage.TEXT_DEBUG.equals(text)) model.dump();

      if (action == null) return;
      // Queue or dispatch?
      synchronized (queue) {
        if (use_queue) {
          queue.execute(action);
          return;
        }
      }
      // else: Not using queue, and queue no longer locked
      action.run();
    } catch (Throwable ex) {
      Activator.getLogger().log(Level.SEVERE, "Message handler error", ex);
    }
  }
コード例 #2
0
 @Override
 public String toString() {
   return info.toString();
 }