Java Code Examples for io.quarkus.deployment.annotations.ExecutionTime#RUNTIME_INIT

The following examples show how to use io.quarkus.deployment.annotations.ExecutionTime#RUNTIME_INIT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigGenerationBuildStep.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * Warns if build time config properties have been changed at runtime.
 */
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
public void checkForBuildTimeConfigChange(
        ConfigChangeRecorder recorder, ConfigurationBuildItem configItem, LoggingSetupBuildItem loggingSetupBuildItem) {
    BuildTimeConfigurationReader.ReadResult readResult = configItem.getReadResult();
    Config config = ConfigProvider.getConfig();

    Map<String, String> values = new HashMap<>();
    for (RootDefinition root : readResult.getAllRoots()) {
        if (root.getConfigPhase() == ConfigPhase.BUILD_AND_RUN_TIME_FIXED ||
                root.getConfigPhase() == ConfigPhase.BUILD_TIME) {

            Iterable<ClassDefinition.ClassMember> members = root.getMembers();
            handleMembers(config, values, members, "quarkus." + root.getRootName() + ".");
        }
    }
    values.remove("quarkus.profile");
    recorder.handleConfigChange(values);
}
 
Example 2
Source File: MongoClientProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Record(ExecutionTime.RUNTIME_INIT)
@BuildStep
void generateClientBeans(MongoClientRecorder recorder,
        List<MongoClientNameBuildItem> mongoClientNames,
        MongodbConfig mongodbConfig,
        Optional<MongoUnremovableClientsBuildItem> mongoUnremovableClientsBuildItem,
        BuildProducer<SyntheticBeanBuildItem> syntheticBeanBuildItemBuildProducer) {

    boolean makeUnremovable = mongoUnremovableClientsBuildItem.isPresent();

    // default blocking client
    syntheticBeanBuildItemBuildProducer.produce(createBlockingSyntheticBean(recorder, mongodbConfig, makeUnremovable,
            MongoClientBeanUtil.DEFAULT_MONGOCLIENT_NAME));
    // default reactive client
    syntheticBeanBuildItemBuildProducer.produce(createReactiveSyntheticBean(recorder, mongodbConfig, makeUnremovable,
            MongoClientBeanUtil.DEFAULT_MONGOCLIENT_NAME));

    for (MongoClientNameBuildItem mongoClientName : mongoClientNames) {
        // named blocking client
        syntheticBeanBuildItemBuildProducer
                .produce(createBlockingSyntheticBean(recorder, mongodbConfig, makeUnremovable, mongoClientName.getName()));
        // named reactive client
        syntheticBeanBuildItemBuildProducer
                .produce(createReactiveSyntheticBean(recorder, mongodbConfig, makeUnremovable, mongoClientName.getName()));
    }
}
 
Example 3
Source File: CassandraqlProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example 4
Source File: SmallRyeContextPropagationProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
void build(SmallRyeContextPropagationRecorder recorder,
        BeanContainerBuildItem beanContainer,
        ExecutorBuildItem executorBuildItem,
        BuildProducer<FeatureBuildItem> feature,
        BuildProducer<ManagedExecutorInitializedBuildItem> managedExecutorInitialized) {
    feature.produce(new FeatureBuildItem(Feature.SMALLRYE_CONTEXT_PROPAGATION));

    recorder.configureRuntime(beanContainer.getValue(), executorBuildItem.getExecutorProxy());
    managedExecutorInitialized.produce(new ManagedExecutorInitializedBuildItem());
}
 
Example 5
Source File: GoogleBigqueryProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example 6
Source File: KmsProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
void createClientBuilders(List<AmazonClientTransportsBuildItem> transportBuildItems, KmsRecorder recorder,
        KmsConfig runtimeConfig, BuildProducer<AmazonClientBuilderBuildItem> builderProducer) {

    createClientBuilders(transportBuildItems, builderProducer,
            (syncTransport) -> recorder.createSyncBuilder(runtimeConfig, syncTransport),
            (asyncTransport) -> recorder.createAsyncBuilder(runtimeConfig, asyncTransport));
}
 
Example 7
Source File: ElytronDeploymentProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * For each SecurityRealm, load it's runtime state. This is currently a little strange due to how the AuthConfig is
 * downcast to the type of SecurityRealm configuration instance.
 *
 * @param recorder - the runtime recorder class used to access runtime behaviors
 * @param realms - the previously created SecurityRealm runtime values
 * @throws Exception
 */
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
void loadRealm(ElytronRecorder recorder, List<SecurityRealmBuildItem> realms) throws Exception {
    for (SecurityRealmBuildItem realm : realms) {
        if (realm.getRuntimeLoadTask() != null) {
            recorder.runLoadTask(realm.getRuntimeLoadTask());
        }
    }
}
 
Example 8
Source File: DynamodbProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
void buildClients(List<AmazonClientBuilderConfiguredBuildItem> configuredClients, DynamodbRecorder recorder,
        BeanContainerBuildItem beanContainer,
        ShutdownContextBuildItem shutdown) {

    buildClients(configuredClients,
            (syncBuilder) -> recorder.buildClient(syncBuilder, beanContainer.getValue(), shutdown),
            (asyncBuilder) -> recorder.buildAsyncClient(asyncBuilder, beanContainer.getValue(), shutdown));
}
 
Example 9
Source File: AvroProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example 10
Source File: VertxCoreProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
@Record(value = ExecutionTime.RUNTIME_INIT)
CoreVertxBuildItem build(VertxCoreRecorder recorder,
        LaunchModeBuildItem launchMode, ShutdownContextBuildItem shutdown, VertxConfiguration config,
        List<VertxOptionsConsumerBuildItem> vertxOptionsConsumers,
        BuildProducer<SyntheticBeanBuildItem> syntheticBeans,
        BuildProducer<EventLoopSupplierBuildItem> eventLoops,
        BuildProducer<ServiceStartBuildItem> serviceStartBuildItem) {

    Collections.sort(vertxOptionsConsumers);
    List<Consumer<VertxOptions>> consumers = new ArrayList<>(vertxOptionsConsumers.size());
    for (VertxOptionsConsumerBuildItem x : vertxOptionsConsumers) {
        consumers.add(x.getConsumer());
    }

    Supplier<Vertx> vertx = recorder.configureVertx(config,
            launchMode.getLaunchMode(), shutdown, consumers);
    syntheticBeans.produce(SyntheticBeanBuildItem.configure(Vertx.class)
            .types(Vertx.class)
            .scope(Singleton.class)
            .unremovable()
            .setRuntimeInit()
            .supplier(vertx).done());

    // Event loops are only usable after the core vertx instance is configured
    eventLoops.produce(new EventLoopSupplierBuildItem(recorder.mainSupplier(), recorder.bossSupplier()));

    return new CoreVertxBuildItem(vertx);
}
 
Example 11
Source File: OgnlProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Remove this once this extension starts supporting the native mode.
 */
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
    JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
    recorder.warnJvmInNative(FEATURE); // warn at runtime
}
 
Example 12
Source File: SesProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
void configureClient(List<AmazonClientBuilderBuildItem> clients, SesRecorder recorder,
        AmazonClientRecorder commonRecorder,
        SesConfig runtimeConfig,
        BuildProducer<AmazonClientBuilderConfiguredBuildItem> producer) {

    initClientBuilders(clients, commonRecorder, recorder.getAwsConfig(runtimeConfig), recorder.getSdkConfig(runtimeConfig),
            buildTimeConfig.sdk, producer);
}
 
Example 13
Source File: NettyProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
public void eagerlyInitClass(NettyRecorder recorder) {
    //see https://github.com/quarkusio/quarkus/issues/3663
    //this class is slow to initialize, we make sure that we do it eagerly
    //before it blocks the IO thread and causes a warning
    recorder.eagerlyInitChannelId();
}
 
Example 14
Source File: SqsProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
void configureClient(List<AmazonClientBuilderBuildItem> clients, SqsRecorder recorder,
        AmazonClientRecorder commonRecorder,
        SqsConfig runtimeConfig,
        BuildProducer<AmazonClientBuilderConfiguredBuildItem> producer) {

    initClientBuilders(clients, commonRecorder, recorder.getAwsConfig(runtimeConfig), recorder.getSdkConfig(runtimeConfig),
            buildTimeConfig.sdk, producer);
}
 
Example 15
Source File: VertxHttpProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
VertxWebRouterBuildItem initializeRouter(VertxHttpRecorder recorder,
        CoreVertxBuildItem vertx,
        List<RouteBuildItem> routes, LaunchModeBuildItem launchModeBuildItem,
        ShutdownContextBuildItem shutdown) {

    RuntimeValue<Router> router = recorder.initializeRouter(vertx.getVertx(), launchModeBuildItem.getLaunchMode(),
            shutdown);
    for (RouteBuildItem route : routes) {
        recorder.addRoute(router, route.getRouteFunction(), route.getHandler(), route.getType());
    }

    return new VertxWebRouterBuildItem(router);
}
 
Example 16
Source File: VertxProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@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,
        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()));
}
 
Example 17
Source File: DynamodbProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
void configureClient(List<AmazonClientBuilderBuildItem> clients, DynamodbRecorder recorder,
        AmazonClientRecorder commonRecorder,
        DynamodbConfig runtimeConfig,
        BuildProducer<AmazonClientBuilderConfiguredBuildItem> producer) {

    initClientBuilders(clients, commonRecorder, recorder.getAwsConfig(runtimeConfig), recorder.getSdkConfig(runtimeConfig),
            buildTimeConfig.sdk, producer);
}
 
Example 18
Source File: JDBCMySQLProcessor.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
void abandonedConnectionCleanUp(MySQLRecorder recorder) {
    recorder.startAbandonedConnectionCleanup();
}
 
Example 19
Source File: AgroalProcessor.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Record(ExecutionTime.RUNTIME_INIT)
@BuildStep
void generateDataSourceBeans(AgroalRecorder recorder,
        DataSourcesRuntimeConfig dataSourcesRuntimeConfig,
        List<AggregatedDataSourceBuildTimeConfigBuildItem> aggregatedBuildTimeConfigBuildItems,
        SslNativeConfigBuildItem sslNativeConfig,
        Capabilities capabilities,
        BuildProducer<SyntheticBeanBuildItem> syntheticBeanBuildItemBuildProducer,
        BuildProducer<JdbcDataSourceBuildItem> jdbcDataSource) {
    if (aggregatedBuildTimeConfigBuildItems.isEmpty()) {
        // No datasource has been configured so bail out
        return;
    }

    for (Map.Entry<String, DataSourceSupport.Entry> entry : getDataSourceSupport(aggregatedBuildTimeConfigBuildItems,
            sslNativeConfig,
            capabilities).entries.entrySet()) {

        String dataSourceName = entry.getKey();

        SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator = SyntheticBeanBuildItem
                .configure(AgroalDataSource.class)
                .addType(DATA_SOURCE)
                .scope(Singleton.class)
                .setRuntimeInit()
                .unremovable()
                // pass the runtime config into the recorder to ensure that the DataSource related beans
                // are created after runtime configuration has been setup
                .supplier(recorder.agroalDataSourceSupplier(dataSourceName, dataSourcesRuntimeConfig));

        if (entry.getValue().isDefault) {
            configurator.addQualifier(Default.class);
        } else {
            // this definitely not ideal, but 'elytron-jdbc-security' uses it (although it could be easily changed)
            // which means that perhaps other extensions might depend on this as well...
            configurator.name(dataSourceName);

            configurator.addQualifier().annotation(DotNames.NAMED).addValue("value", dataSourceName).done();
            configurator.addQualifier().annotation(DataSource.class).addValue("value", dataSourceName).done();
        }

        syntheticBeanBuildItemBuildProducer.produce(configurator.done());

        jdbcDataSource.produce(new JdbcDataSourceBuildItem(dataSourceName,
                entry.getValue().resolvedDbKind,
                entry.getValue().isDefault));
    }
}
 
Example 20
Source File: DummyBootstrapConfigBuildStep.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
public void dummyRecorder2(DummyBootstrapRecorder2 recorder,
        BuildProducer<RunTimeConfigurationSourceValueBuildItem> producer) {
    producer.produce(new RunTimeConfigurationSourceValueBuildItem(recorder.create()));
}