Java Code Examples for io.quarkus.arc.runtime.BeanContainer#instance()

The following examples show how to use io.quarkus.arc.runtime.BeanContainer#instance() . 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: KmsRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<KmsClient> buildClient(RuntimeValue<? extends AwsClientBuilder> builder,
        BeanContainer beanContainer,
        ShutdownContext shutdown) {
    KmsClientProducer producer = beanContainer.instance(KmsClientProducer.class);
    producer.setSyncConfiguredBuilder((KmsClientBuilder) builder.getValue());
    shutdown.addShutdownTask(producer::destroy);
    return new RuntimeValue<>(producer.client());
}
 
Example 2
Source File: DynamodbRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<DynamoDbAsyncClient> buildAsyncClient(RuntimeValue<? extends AwsClientBuilder> builder,
        BeanContainer beanContainer,
        ShutdownContext shutdown) {
    DynamodbClientProducer producer = beanContainer.instance(DynamodbClientProducer.class);
    producer.setAsyncConfiguredBuilder((DynamoDbAsyncClientBuilder) builder.getValue());
    shutdown.addShutdownTask(producer::destroy);
    return new RuntimeValue<>(producer.asyncClient());
}
 
Example 3
Source File: DynamodbRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<DynamoDbClient> buildClient(RuntimeValue<? extends AwsClientBuilder> builder,
        BeanContainer beanContainer,
        ShutdownContext shutdown) {
    DynamodbClientProducer producer = beanContainer.instance(DynamodbClientProducer.class);
    producer.setSyncConfiguredBuilder((DynamoDbClientBuilder) builder.getValue());
    shutdown.addShutdownTask(producer::destroy);
    return new RuntimeValue<>(producer.client());
}
 
Example 4
Source File: KafkaStreamsRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public BeanContainerListener configure(Properties properties) {
    return new BeanContainerListener() {

        @Override
        public void created(BeanContainer container) {
            KafkaStreamsTopologyManager instance = container.instance(KafkaStreamsTopologyManager.class);
            instance.configure(properties);
        }
    };
}
 
Example 5
Source File: SnsRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<SnsClient> buildClient(RuntimeValue<? extends AwsClientBuilder> builder,
        BeanContainer beanContainer,
        ShutdownContext shutdown) {
    SnsClientProducer producer = beanContainer.instance(SnsClientProducer.class);
    producer.setSyncConfiguredBuilder((SnsClientBuilder) builder.getValue());
    shutdown.addShutdownTask(producer::destroy);
    return new RuntimeValue<>(producer.client());
}
 
Example 6
Source File: S3Recorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<S3Client> buildClient(RuntimeValue<? extends AwsClientBuilder> builder,
        BeanContainer beanContainer,
        ShutdownContext shutdown) {
    S3ClientProducer producer = beanContainer.instance(S3ClientProducer.class);
    producer.setSyncConfiguredBuilder((S3ClientBuilder) builder.getValue());
    shutdown.addShutdownTask(producer::destroy);
    return new RuntimeValue<>(producer.client());
}
 
Example 7
Source File: SqsRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<SqsClient> buildClient(RuntimeValue<? extends AwsClientBuilder> builder,
        BeanContainer beanContainer,
        ShutdownContext shutdown) {
    SqsClientProducer producer = beanContainer.instance(SqsClientProducer.class);
    producer.setSyncConfiguredBuilder((SqsClientBuilder) builder.getValue());
    shutdown.addShutdownTask(producer::destroy);
    return new RuntimeValue<>(producer.client());
}
 
Example 8
Source File: SesRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<SesAsyncClient> buildAsyncClient(RuntimeValue<? extends AwsClientBuilder> builder,
        BeanContainer beanContainer,
        ShutdownContext shutdown) {
    SesClientProducer producer = beanContainer.instance(SesClientProducer.class);
    producer.setAsyncConfiguredBuilder((SesAsyncClientBuilder) builder.getValue());
    shutdown.addShutdownTask(producer::destroy);
    return new RuntimeValue<>(producer.asyncClient());
}
 
Example 9
Source File: SesRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<SesClient> buildClient(RuntimeValue<? extends AwsClientBuilder> builder,
        BeanContainer beanContainer,
        ShutdownContext shutdown) {
    SesClientProducer producer = beanContainer.instance(SesClientProducer.class);
    producer.setSyncConfiguredBuilder((SesClientBuilder) builder.getValue());
    shutdown.addShutdownTask(producer::destroy);
    return new RuntimeValue<>(producer.client());
}
 
Example 10
Source File: CamelQuteRecorder.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<QuteComponent> createQuteComponent(BeanContainer beanContainer) {
    Engine quteEngine = beanContainer.instance(Engine.class);

    QuteComponent component = new QuteComponent();
    component.setQuteEngine(quteEngine);

    return new RuntimeValue<>(component);
}
 
Example 11
Source File: SmallRyeContextPropagationRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public void configureRuntime(BeanContainer container, ExecutorService executorService) {
    // associate the static init manager to the runtime CL
    ContextManagerProvider contextManagerProvider = ContextManagerProvider.instance();
    // finish building our manager
    builder.withDefaultExecutorService(executorService);

    SmallRyeContextManager contextManager = builder.build();

    contextManagerProvider.registerContextManager(contextManager, Thread.currentThread().getContextClassLoader());

    // initialise injection
    SmallRyeContextPropagationProvider cpProvider = container.instance(SmallRyeContextPropagationProvider.class);
    cpProvider.initialize(executorService);
}
 
Example 12
Source File: KeycloakRecorder.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public BeanContainerListener configureDataSource() {
    return new BeanContainerListener() {
        @Override
        public void created(BeanContainer container) {
            String driver = CONFIG.getRawValue("quarkus.datasource.driver");
            DataSourceSupport instance = container.instance(DataSourceSupport.class);
            DataSourceSupport.Entry entry = instance.entries.get(DataSourceUtil.DEFAULT_DATASOURCE_NAME);
            entry.resolvedDriverClass = driver;
        }
    };
}
 
Example 13
Source File: Neo4jDriverRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public void configureNeo4jProducer(BeanContainer beanContainer, Neo4jConfiguration configuration,
        ShutdownContext shutdownContext) {

    Driver driver = initializeDriver(configuration, shutdownContext);

    Neo4jDriverProducer driverProducer = beanContainer.instance(Neo4jDriverProducer.class);
    driverProducer.initialize(driver);
}
 
Example 14
Source File: HibernateOrmRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the JPA configuration to be used at runtime.
 * 
 * @param jtaEnabled Should JTA be enabled?
 * @param strategy Multitenancy strategy to use.
 * @param multiTenancySchemaDataSource Data source to use in case of {@link MultiTenancyStrategy#SCHEMA} approach or
 *        {@link null} in case the default data source.
 * 
 * @return
 */
public BeanContainerListener initializeJpa(boolean jtaEnabled, MultiTenancyStrategy strategy,
        String multiTenancySchemaDataSource) {
    return new BeanContainerListener() {
        @Override
        public void created(BeanContainer beanContainer) {
            JPAConfig instance = beanContainer.instance(JPAConfig.class);
            instance.setJtaEnabled(jtaEnabled);
            instance.setMultiTenancyStrategy(strategy);
            instance.setMultiTenancySchemaDataSource(multiTenancySchemaDataSource);
        }
    };
}
 
Example 15
Source File: S3Recorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public RuntimeValue<S3AsyncClient> buildAsyncClient(RuntimeValue<? extends AwsClientBuilder> builder,
        BeanContainer beanContainer,
        ShutdownContext shutdown) {
    S3ClientProducer producer = beanContainer.instance(S3ClientProducer.class);
    producer.setAsyncConfiguredBuilder((S3AsyncClientBuilder) builder.getValue());
    shutdown.addShutdownTask(producer::destroy);
    return new RuntimeValue<>(producer.asyncClient());
}
 
Example 16
Source File: SmallRyeReactiveMessagingRecorder.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public void registerMediators(List<QuarkusMediatorConfiguration> configurations, BeanContainer container) {
    MediatorManager mediatorManager = container.instance(MediatorManager.class);
    mediatorManager.addAnalyzed(configurations);
}
 
Example 17
Source File: SmallRyeGraphQLRecorder.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public void createExecutionService(BeanContainer beanContainer, Schema schema) {
    GraphQLProducer graphQLProducer = beanContainer.instance(GraphQLProducer.class);
    graphQLProducer.setSchema(schema);
    graphQLProducer.initialize();
}
 
Example 18
Source File: TikaRecorder.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
public RuntimeValue<TikaComponent> createTikaComponent(BeanContainer container) {
    return new RuntimeValue<>(new QuarkusTikaComponent(container.instance(TikaParserProducer.class)));
}
 
Example 19
Source File: CamelKubernetesRecorder.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
public RuntimeValue<?> getKubernetesClient(BeanContainer beanContainer) {
    KubernetesClient client = beanContainer.instance(KubernetesClient.class);
    return new RuntimeValue<>(client);
}
 
Example 20
Source File: TestRecorder.java    From quarkus with Apache License 2.0 3 votes vote down vote up
/**
 * Instantiate the given class in the given BeanContainer and passes the TestBuildAndRunTimeConfig and TestRunTimeConfig to
 * it
 *
 * @param beanContainer - CDI container
 * @param beanClass - IConfigConsumer
 * @param buildTimeConfig - the extension TestBuildAndRunTimeConfig
 * @param runTimeConfig - the extension TestRunTimeConfig
 * @see IConfigConsumer#loadConfig(TestBuildAndRunTimeConfig, TestRunTimeConfig)
 */
public void configureBeans(BeanContainer beanContainer, Class<IConfigConsumer> beanClass,
        TestBuildAndRunTimeConfig buildTimeConfig,
        TestRunTimeConfig runTimeConfig, FooRuntimeConfig fooRuntimeConfig) {
    log.infof("Begin BeanContainerListener callback\n");
    IConfigConsumer instance = beanContainer.instance(beanClass);
    instance.loadConfig(buildTimeConfig, runTimeConfig, fooRuntimeConfig);
    log.infof("configureBeans, instance=%s\n", instance);
}