use of io.quarkus.agroal.spi.JdbcInitialSQLGeneratorBuildItem in project quarkus by quarkusio.
the class HibernateOrmProcessor method handleGenerateSqlForPu.
private void handleGenerateSqlForPu(BuildProducer<DevConsoleRuntimeTemplateInfoBuildItem> runtimeInfoProducer, BuildProducer<JdbcInitialSQLGeneratorBuildItem> initialSQLGeneratorBuildItemBuildProducer, String puName, String dsName, CurateOutcomeBuildItem curateOutcomeBuildItem) {
DevConsoleRuntimeTemplateInfoBuildItem devConsoleRuntimeTemplateInfoBuildItem = new DevConsoleRuntimeTemplateInfoBuildItem("create-ddl." + puName, new HibernateOrmDevConsoleCreateDDLSupplier(puName), this.getClass(), curateOutcomeBuildItem);
runtimeInfoProducer.produce(devConsoleRuntimeTemplateInfoBuildItem);
initialSQLGeneratorBuildItemBuildProducer.produce(new JdbcInitialSQLGeneratorBuildItem(dsName, new Supplier<String>() {
@Override
public String get() {
return DevConsoleManager.getTemplateInfo().get(devConsoleRuntimeTemplateInfoBuildItem.getGroupId() + "." + devConsoleRuntimeTemplateInfoBuildItem.getArtifactId()).get(devConsoleRuntimeTemplateInfoBuildItem.getName()).toString();
}
}));
}
use of io.quarkus.agroal.spi.JdbcInitialSQLGeneratorBuildItem in project quarkus by quarkusio.
the class FlywayProcessor method createBeansAndStartActions.
@BuildStep
@Consume(LoggingSetupBuildItem.class)
@Record(ExecutionTime.RUNTIME_INIT)
ServiceStartBuildItem createBeansAndStartActions(FlywayRecorder recorder, List<JdbcDataSourceBuildItem> jdbcDataSourceBuildItems, List<JdbcInitialSQLGeneratorBuildItem> sqlGeneratorBuildItems, BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<SyntheticBeanBuildItem> syntheticBeanBuildItemBuildProducer, BuildProducer<JdbcDataSourceSchemaReadyBuildItem> schemaReadyBuildItem, MigrationStateBuildItem migrationsBuildItem) {
// make a FlywayContainerProducer bean
additionalBeans.produce(AdditionalBeanBuildItem.builder().addBeanClasses(FlywayContainerProducer.class).setUnremovable().setDefaultScope(DotNames.SINGLETON).build());
// add the @FlywayDataSource class otherwise it won't registered as a qualifier
additionalBeans.produce(AdditionalBeanBuildItem.builder().addBeanClass(FlywayDataSource.class).build());
recorder.resetFlywayContainers();
Collection<String> dataSourceNames = getDataSourceNames(jdbcDataSourceBuildItems);
for (String dataSourceName : dataSourceNames) {
boolean hasMigrations = migrationsBuildItem.hasMigrations.contains(dataSourceName);
boolean createPossible = false;
if (!hasMigrations) {
createPossible = sqlGeneratorBuildItems.stream().anyMatch(s -> s.getDatabaseName().equals(dataSourceName));
}
SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator = SyntheticBeanBuildItem.configure(Flyway.class).scope(// this is what the existing code does, but it doesn't seem reasonable
Dependent.class).setRuntimeInit().unremovable().supplier(recorder.flywaySupplier(dataSourceName, hasMigrations, createPossible));
if (DataSourceUtil.isDefault(dataSourceName)) {
configurator.addQualifier(Default.class);
} else {
String beanName = FLYWAY_BEAN_NAME_PREFIX + dataSourceName;
configurator.name(beanName);
configurator.addQualifier().annotation(DotNames.NAMED).addValue("value", beanName).done();
configurator.addQualifier().annotation(FlywayDataSource.class).addValue("value", dataSourceName).done();
}
syntheticBeanBuildItemBuildProducer.produce(configurator.done());
}
// will actually run the actions at runtime
recorder.doStartActions();
// once we are done running the migrations, we produce a build item indicating that the
// schema is "ready"
schemaReadyBuildItem.produce(new JdbcDataSourceSchemaReadyBuildItem(migrationsBuildItem.hasMigrations));
return new ServiceStartBuildItem("flyway");
}
Aggregations