private void dispatch(String[] commands, PrintWriter writer) {

        switch (commands[0]) { //first element of string array must be one of the accepted commands
            case AppConstants.ADD:
                if (commands.length != 3) {
                    LOG.warning("Insufficient number of parameters in ADD command");
                    break;
                }

                String clientName = commands[1];
                String portNumber = commands[2];
                int port = 0;
                try {
                    port = Integer.parseInt(portNumber);
                    boolean status = add(clientName, port);

                    if (status) {
                        writer.println(AppConstants.OK);
                    } else {
                        writer.println(AppConstants.ERROR);
                    }
                } catch (NumberFormatException nfe) {
                    LOG.warning("portNumber parameter was not an integer");
                }

                LOG.log(Level.INFO, "client request serviced: ADD {0} {1}", new Object[]{clientName, portNumber});
                break;
            case AppConstants.REMOVE:
                clientName = commands[1];

                remove(clientName);

                LOG.log(Level.INFO, "client request serviced: REMOVE {0}", clientName);
                break;
            case AppConstants.FIND:
                clientName = commands[1];
                int portNumberResult = find(clientName);

                if (portNumberResult == 0) {
                    writer.println(AppConstants.NOTFOUND);
                } else {
                    writer.println(AppConstants.FOUND + " " + portNumberResult);
                }

                LOG.log(Level.INFO, "client request serviced: FIND {0}", clientName);
                break;
            default:
                LOG.log(Level.WARNING, "Unknown command: {0}", commands[0]);
        }
    }