// Path: services-infrastructure-eventstore/src/main/java/io/plumery/eventstore/EventStoreFactory.java
// public class EventStoreFactory {
//     private static Logger LOG = LoggerFactory.getLogger(EventStoreFactory.class);
//     private static final String LOCAL = "local";
//     private static final String JDBC = "jdbc";
// 
//     private String bootstrap;
// 
//     @JsonProperty
//     private String type = LOCAL;
// 
//     @JsonProperty
//     private DataSourceFactory database = new DataSourceFactory();
// 
//     public void setBootstrap(String bootstrap) {
//         this.bootstrap = bootstrap;
//     }
// 
//     public String getBootstrap() {
//         return bootstrap;
//     }
// 
//     public String getType() {
//         return type;
//     }
// 
//     public void setType(String type) {
//         this.type = type;
//     }
// 
//     public EventStore build(Environment environment, EventPublisher publisher, String eventsPackage) {
//         EventStore eventStore;
// 
//         if (type.equals(JDBC)) {
//             eventStore = buildJdbcEventStore(publisher, environment);
//         } else {
//             eventStore = new LocalEventStore(publisher);
//         }
// 
//         LOG.info("Configured EventStore ["+ eventStore.getClass().getSimpleName() +
//                 "] with Events Package [" + eventsPackage + "] and Publisher ["
//                 + publisher.getClass().getSimpleName() + "]");
// 
//         return eventStore;
//     }
// 
//     private EventStore buildJdbcEventStore(EventPublisher publisher, Environment environment) {
//         ManagedDataSource ds = database.build(environment.metrics(), "eventstore");
//         DBI jdbi = new DBIFactory().build(environment, database, "eventstore");
//         updateDatabaseSchema(ds);
//         EventStore eventStore = new JdbcEventStore(jdbi, environment.getObjectMapper(), publisher);
//         return eventStore;
//     }
// 
//     private void updateDatabaseSchema(ManagedDataSource ds) {
//         try {
//             try {
//                 CloseableLiquibase lq = new CloseableLiquibaseWithClassPathMigrationsFile(ds, "migrations.xml");
//                 lq.update("");
//                 lq.close();
//             } finally {
//                 if (ds != null) {
//                     ds.stop();
//                 }
//             }
//         } catch (SQLException e) {
//             throw new RuntimeException("Can not execute db migrations.", e);
//         } catch (LiquibaseException e) {
//             throw new RuntimeException("Can not execute db migrations.", e);
//         } catch (Exception e) {
//             throw new RuntimeException("Can not execute db migrations.", e);
//         }
//     }
// 
//     public DataSourceFactory getDataSourceFactory() {
//         return database;
//     }
// }
// 
// Path: services-infrastructure-messaging/src/main/java/io/plumery/messaging/CommandListenerFactory.java
// public class CommandListenerFactory {
//     @NotEmpty
//     @JsonProperty
//     private String boostrap;
// 
//     public String getBoostrap() {
//         return boostrap;
//     }
// 
//     public void setBoostrap(String boostrap) {
//         this.boostrap = boostrap;
//     }
// 
//     public CommandListener build(Environment environment,
//                                  EventPublisher applicationEventPublisher, Class aggregateRoot) {
//         KafkaCommandListener listener =
//                 new KafkaCommandListener(boostrap,
//                         environment.getName(),
//                         environment.getObjectMapper(),
//                         applicationEventPublisher,
//                         aggregateRoot.getSimpleName());
// 
//         environment.lifecycle().manage(listener);
// 
//         return listener;
//     }
// }
// 
// Path: services-infrastructure-messaging/src/main/java/io/plumery/messaging/EventPublisherFactory.java
// public class EventPublisherFactory {
//     @NotEmpty
//     @JsonProperty
//     private String bootstrap;
// 
//     public String getBootstrap() {
//         return bootstrap;
//     }
// 
//     public void setBootstrap(String bootstrap) {
//         this.bootstrap = bootstrap;
//     }
// 
//     public EventPublisher build(Environment environment) {
//         return new KafkaEventPublisher(bootstrap, environment.getObjectMapper());
//     }
// }
// 
// Path: services-infrastructure-messaging/src/main/java/io/plumery/messaging/kafka/KafkaConfigurationFactory.java
// public class KafkaConfigurationFactory {
//     @NotEmpty
//     @JsonProperty
//     private String bootstrap;
// 
//     public void setBootstrap(String bootstrap) {
//         this.bootstrap = bootstrap;
//     }
// 
//     public String getBootstrap() {
//         return bootstrap;
//     }
// }


import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import io.plumery.eventstore.EventStoreFactory;
import io.plumery.messaging.CommandListenerFactory;
import io.plumery.messaging.EventPublisherFactory;
import io.plumery.messaging.kafka.KafkaConfigurationFactory;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
package io.plumery.inventoryitem;



public class InventoryItemDomainConfiguration extends Configuration {
    @Valid
    @NotNull
    private EventStoreFactory eventStoreFactory;
    private CommandListenerFactory commandListenerFactory;
    private EventPublisherFactory eventPublisher;

    @Valid
    @NotNull
    private KafkaConfigurationFactory kafkaConfigurationFactory;

    @JsonProperty("eventStore")
    public EventStoreFactory getEventStoreFactory() {
        return eventStoreFactory;
    }

    @JsonProperty("eventStore")
    public void setEventStoreFactory(EventStoreFactory eventStoreFactory) {
        this.eventStoreFactory = eventStoreFactory;
    }

    public CommandListenerFactory getCommandListenerFactory() {
        return commandListenerFactory;
    }
    public EventPublisherFactory getEventPublisherFactory() {
        return eventPublisher;
    }

    @JsonProperty("kafka")
    public void setKafkaConfigurationFactory(KafkaConfigurationFactory kafkaConfigurationFactory) {
        this.kafkaConfigurationFactory = kafkaConfigurationFactory;

// Path: services-infrastructure-eventstore/src/main/java/io/plumery/eventstore/EventStoreFactory.java
// public class EventStoreFactory {
//     private static Logger LOG = LoggerFactory.getLogger(EventStoreFactory.class);
//     private static final String LOCAL = "local";
//     private static final String JDBC = "jdbc";
// 
//     private String bootstrap;
// 
//     @JsonProperty
//     private String type = LOCAL;
// 
//     @JsonProperty
//     private DataSourceFactory database = new DataSourceFactory();
// 
//     public void setBootstrap(String bootstrap) {
//         this.bootstrap = bootstrap;
//     }
// 
//     public String getBootstrap() {
//         return bootstrap;
//     }
// 
//     public String getType() {
//         return type;
//     }
// 
//     public void setType(String type) {
//         this.type = type;
//     }
// 
//     public EventStore build(Environment environment, EventPublisher publisher, String eventsPackage) {
//         EventStore eventStore;
// 
//         if (type.equals(JDBC)) {
//             eventStore = buildJdbcEventStore(publisher, environment);
//         } else {
//             eventStore = new LocalEventStore(publisher);
//         }
// 
//         LOG.info("Configured EventStore ["+ eventStore.getClass().getSimpleName() +
//                 "] with Events Package [" + eventsPackage + "] and Publisher ["
//                 + publisher.getClass().getSimpleName() + "]");
// 
//         return eventStore;
//     }
// 
//     private EventStore buildJdbcEventStore(EventPublisher publisher, Environment environment) {
//         ManagedDataSource ds = database.build(environment.metrics(), "eventstore");
//         DBI jdbi = new DBIFactory().build(environment, database, "eventstore");
//         updateDatabaseSchema(ds);
//         EventStore eventStore = new JdbcEventStore(jdbi, environment.getObjectMapper(), publisher);
//         return eventStore;
//     }
// 
//     private void updateDatabaseSchema(ManagedDataSource ds) {
//         try {
//             try {
//                 CloseableLiquibase lq = new CloseableLiquibaseWithClassPathMigrationsFile(ds, "migrations.xml");
//                 lq.update("");
//                 lq.close();
//             } finally {
//                 if (ds != null) {
//                     ds.stop();
//                 }
//             }
//         } catch (SQLException e) {
//             throw new RuntimeException("Can not execute db migrations.", e);
//         } catch (LiquibaseException e) {
//             throw new RuntimeException("Can not execute db migrations.", e);
//         } catch (Exception e) {
//             throw new RuntimeException("Can not execute db migrations.", e);
//         }
//     }
// 
//     public DataSourceFactory getDataSourceFactory() {
//         return database;
//     }
// }
// 
// Path: services-infrastructure-messaging/src/main/java/io/plumery/messaging/CommandListenerFactory.java
// public class CommandListenerFactory {
//     @NotEmpty
//     @JsonProperty
//     private String boostrap;
// 
//     public String getBoostrap() {
//         return boostrap;
//     }
// 
//     public void setBoostrap(String boostrap) {
//         this.boostrap = boostrap;
//     }
// 
//     public CommandListener build(Environment environment,
//                                  EventPublisher applicationEventPublisher, Class aggregateRoot) {
//         KafkaCommandListener listener =
//                 new KafkaCommandListener(boostrap,
//                         environment.getName(),
//                         environment.getObjectMapper(),
//                         applicationEventPublisher,
//                         aggregateRoot.getSimpleName());
// 
//         environment.lifecycle().manage(listener);
// 
//         return listener;
//     }
// }
// 
// Path: services-infrastructure-messaging/src/main/java/io/plumery/messaging/EventPublisherFactory.java
// public class EventPublisherFactory {
//     @NotEmpty
//     @JsonProperty
//     private String bootstrap;
// 
//     public String getBootstrap() {
//         return bootstrap;
//     }
// 
//     public void setBootstrap(String bootstrap) {
//         this.bootstrap = bootstrap;
//     }
// 
//     public EventPublisher build(Environment environment) {
//         return new KafkaEventPublisher(bootstrap, environment.getObjectMapper());
//     }
// }
// 
// Path: services-infrastructure-messaging/src/main/java/io/plumery/messaging/kafka/KafkaConfigurationFactory.java
// public class KafkaConfigurationFactory {
//     @NotEmpty
//     @JsonProperty
//     private String bootstrap;
// 
//     public void setBootstrap(String bootstrap) {
//         this.bootstrap = bootstrap;
//     }
// 
//     public String getBootstrap() {
//         return bootstrap;
//     }
// }


// Path: services-inventoryitem-domain/src/main/java/io/plumery/inventoryitem/InventoryItemDomainConfiguration.java
import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import io.plumery.eventstore.EventStoreFactory;
import io.plumery.messaging.CommandListenerFactory;
import io.plumery.messaging.EventPublisherFactory;
import io.plumery.messaging.kafka.KafkaConfigurationFactory;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

package io.plumery.inventoryitem;



public class InventoryItemDomainConfiguration extends Configuration {
    @Valid
    @NotNull
    private EventStoreFactory eventStoreFactory;
    private CommandListenerFactory commandListenerFactory;
    private EventPublisherFactory eventPublisher;

    @Valid
    @NotNull
    private KafkaConfigurationFactory kafkaConfigurationFactory;

    @JsonProperty("eventStore")
    public EventStoreFactory getEventStoreFactory() {
        return eventStoreFactory;
    }

    @JsonProperty("eventStore")
    public void setEventStoreFactory(EventStoreFactory eventStoreFactory) {
        this.eventStoreFactory = eventStoreFactory;
    }

    public CommandListenerFactory getCommandListenerFactory() {
        return commandListenerFactory;
    }
    public EventPublisherFactory getEventPublisherFactory() {
        return eventPublisher;
    }

    @JsonProperty("kafka")
    public void setKafkaConfigurationFactory(KafkaConfigurationFactory kafkaConfigurationFactory) {
        this.kafkaConfigurationFactory = kafkaConfigurationFactory;

        this.commandListenerFactory = new CommandListenerFactory();