use of io.quarkus.deployment.builditem.ServiceStartBuildItem in project quarkus by quarkusio.
the class VertxHttpProcessor method finalizeRouter.
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
ServiceStartBuildItem finalizeRouter(VertxHttpRecorder recorder, BeanContainerBuildItem beanContainer, CoreVertxBuildItem vertx, LaunchModeBuildItem launchMode, List<DefaultRouteBuildItem> defaultRoutes, List<FilterBuildItem> filters, VertxWebRouterBuildItem httpRouteRouter, HttpRootPathBuildItem httpRootPathBuildItem, NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem, HttpBuildTimeConfig httpBuildTimeConfig, List<RequireBodyHandlerBuildItem> requireBodyHandlerBuildItems, BodyHandlerBuildItem bodyHandlerBuildItem, BuildProducer<ShutdownListenerBuildItem> shutdownListenerBuildItemBuildProducer, ShutdownConfig shutdownConfig, LiveReloadConfig lrc, // Injected to be sure that Vert.x has been produced before calling this method.
CoreVertxBuildItem core, ExecutorBuildItem executorBuildItem) throws BuildException, IOException {
Optional<DefaultRouteBuildItem> defaultRoute;
if (defaultRoutes == null || defaultRoutes.isEmpty()) {
defaultRoute = Optional.empty();
} else {
if (defaultRoutes.size() > 1) {
// this should never happen
throw new BuildException("Too many default routes.", Collections.emptyList());
} else {
defaultRoute = Optional.of(defaultRoutes.get(0));
}
}
HttpRemoteDevClientProvider.liveReloadConfig = lrc;
GracefulShutdownFilter gracefulShutdownFilter = recorder.createGracefulShutdownHandler();
shutdownListenerBuildItemBuildProducer.produce(new ShutdownListenerBuildItem(gracefulShutdownFilter));
List<Filter> listOfFilters = filters.stream().filter(f -> f.getHandler() != null).map(FilterBuildItem::toFilter).collect(Collectors.toList());
// if the body handler is required then we know it is installed for all routes, so we don't need to register it here
Handler<RoutingContext> bodyHandler = !requireBodyHandlerBuildItems.isEmpty() ? bodyHandlerBuildItem.getHandler() : null;
Optional<RuntimeValue<Router>> mainRouter = httpRouteRouter.getMainRouter() != null ? Optional.of(httpRouteRouter.getMainRouter()) : Optional.empty();
if (httpRouteRouter.getFrameworkRouter() != null) {
if (nonApplicationRootPathBuildItem.isAttachedToMainRouter()) {
// Mount nested framework router
recorder.mountFrameworkRouter(httpRouteRouter.getHttpRouter(), httpRouteRouter.getFrameworkRouter(), nonApplicationRootPathBuildItem.getVertxRouterPath());
} else {
// Create main router, not mounted under application router
if (!mainRouter.isPresent()) {
mainRouter = Optional.of(recorder.initializeRouter(vertx.getVertx()));
}
// Mount independent framework router under new main router
recorder.mountFrameworkRouter(mainRouter.get(), httpRouteRouter.getFrameworkRouter(), nonApplicationRootPathBuildItem.getVertxRouterPath());
}
}
recorder.finalizeRouter(beanContainer.getValue(), defaultRoute.map(DefaultRouteBuildItem::getRoute).orElse(null), listOfFilters, vertx.getVertx(), lrc, mainRouter, httpRouteRouter.getHttpRouter(), httpRouteRouter.getMutinyRouter(), httpRootPathBuildItem.getRootPath(), launchMode.getLaunchMode(), !requireBodyHandlerBuildItems.isEmpty(), bodyHandler, gracefulShutdownFilter, shutdownConfig, executorBuildItem.getExecutorProxy());
return new ServiceStartBuildItem("vertx-http");
}
use of io.quarkus.deployment.builditem.ServiceStartBuildItem in project quarkus by quarkusio.
the class VertxProcessor method build.
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
VertxBuildItem build(CoreVertxBuildItem vertx, VertxRecorder recorder, List<EventConsumerBusinessMethodItem> messageConsumerBusinessMethods, BuildProducer<GeneratedClassBuildItem> generatedClass, AnnotationProxyBuildItem annotationProxy, LaunchModeBuildItem launchMode, ShutdownContextBuildItem shutdown, BuildProducer<ServiceStartBuildItem> serviceStart, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, List<MessageCodecBuildItem> codecs, RecorderContext recorderContext) {
Map<String, ConsumeEvent> messageConsumerConfigurations = new HashMap<>();
ClassOutput classOutput = new GeneratedClassGizmoAdaptor(generatedClass, true);
for (EventConsumerBusinessMethodItem businessMethod : messageConsumerBusinessMethods) {
String invokerClass = EventBusConsumer.generateInvoker(businessMethod.getBean(), businessMethod.getMethod(), businessMethod.getConsumeEvent(), classOutput);
messageConsumerConfigurations.put(invokerClass, annotationProxy.builder(businessMethod.getConsumeEvent(), ConsumeEvent.class).withDefaultValue("value", businessMethod.getBean().getBeanClass().toString()).build(classOutput));
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, invokerClass));
}
Map<Class<?>, Class<?>> codecByClass = new HashMap<>();
for (MessageCodecBuildItem messageCodecItem : codecs) {
codecByClass.put(recorderContext.classProxy(messageCodecItem.getType()), recorderContext.classProxy(messageCodecItem.getCodec()));
}
recorder.configureVertx(vertx.getVertx(), messageConsumerConfigurations, launchMode.getLaunchMode(), shutdown, codecByClass);
serviceStart.produce(new ServiceStartBuildItem("vertx"));
return new VertxBuildItem(recorder.forceStart(vertx.getVertx()));
}
use of io.quarkus.deployment.builditem.ServiceStartBuildItem in project kogito-apps by kiegroup.
the class InmemoryPostgreSQLProcessor method startService.
@BuildStep
@Record(RUNTIME_INIT)
ServiceStartBuildItem startService(InmemoryPostgreSQLRecorder recorder, BuildProducer<RunTimeConfigurationSourceValueBuildItem> configSourceValueBuildItem) throws IOException {
RuntimeValue<Integer> port = recorder.startPostgres();
configSourceValueBuildItem.produce(new RunTimeConfigurationSourceValueBuildItem(recorder.configSources(port)));
return new ServiceStartBuildItem(FEATURE);
}
use of io.quarkus.deployment.builditem.ServiceStartBuildItem 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");
}
use of io.quarkus.deployment.builditem.ServiceStartBuildItem in project camel-quarkus by apache.
the class CamelBootstrapProcessor method boot.
/**
* Starts the given {@link CamelRuntimeBuildItem}.
*
* @param recorder the recorder.
* @param runtime a reference to the {@link CamelRuntimeBuildItem}.
* @param commandLineArguments a reference to the raw command line arguments as they were passed to the application.
* @param shutdown a reference to a {@link ShutdownContext} used tor register the Camel's related shutdown
* tasks.
*/
@BuildStep
@Record(value = ExecutionTime.RUNTIME_INIT)
@Produce(CamelBootstrapCompletedBuildItem.class)
void boot(CamelBootstrapRecorder recorder, CamelRuntimeBuildItem runtime, RawCommandLineArgumentsBuildItem commandLineArguments, ShutdownContextBuildItem shutdown, BuildProducer<ServiceStartBuildItem> serviceStartBuildItems) {
recorder.addShutdownTask(shutdown, runtime.runtime());
if (runtime.isAutoStartup()) {
recorder.start(runtime.runtime(), commandLineArguments);
}
/* Make sure that Quarkus orders this method before starting to serve HTTP endpoints.
* Otherwise first requests might reach Camel context in a non-yet-started state. */
serviceStartBuildItems.produce(new ServiceStartBuildItem("camel-runtime"));
}
Aggregations