package com.randiantech;

import com.randiantech.utils.HttpServerConfiguration;
import com.randiantech.value.ErrorMessageBuilder;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Juan Carlos Cancela <juan.cancela@randiantech.com>
 */
public class Application
{

    private static ErrorMessageBuilder errorMessageBuilder = new ErrorMessageBuilder();
    private static Map<String, Connection> connections = new HashMap<String, Connection>();


    private void startHttpServer(String providedPort) throws Exception
    {
        Integer applicationPort = HttpServerConfiguration.getApplicationPort(providedPort);
        Server server = new Server(applicationPort);
        WebAppContext root = new WebAppContext();
        root.setContextPath(HttpServerConfiguration.getContextPath());
        root.setDescriptor(HttpServerConfiguration.getApplicationDescriptorPath());
        root.setResourceBase(HttpServerConfiguration.getWebApplicationDirectory());
        root.setParentLoaderPriority(true);
        server.setHandler(root);
        server.start();
        server.join();
    }

    private void registerDatabaseConnections(String databaseType){
            //connections.put(DatabaseType.valueOf(databaseType), DatabaseType.valueOf(databaseType).getConnection(null));
    }

    public void start(String providedPort) throws Exception{
        //registerDatabaseConnections(databaseType);
        startHttpServer(providedPort);
    }

    public static ErrorMessageBuilder getErrorMessageBuilder()
    {
        return errorMessageBuilder;
    }

    public static void setErrorMessageBuilder(ErrorMessageBuilder errorMessageBuilder)
    {
        Application.errorMessageBuilder = errorMessageBuilder;
    }

    public static Map<String, Connection> getConnections()
    {
        return connections;
    }
}

@@ -386,16 +386,48 @@
 tion%0A%7B%0A%0A
+    /* Error Message Builder */%0A
     priv
@@ -502,24 +502,55 @@
 eBuilder();%0A
+    %0A    /* Connections Map */%0A
     private 

Update Application.java