org.mycore.frontend.servlets
Class MCRWebCLIContainer

java.lang.Object
  extended by org.mycore.frontend.servlets.MCRWebCLIContainer

 class MCRWebCLIContainer
extends Object

Is a wrapper class around command execution. Commands will be queued and executed in a seperate thread. All logging events in that thread are grabbed and can be retrieved by the getLogs method.

Since:
2.0
Author:
Thomas Scheffler (yagee)

Field Summary
(package private)  Future<Boolean> curFuture
           
 
Constructor Summary
MCRWebCLIContainer(List<MCRCommand> knownCommands, HttpSession session)
          Will instantiate this container with a list of supported commands.
 
Method Summary
 void addCommand(String cmd)
          Adds this cmd to the current command queue.
 LinkedList<String> getCommandQueue()
          Gets the current command queue.
 net.sf.json.JSONObject getLogs()
          Returns all logs that were grabbed in the command execution thread.
 boolean isRunning()
          Returns the status of the command execution thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

curFuture

Future<Boolean> curFuture
Constructor Detail

MCRWebCLIContainer

public MCRWebCLIContainer(List<MCRCommand> knownCommands,
                          HttpSession session)
Will instantiate this container with a list of supported commands.

Parameters:
knownCommands - commands that are supported by the web gui.
session - the current HttpSession of the usere using the gui.
Method Detail

addCommand

public void addCommand(String cmd)
Adds this cmd to the current command queue. The thread executing the commands will be started automatically if the queue was previously empty.

Parameters:
cmd - a valid String representation of a known MCRCommand

getCommandQueue

public LinkedList<String> getCommandQueue()
Gets the current command queue.

Returns:
the queue of commands yet to be processed

isRunning

public boolean isRunning()
Returns the status of the command execution thread.

Returns:
true if the thread is running

getLogs

public net.sf.json.JSONObject getLogs()
Returns all logs that were grabbed in the command execution thread. This method is backed by a queue that will be empty after the method returns.

Returns:
{"logs": {
    "logLevel": logLevel,
    "message": message,
    "exception": exception
}}