Hi, all.
Following is the source code for configureHierarchy method which is in SocketServer 
class.
The code I am in question is that when 7 and 8th line of code (including comment). 

When inetAddress.toString() gets executed, it returns /my.local.ip.number.
And then next line it searches for the index of "/".  Since toString method returns a 
string starting with "/", index will be set to zero.
Thus on the else clause, "String key = s.substring(0, i);".  The key variable will be 
set to blank.  
So, that is the reason why my File statement fails.  (c:/.lcf will be the formed 
string)

How is everybody coping with this, if you want to run the client from command line by 
passing the configuration file absolute path?

Thanks for your help!!



  // This method assumes that there is no hiearchy for inetAddress
  // yet. It will configure one and return it.
  Hierarchy configureHierarchy(InetAddress inetAddress) {
    cat.info("Locating configuration file for "+inetAddress);
    // We assume that the toSting method of InetAddress returns is in
    // the format hostname/d1.d2.d3.d4 e.g. torino/192.168.1.1
    String s = inetAddress.toString();
    int i = s.indexOf("/");
    if(i == -1) {
      cat.warn("Could not parse the inetAddress ["+inetAddress+
               "]. Using default hierarchy.");
      return genericHierarchy();
    } else {
      String key = s.substring(0, i);
      File configFile = new File(dir, key+CONFIG_FILE_EXT);
      if(configFile.exists()) {
        Hierarchy h = new Hierarchy(new RootCategory(Priority.DEBUG));
        hierarchyMap.put(inetAddress, h);
        
        new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h);

        return h;       
      } else {
        cat.warn("Could not find config file ["+configFile+"].");
        return genericHierarchy();
      }
    }
  }


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to