// Path: inventory-cmd-producer/src/main/java/org/myeslib/cmdproducer/routes/CommandsDataSetsRoute.java
// @AllArgsConstructor
// public class CommandsDataSetsRoute extends RouteBuilder {
// 
// 	final Gson gson;
// 	final String targetEndpoint;
// 	final Type commandType = new TypeToken<Command>() {}.getType();
// 
// 	final int datasetSize;
// 	final int delayBetweenDatasets;
// 	final int initialDelay;
// 
// 	public void configure() throws Exception {
// 
// 		fromF("dataset:createCommandDataset?initialDelay=%d", initialDelay)
// 				.routeId("dataset:createCommandsDataset")
// 				.startupOrder(1).autoStartup(true)
// 				.process(new MarshalProcessor()).to(targetEndpoint)
//                 .aggregate(constant(0), AggregationStrategies.useLatest()).completionSize(datasetSize)
//     			    .log("finished")
//     			    .log("will start next dataset")
//     			    .to("controlbus:route?routeId=dataset:increaseCommandsDataset&action=start")
// 				.end()
//     			;
// 
// 		fromF("dataset:increaseCommandDataset?initialDelay=%d", delayBetweenDatasets)
// 				.routeId("dataset:increaseCommandsDataset")
//                 .startupOrder(2).autoStartup(false)
// 				.process(new MarshalProcessor()).to(targetEndpoint)
// 				.aggregate(constant(0), AggregationStrategies.useLatest()).completionSize(datasetSize)
//                     .log("finished")
//                     .log("will start next dataset")
//                     .to("controlbus:route?routeId=dataset:decreaseCommandsDataset&action=start")
//                 .end();
// 				;
// 
// 		fromF("dataset:decreaseCommandDataset?initialDelay=%d", delayBetweenDatasets)
// 		        .routeId("dataset:decreaseCommandsDataset")
//                 .startupOrder(3).autoStartup(false)
// 				.process(new MarshalProcessor()).to(targetEndpoint)
//                 .aggregate(constant(0), AggregationStrategies.useLatest()).completionSize(datasetSize)
//                     .log("finished")
//                 .end();
// 		;
// 
// 	}
// 
// 	class MarshalProcessor implements Processor {
// 		@Override
// 		public void process(Exchange e) throws Exception {
// 			Command c = e.getIn().getBody(Command.class);
// 			String asJson = gson.toJson(c, commandType);
// 			e.getOut().setBody(asJson);
// 			e.getOut().setHeader(Exchange.CONTENT_TYPE, "application/json");
// 			e.getOut().setHeader(Exchange.HTTP_METHOD, constant("POST"));
// 		}
// 	}
// }
// 
// Path: inventory-aggregate-root/src/main/java/org/myeslib/example/SampleDomainGsonFactory.java
// public class SampleDomainGsonFactory {
// 	
// 	private final Gson gson;
// 	
// 	public SampleDomainGsonFactory() {
// 
// 		final RuntimeTypeAdapterFactory<AggregateRoot> aggregateRootAdapter = 
// 				RuntimeTypeAdapterFactory.of(AggregateRoot.class)
// 				.registerSubtype(InventoryItemAggregateRoot.class, InventoryItemAggregateRoot.class.getSimpleName());
// 
// 		final RuntimeTypeAdapterFactory<Command> commandAdapter = 
// 				RuntimeTypeAdapterFactory.of(Command.class)
// 				.registerSubtype(CreateInventoryItem.class, CreateInventoryItem.class.getSimpleName())
// 				.registerSubtype(IncreaseInventory.class, IncreaseInventory.class.getSimpleName())
// 				.registerSubtype(DecreaseInventory.class, DecreaseInventory.class.getSimpleName());
// 
// 		final RuntimeTypeAdapterFactory<Event> eventAdapter = 
// 				RuntimeTypeAdapterFactory.of(Event.class)
// 				.registerSubtype(InventoryItemCreated.class, InventoryItemCreated.class.getSimpleName())
// 				.registerSubtype(InventoryIncreased.class, InventoryIncreased.class.getSimpleName())
// 				.registerSubtype(InventoryDecreased.class, InventoryDecreased.class.getSimpleName());	
// 		
// 		
// 		this.gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT)
// 			.registerTypeAdapterFactory(aggregateRootAdapter)
// 			.registerTypeAdapterFactory(commandAdapter)
// 			.registerTypeAdapterFactory(eventAdapter)
// 			//.setPrettyPrinting()
// 			.create();
// 	
// 	}
// 
// 	public Gson create() {
// 		return gson;
// 	}
// 
// }


import javax.inject.Singleton;
import lombok.AllArgsConstructor;
import org.myeslib.cmdproducer.routes.CommandsDataSetsRoute;
import org.myeslib.example.SampleDomainGsonFactory;
import com.google.gson.Gson;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
package org.myeslib.cmdproducer;





@AllArgsConstructor
public class CmdProducerModule extends AbstractModule {

    int dataSetSize;
	int delayBetweenDataSets;
	int initialDelay;

	@Provides
	@Singleton
	public Gson gson() {
// Path: inventory-cmd-producer/src/main/java/org/myeslib/cmdproducer/routes/CommandsDataSetsRoute.java
// @AllArgsConstructor
// public class CommandsDataSetsRoute extends RouteBuilder {
// 
// 	final Gson gson;
// 	final String targetEndpoint;
// 	final Type commandType = new TypeToken<Command>() {}.getType();
// 
// 	final int datasetSize;
// 	final int delayBetweenDatasets;
// 	final int initialDelay;
// 
// 	public void configure() throws Exception {
// 
// 		fromF("dataset:createCommandDataset?initialDelay=%d", initialDelay)
// 				.routeId("dataset:createCommandsDataset")
// 				.startupOrder(1).autoStartup(true)
// 				.process(new MarshalProcessor()).to(targetEndpoint)
//                 .aggregate(constant(0), AggregationStrategies.useLatest()).completionSize(datasetSize)
//     			    .log("finished")
//     			    .log("will start next dataset")
//     			    .to("controlbus:route?routeId=dataset:increaseCommandsDataset&action=start")
// 				.end()
//     			;
// 
// 		fromF("dataset:increaseCommandDataset?initialDelay=%d", delayBetweenDatasets)
// 				.routeId("dataset:increaseCommandsDataset")
//                 .startupOrder(2).autoStartup(false)
// 				.process(new MarshalProcessor()).to(targetEndpoint)
// 				.aggregate(constant(0), AggregationStrategies.useLatest()).completionSize(datasetSize)
//                     .log("finished")
//                     .log("will start next dataset")
//                     .to("controlbus:route?routeId=dataset:decreaseCommandsDataset&action=start")
//                 .end();
// 				;
// 
// 		fromF("dataset:decreaseCommandDataset?initialDelay=%d", delayBetweenDatasets)
// 		        .routeId("dataset:decreaseCommandsDataset")
//                 .startupOrder(3).autoStartup(false)
// 				.process(new MarshalProcessor()).to(targetEndpoint)
//                 .aggregate(constant(0), AggregationStrategies.useLatest()).completionSize(datasetSize)
//                     .log("finished")
//                 .end();
// 		;
// 
// 	}
// 
// 	class MarshalProcessor implements Processor {
// 		@Override
// 		public void process(Exchange e) throws Exception {
// 			Command c = e.getIn().getBody(Command.class);
// 			String asJson = gson.toJson(c, commandType);
// 			e.getOut().setBody(asJson);
// 			e.getOut().setHeader(Exchange.CONTENT_TYPE, "application/json");
// 			e.getOut().setHeader(Exchange.HTTP_METHOD, constant("POST"));
// 		}
// 	}
// }
// 
// Path: inventory-aggregate-root/src/main/java/org/myeslib/example/SampleDomainGsonFactory.java
// public class SampleDomainGsonFactory {
// 	
// 	private final Gson gson;
// 	
// 	public SampleDomainGsonFactory() {
// 
// 		final RuntimeTypeAdapterFactory<AggregateRoot> aggregateRootAdapter = 
// 				RuntimeTypeAdapterFactory.of(AggregateRoot.class)
// 				.registerSubtype(InventoryItemAggregateRoot.class, InventoryItemAggregateRoot.class.getSimpleName());
// 
// 		final RuntimeTypeAdapterFactory<Command> commandAdapter = 
// 				RuntimeTypeAdapterFactory.of(Command.class)
// 				.registerSubtype(CreateInventoryItem.class, CreateInventoryItem.class.getSimpleName())
// 				.registerSubtype(IncreaseInventory.class, IncreaseInventory.class.getSimpleName())
// 				.registerSubtype(DecreaseInventory.class, DecreaseInventory.class.getSimpleName());
// 
// 		final RuntimeTypeAdapterFactory<Event> eventAdapter = 
// 				RuntimeTypeAdapterFactory.of(Event.class)
// 				.registerSubtype(InventoryItemCreated.class, InventoryItemCreated.class.getSimpleName())
// 				.registerSubtype(InventoryIncreased.class, InventoryIncreased.class.getSimpleName())
// 				.registerSubtype(InventoryDecreased.class, InventoryDecreased.class.getSimpleName());	
// 		
// 		
// 		this.gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT)
// 			.registerTypeAdapterFactory(aggregateRootAdapter)
// 			.registerTypeAdapterFactory(commandAdapter)
// 			.registerTypeAdapterFactory(eventAdapter)
// 			//.setPrettyPrinting()
// 			.create();
// 	
// 	}
// 
// 	public Gson create() {
// 		return gson;
// 	}
// 
// }


// Path: inventory-cmd-producer/src/main/java/org/myeslib/cmdproducer/CmdProducerModule.java
import javax.inject.Singleton;
import lombok.AllArgsConstructor;
import org.myeslib.cmdproducer.routes.CommandsDataSetsRoute;
import org.myeslib.example.SampleDomainGsonFactory;
import com.google.gson.Gson;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;

package org.myeslib.cmdproducer;





@AllArgsConstructor
public class CmdProducerModule extends AbstractModule {

    int dataSetSize;
	int delayBetweenDataSets;
	int initialDelay;

	@Provides
	@Singleton
	public Gson gson() {
        return new SampleDomainGsonFactory().create();