/** * Returns a Configurer instance with default components configured, such as a {@link SimpleCommandBus} and * {@link SimpleEventBus}, indicating whether to {@code autoLocateConfigurerModules}. * * When {@code autoLocateConfigurerModules} is {@code true}, a ServiceLoader will be used to locate all declared * instances of type {@link ConfigurerModule}. Each of the discovered instances will be invoked, allowing it to * set default values for the configuration. * * @param autoLocateConfigurerModules flag indicating whether ConfigurerModules on the classpath should be * automatically retrieved. Should be set to {@code false} when using an * application container, such as Spring or CDI. * @return Configurer instance for further configuration. */ public static Configurer defaultConfiguration(boolean autoLocateConfigurerModules) { DefaultConfigurer configurer = new DefaultConfigurer(); if(autoLocateConfigurerModules) { ServiceLoader<ConfigurerModule> configurerModuleLoader = ServiceLoader.load(ConfigurerModule.class, configurer.getClass().getClassLoader()); List<ConfigurerModule> configurerModules = new ArrayList<>(); configurerModuleLoader.forEach(configurerModules::add); configurerModules.sort(Comparator.comparingInt(ConfigurerModule::order)); configurerModules.forEach(cm -> cm.configureModule(configurer)); } return configurer; }
return new DefaultConfigurer() .registerComponent(EntityManagerProvider.class, c -> entityManagerProvider) .registerComponent(TransactionManager.class, c -> transactionManager)
/** * Returns a Configurer instance with default components configured, such as a {@link SimpleCommandBus} and * {@link SimpleEventBus}. * * @return Configurer instance for further configuration. */ public static Configurer defaultConfiguration() { return new DefaultConfigurer(); }
/** * Returns a Configurer instance with default components configured, such as a {@link SimpleCommandBus} and * {@link SimpleEventBus}, indicating whether to {@code autoLocateConfigurerModules}. * * When {@code autoLocateConfigurerModules} is {@code true}, a ServiceLoader will be used to locate all declared * instances of type {@link ConfigurerModule}. Each of the discovered instances will be invoked, allowing it to * set default values for the configuration. * * @param autoLocateConfigurerModules flag indicating whether ConfigurerModules on the classpath should be * automatically retrieved. Should be set to {@code false} when using an * application container, such as Spring or CDI. * @return Configurer instance for further configuration. */ public static Configurer defaultConfiguration(boolean autoLocateConfigurerModules) { DefaultConfigurer configurer = new DefaultConfigurer(); if(autoLocateConfigurerModules) { ServiceLoader<ConfigurerModule> configurerModuleLoader = ServiceLoader.load(ConfigurerModule.class, configurer.getClass().getClassLoader()); List<ConfigurerModule> configurerModules = new ArrayList<>(); configurerModuleLoader.forEach(configurerModules::add); configurerModules.sort(Comparator.comparingInt(ConfigurerModule::order)); configurerModules.forEach(cm -> cm.configureModule(configurer)); } return configurer; }
return new DefaultConfigurer() .registerComponent(EntityManagerProvider.class, c -> entityManagerProvider) .registerComponent(TransactionManager.class, c -> transactionManager)
return new DefaultConfigurer() .registerComponent(EntityManagerProvider.class, c -> entityManagerProvider) .registerComponent(TransactionManager.class, c -> transactionManager)