コード例 #1
0
ファイル: DynamicIP.java プロジェクト: ruralcdn/CDN_User
  @SuppressWarnings("deprecation")
  public void run() {
    System.out.println("Inside NewStack.DynamicIP: Starting DynamicIP");
    while (true) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      flag = true;
      startCheck = true;
      String localIP = detectPPP();
      if (!localIP.equals(controlIP)) {
        controlIP = localIP;
        String custodian = "";
        String[] splitInfo = controlIP.split(",");
        if (!splitInfo[0].equals("127.0.0.1")) {
          if (splitInfo[1].equals("y")) custodian = AppConfig.getProperty("User.Custodian.IP");
          else custodian = AppConfig.getProperty("User.Custodian.IP");

          try {
            Registry registry = LocateRegistry.getRegistry(custodian);

            // Changes by arvind
            if (oldIPAddressGPRS == null || (!oldIPAddressGPRS.equals(splitInfo[0]))) {
              ICustodian stub =
                  (ICustodian) registry.lookup(AppConfig.getProperty("User.Custodian.Service"));
              stub.infoIP(userId, splitInfo[0]);
              oldIPAddressGPRS = splitInfo[0];
            }

          } catch (Exception e) {
            e.printStackTrace();
            System.out.println(
                "Inside NewStack.DynamicIP: Error in locating service for Custodian");
            controlIP = "";
          }
        }
      }

      Status st = Status.getStatus();
      if (!st.executeQuery("select * from status")) {
        flag = false;
        System.out.println("Inside NewStack.DynamicIP: Nothing in Status file");
        suspend();
      }
    }
  }