align="justify"> * Time: 22:45
*
* @ author DoSOfRR
* / class ConsoleView implements ViewInterface {OutputStream os;
/ *
* Creates an console view.
*
* @ param os
* Specifies output stream that will be used to print messages.
* / ConsoleView (OutputStream os) {. os=os;
} ConsoleView () {
/ / System.out as default output stream .. os=System.out;
}
@ Overridevoid showDefault () throws IOException {. write («Welcome to server administration panel. n». getBytes ());. write (« nType "-help " to print help n ». getBytes ());
}
@ Overridevoid showHelp () throws IOException {. write (« nType "-start " to start server.». getBytes ());. write (« nType "-stop " to stop server.». getBytes ());. write (« nType "-restart " to restart server.». getBytes ());. write (« nType "-help " to get help.». getBytes ());
}
@ Overridevoid showMessage (String message) throws IOException {. write (message.getBytes ());
}
@ Overridevoid showAuthorize () throws IOException {new NotImplementedException ();
}
@ OverrideCommands readMessage (byte [] message) throws IOException {strmsg=new String (message); (strmsg) {«-start» : Return Commands.Start_Server; «-stop» : Return Commands.Stop_Server; «-help» : Return Commands.Help; «-restart» : Return Commands.Restart_Server;: return Commands.Undefined;
}
}
}com.gmail.dosofredriver.ajax.serviceserver.util.view;java.io.IOException;java.util.concurrent.BlockingQueue;java.util.concurrent.LinkedBlockingQueue;
/ **
* Date: 07.03.13
* Time: 21:47
*
* @ author DoSOfRR
* /
/ *
* This interface realizes view for admin panel. With that interface you can specify
* your view without changing Commander controller.
* / interface ViewInterface { messages=new LinkedBlockingQueue <> ();
/ *
* This method is used to show initial interface and / or message.
* Here you can write some tips for users, or send HTML form, for example.
* / void showDefault () throws IOException;
/ *
* Show help, that can describe commands, params etc.
* / void showHelp () throws IOException;
/ *
* Show some message that server send to user.
* / void showMessage (String message) throws IOException;
/ *
* Show authorize form / message.
* / void showAuthorize () throws IOException;
/ *