1 25 package org.objectweb.carol.rmi.util; 26 27 import org.objectweb.carol.util.configuration.TraceCarol; 28 29 30 34 public class PortNumber { 35 36 37 40 private PortNumber() { 41 42 } 43 44 50 public static int strToint(String portStr, String propertyName) { 51 int port = 0; 52 try { 53 port = Integer.parseInt(portStr); 54 } catch (NumberFormatException nfe) { 55 TraceCarol.error("Invalid port number for property '" + propertyName + "'. Value set was '" + portStr + "'. It should be 0(random) or greater than 0. Error : " + nfe.getMessage()); 56 } 57 if (port < 0) { 58 String errMsg = "Invalid port number for property '" + propertyName + "'. It should be 0(random) or greater than 0."; 59 TraceCarol.error(errMsg); 60 throw new IllegalArgumentException (errMsg); 61 } 62 if (port == 0) { 63 if (TraceCarol.isDebugJndiCarol()) { 64 TraceCarol.debugCarol("Port was 0, will use a random port"); 65 } 66 } 67 return port; 68 } 69 } 70 | Popular Tags |