package com.michelboudreau.alternator;

public class AlternatorDBServer
{
    public static void main(final String[] args) throws Exception
    {
        int port = 9090;

        // TODO: Parse args for alternate port.
        AlternatorDB db = new AlternatorDB(port);
        db.start();

        System.out.println(
                String.format("AlternatorDB has started and is listening on port %d.", port));
    }
}

@@ -33,16 +33,38 @@
 nator;%0A%0A
+import java.io.File;%0A%0A
 public c
@@ -90,10 +90,378 @@
 rver
+ %7B%0A%0A    /**%0A     * Allow the database to be persisted to disk when the server shuts down.%0A     */%0A    private static final boolean sandboxStatusSaveToDisk = false;%0A    %0A    /**%0A     * Discard the database contents when the server shuts down.%0A     */%0A    private static final boolean sandboxStatusDiscardData = true;%0A    %0A    private static final int defaultPort = 9090;
 %0A
-%7B
 %0A   
@@ -526,160 +526,401 @@
 tion
+ %7B%0A
 %0A    
-%7B%0A        int port = 9090;%0A%0A        // TODO: Parse args for alternate port.%0A        AlternatorDB db = new AlternatorDB(port);%0A        db.start();%0A%0A
+    File persistenceFile = null;%0A        %0A        int port = defaultPort;%0A%0A        if (args.length %3E= 1) %7B%0A            String persistencePath = args%5B0%5D;%0A            persistenceFile = new File(persistencePath);%0A        %7D%0A        %0A        AlternatorDB db = new AlternatorDB(port, persistenceFile, sandboxStatusSaveToDisk);%0A        db.start();%0A%0A        if (persistenceFile != null) %7B%0A    
     
@@ -955,24 +955,28 @@
             
+  
+  
 String.forma
@@ -982,71 +982,892 @@
 at(%22
-AlternatorDB has started and is listening on port %25d.%22, port));
++++++ AlternatorDB loaded data from file: %25s%22, persistenceFile.getCanonicalPath()));%0A        %7D%0A        %0A        System.out.println(%0A                String.format(%22+++++ AlternatorDB has started and is listening on port %25d.%22, port));%0A%0A        if (persistenceFile != null) %7B%0A            System.out.println(%0A                    String.format(%22Press the Enter key to exit gracefully and save data to file: %25s%22, persistenceFile.getCanonicalPath()));%0A        %7D%0A        System.out.print(%22Use Control-C to force exit (without saving data changes): %22);%0A        String input = System.console().readLine();%0A%0A        System.out.println(%22----- AlternatorDB is shutting down...%22);%0A%0A        db.stop();%0A        %0A        if (persistenceFile != null) %7B%0A            System.out.println(%0A                    String.format(%22----- Data was saved to file: %25s%22, persistenceFile.getCanonicalPath()));%0A        %7D
 %0A   

Support a persistence file in executable JAR console operation.