/***********************************************************************************************************************
 *
 * FixBro - an open source FIX broker (sell side) simulator
 * =========================================================
 *
 * Copyright (C) 2016 by Emilio Bosch Ferrando
 * https://github.com/embosfer
 *
 ***********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 ***********************************************************************************************************************/
package com.embosfer.fixbro.main;

import com.embosfer.fixbro.controller.OrderController;
import com.embosfer.fixbro.controller.OrderControllerImpl;
import com.embosfer.fixbro.controller.qfj.QFJAcceptor;
import com.embosfer.fixbro.controller.qfj.QFJApplication;
import com.embosfer.fixbro.model.state.Order;
import com.embosfer.fixbro.model.state.OrderBean;
import com.embosfer.fixbro.model.state.OrderBook;
import com.embosfer.fixbro.model.tags.OrdStatus;
import com.embosfer.fixbro.model.tags.OrdType;
import com.embosfer.fixbro.model.tags.Side;
import com.embosfer.fixbro.view.OrderView;

import javafx.application.Application;
import javafx.stage.Stage;
import quickfix.ConfigError;

/**
 * Starts the application and delegates to the actual JavaFX application. An
 * instance of this class will be created by JavaFX after having called
 * launch(args). FIXBro will create the actual application (view) and the
 * controller
 * 
 * @author embosfer
 *
 */
public class FIXBro extends Application {

	private Application view;

	public FIXBro() {
		OrderController controller = new OrderControllerImpl();
		view = new OrderView(controller);
	}

	public static void main(String[] args) throws ConfigError {
		// start accepting connections
		final QFJAcceptor acceptor = new QFJAcceptor("fixbro_qfj.cfg", new QFJApplication());
		acceptor.start();

		// add some fake orders into the order book
		Order order1 = new OrderBean();
		order1.setAvgPx(0D);
		order1.setClOrdID("1234");
		order1.setCumQty(0D);
		order1.setLeavesQty(1000D);
		order1.setOrderID("myOrderID");
		order1.setOrdType(OrdType.LIMIT);
		order1.setOrdStatus(OrdStatus.PENDING_NEW);
		order1.setOrigClOrdID("orig1234");
		order1.setPrice(1.35D);
		order1.setQty(1000D);
		order1.setSide(Side.BUY);
		order1.setSymbol("EUR/USD");
		OrderBook.getInstance().addOrder(order1);

		Order order2 = new OrderBean();
		order2.setAvgPx(0D);
		order2.setClOrdID("1235");
		order2.setCumQty(0D);
		order2.setLeavesQty(2000D);
		order2.setOrderID("myOrderID2");
		order2.setOrdType(OrdType.MARKET);
		order2.setOrdStatus(OrdStatus.NEW);
		order2.setOrigClOrdID("orig1235");
		order2.setQty(2000D);
		order2.setSide(Side.SELL);
		order2.setSymbol("EUR/USD");
		OrderBook.getInstance().addOrder(order2);

		// launch JavaFX
		launch(args);

		acceptor.stop();
	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		view.start(primaryStage);
	}
}

@@ -1152,16 +1152,42 @@
 .main;%0A%0A
+import java.util.Arrays;%0A%0A
 import c
@@ -1334,81 +1334,428 @@
 ler.
-qfj.QFJAcceptor;%0Aimport com.embosfer.fixbro.controller.qfj.QFJApplication
+er.processor.ExecutionReportProcessor;%0Aimport com.embosfer.fixbro.controller.er.processor.ExecutionReportProcessorImpl;%0Aimport com.embosfer.fixbro.controller.qfj.QFJAcceptor;%0Aimport com.embosfer.fixbro.controller.qfj.QFJApplicationIn;%0Aimport com.embosfer.fixbro.controller.qfj.QFJApplicationOut;%0Aimport com.embosfer.fixbro.controller.sender.DirectMessageSender;%0Aimport com.embosfer.fixbro.controller.sender.MessageSender
 ;%0Aim
@@ -2524,27 +2524,367 @@
 ew;%0A
-%0A%09public FIXBro() %7B
+%09private QFJAcceptor acceptor;%0A%0A%09public FIXBro() throws ConfigError %7B%0A%09%09// sending strategy: directly%0A%09%09MessageSender directSender = new DirectMessageSender();%0A%09%09acceptor = new QFJAcceptor(%22fixbro_qfj.cfg%22, new QFJApplicationIn(directSender));%0A%0A%09%09ExecutionReportProcessor erProcessor = new ExecutionReportProcessorImpl(Arrays.asList(new QFJApplicationOut()));
 %0A%09%09O
@@ -2935,16 +2935,27 @@
 lerImpl(
+erProcessor
 );%0A%09%09vie
@@ -3033,170 +3033,24 @@
 gs) 
-throws ConfigError %7B%0A%09%09// start accepting connections%0A%09%09final QFJAcceptor acceptor = new QFJAcceptor(%22fixbro_qfj.cfg%22, new QFJApplication());%0A%09%09acceptor.start();%0A
+%7B%0A%09%09// TEST DATA
 %0A%09%09/
@@ -3993,28 +3993,8 @@
 gs);
-%0A%0A%09%09acceptor.stop();
 %0A%09%7D%0A
@@ -4069,31 +4069,171 @@
 %7B%0A%09%09
-view.start(primaryStage
+acceptor.start(); // start accepting connections%0A%09%09view.start(primaryStage);%0A%09%7D%0A%0A%09@Override%0A%09public void stop() throws Exception %7B%0A%09%09super.stop();%0A%09%09acceptor.stop(
 );%0A%09

Refactor bootstrap