package poem.hexagon.boundary;

import org.requirementsascode.Model;
import org.requirementsascode.ModelRunner;

import poem.hexagon.boundary.drivenport.IObtainPoems;
import poem.hexagon.boundary.drivenport.IWriteLines;
import poem.hexagon.boundary.driverport.IReactToCommands;
import poem.hexagon.internal.commandhandler.DisplayRandomPoem;

/**
 * The boundary class is the only point of communication with left-side driver
 * adapters. It accepts commands, and calls the appropriate command handler.
 * 
 * On creation, this class wires up the dependencies between command types and
 * command handlers, by injecting the command handlers into a use case model.
 * 
 * After creation, this class sends each command it receives to the runner
 * of the use case model. The model runner then dispatches the command to the
 * appropriate command handler, which in turn calls the driven adapters.
 * 
 * Inspired by a talk by A. Cockburn and T. Pierrain on hexagonal architecture:
 * https://www.youtube.com/watch?v=th4AgBcrEHA
 * 
 * @author b_muth
 *
 */
public class Boundary implements IReactToCommands {

	private ModelRunner modelRunner;

	public Boundary(IObtainPoems poetryLibrary, IWriteLines publishingDevice) {
		// Create a use case model
		Model model = buildModel(poetryLibrary, publishingDevice);
		
		// Run the use case model
		modelRunner = new ModelRunner().run(model);
	}

	private Model buildModel(IObtainPoems poetryLibrary, IWriteLines publishingDevice) {
		// Create the command handler(s)
		DisplayRandomPoem displayRandomPoem = new DisplayRandomPoem(poetryLibrary, publishingDevice);
		
		// Inject command handler(s) into use case model, to wire them up with command types.
		Model model = UseCaseModel.build(displayRandomPoem); 
		return model;
	}

	public void reactTo(Object commandObject) {
		modelRunner.reactTo(commandObject);
	}
}
@@ -1420,34 +1420,33 @@
 ainPoems poe
-tryLibrary
+mObtainer
 , IWriteLine
@@ -1447,32 +1447,26 @@
 teLines 
-publishingDevice
+lineWriter
 ) %7B%0A%09%09//
@@ -1565,36 +1565,29 @@
 (poe
-tryLibrary, publishingDevice
+mObtainer, lineWriter
 );%0A%09

Update Boundary.java