package com.fenixinfotech.grizzly.framework.playpen;

import com.fenixinfotech.web.common.FrameworkServerBase;
import org.glassfish.grizzly.http.server.HttpHandler;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.grizzly.http.server.Request;
import org.glassfish.grizzly.http.server.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class GrizzlyFrameworkServer extends FrameworkServerBase
{
    private static final Logger logger = LoggerFactory.getLogger(GrizzlyFrameworkServer.class);

    public void runServer() throws IOException {
        HttpServer httpServer = HttpServer.createSimpleServer();
        httpServer.getServerConfiguration().addHttpHandler(new HttpHandler() {
                                                               public void service(Request requestm, Response response) throws Exception {
                                                                   final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.UK);
                                                                   final String date = format.format(new Date(System.currentTimeMillis()));
                                                                   response.setContentType("text/plain");
                                                                   response.setContentLength(date.length());
                                                                   response.getWriter().write(date);
                                                               }
                                                           },
                "/hello"
        );

        httpServer.start();
    }
}

@@ -149,173 +149,9 @@
 ver.
-HttpHandler;%0Aimport org.glassfish.grizzly.http.server.HttpServer;%0Aimport org.glassfish.grizzly.http.server.Request;%0Aimport org.glassfish.grizzly.http.server.Response
+*
 ;%0Aim
@@ -519,32 +519,36 @@
 rows IOException
+%0A   
  %7B%0A        HttpS
@@ -546,72 +546,452 @@
     
-HttpServer httpServer = HttpServer.createSimpleServer(
+runServer(defaultPort);%0A    %7D%0A%0A    public void runServer(int port) throws IOException%0A    %7B%0A        logger.info(%22starting grizzly framework server on port %7B%7D%22, port);%0A%0A        final NetworkListener listener = new NetworkListener(%22Grizzly%22, %22localhost%22, port);%0A        listener.setSecure(false);%0A%0A        HttpServer httpServer = new HttpServer();%0A        httpServer.addListener(listener
 );%0A
+%0A
        
+ final ServerConfiguration serverConfiguration =
  htt
@@ -1022,16 +1022,45 @@
 ration()
+;%0A        serverConfiguration
 .addHttp
@@ -1084,19 +1084,21 @@
 andler()
- %7B%0A
+%0A    
         
@@ -1111,32 +1111,43 @@
                 
+         %7B%0A
                 
@@ -1159,24 +1159,38 @@
             
+              
 public void 
@@ -1250,19 +1250,44 @@
 xception
- %7B%0A
+%0A                           
         
@@ -1290,32 +1290,34 @@
                 
+%7B%0A
                 
@@ -1343,24 +1343,28 @@
             
+    
 final Simple
@@ -1500,32 +1500,16 @@
         
-                
 final St
@@ -1624,32 +1624,16 @@
         
-   
-             
 response
@@ -1714,32 +1714,16 @@
         
-         
-       
 response
@@ -1756,32 +1756,16 @@
 gth());%0A
-                
         
@@ -1892,32 +1892,10 @@
     
-                %7D%0A      
+%7D%0A
     
@@ -1937,20 +1937,9 @@
     
-          %7D,
+%7D
 %0A   
@@ -1943,24 +1943,28 @@
         
+);%0A%0A
         
 %22/hello%22
@@ -1959,54 +1959,135 @@
     
-%22/hello%22%0A        );%0A%0A        httpServer.sta
+httpServer.start();%0A%0A        logger.info(%22bootstrap of grizzly framework server complete, running on http://localhost:%7B%7D%22, po
 rt
-(
 );%0A 

Add ability to override the port grizzly server starts on.