commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1023473 - /commons/proper/daemon/trunk/src/samples/SimpleDaemon.java
Date Sun, 17 Oct 2010 12:22:31 GMT
Author: mturk
Date: Sun Oct 17 12:22:30 2010
New Revision: 1023473

URL: http://svn.apache.org/viewvc?rev=1023473&view=rev
Log:
Add sample usage for DaemonInitException. It will print that string instead stack trace

Modified:
    commons/proper/daemon/trunk/src/samples/SimpleDaemon.java

Modified: commons/proper/daemon/trunk/src/samples/SimpleDaemon.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/samples/SimpleDaemon.java?rev=1023473&r1=1023472&r2=1023473&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/samples/SimpleDaemon.java (original)
+++ commons/proper/daemon/trunk/src/samples/SimpleDaemon.java Sun Oct 17 12:22:30 2010
@@ -34,6 +34,7 @@ import java.util.Vector;
 import org.apache.commons.daemon.Daemon;
 import org.apache.commons.daemon.DaemonContext;
 import org.apache.commons.daemon.DaemonController;
+import org.apache.commons.daemon.DaemonInitException;
 
 public class SimpleDaemon implements Daemon, Runnable {
 
@@ -69,8 +70,13 @@ public class SimpleDaemon implements Dae
         int port=1200;
 
         String[] a = context.getArguments();
-
-        if (a.length>0) port=Integer.parseInt(a[0]);
+        try {
+            if ( a.length > 0)
+                port=Integer.parseInt(a[0]);
+        }
+        catch (NumberFormatException ex) {
+            throw new DaemonInitException("You must provide a number for port");
+        }
         if (a.length>1) this.directory=a[1];
         else this.directory="/tmp";
 



Mime
View raw message