示例#1
0
  static {
    COConfigurationManager.addAndFireParameterListeners(
        new String[] {
          "Proxy.Data.Enable",
          "Proxy.Data.SOCKS.inform",
          "TCP.Listen.Port.Override",
          "Tracker Client No Port Announce",
          "network.transport.encrypted.use.crypto.port",
          "network.transport.encrypted.require",
          "network.transport.encrypted.fallback.incoming",
          "TCP.Listen.Port",
          "UDP.Listen.Port",
          "HTTP.Data.Listen.Port",
          "HTTP.Data.Listen.Port.Override",
          "HTTP.Data.Listen.Port.Enable",
          "Tracker Client Min Announce Interval"
        },
        new ParameterListener() {
          public void parameterChanged(String parameterName) {
            String port = computePortsForURL(false, true);
            String port_with_crypto = computePortsForURL(true, false);

            if (ports_for_url != null && (!ports_for_url.equals(port))) {

              synchronized (listeners) {

                // back off for a bit to prevent multiple config changes from causing
                // multiple firings

                if (listener_thread == null) {

                  listener_thread =
                      new AEThread2("TRTrackerUtils:listener", true) {
                        public void run() {
                          try {
                            Thread.sleep(30000);

                          } catch (Throwable e) {
                          }

                          synchronized (listeners) {
                            listener_thread = null;
                          }

                          for (Iterator it = listeners.iterator(); it.hasNext(); ) {

                            try {
                              ((TRTrackerUtilsListener) it.next()).announceDetailsChanged();

                            } catch (Throwable e) {

                              Debug.printStackTrace(e);
                            }
                          }
                        }
                      };

                  listener_thread.start();
                }
              }
            }

            ports_for_url = port;
            ports_for_url_with_crypto = port_with_crypto;
          }
        });
  }