while(true)
{
try
{
/* Take the first applicationEvent and handle it. */
ApplicationEvent applicationEvent = blockingQueue.take();
/* If somehow the controller has received an unknown applicationEvent - stop the application. */
if(! eventStrategyMap.containsKey(applicationEvent.getClass()))
{
throw new RuntimeException();
}
/* Handle the event. */
eventStrategyMap.get(applicationEvent.getClass()).handle(applicationEvent);
}
catch(InterruptedException exception)
{
throw new RuntimeException();
}