io.quarkus.arc.deployment.AdditionalBeanBuildItem Java Examples

The following examples show how to use io.quarkus.arc.deployment.AdditionalBeanBuildItem. 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: ResteasyCommonProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private void registerJsonContextResolver(
        DotName jsonImplementation,
        DotName jsonContextResolver,
        CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ResteasyJaxrsProviderBuildItem> jaxrsProvider,
        BuildProducer<AdditionalBeanBuildItem> additionalBean,
        BuildProducer<UnremovableBeanBuildItem> unremovable) {

    IndexView index = combinedIndexBuildItem.getIndex();

    jaxrsProvider.produce(new ResteasyJaxrsProviderBuildItem(jsonContextResolver.toString()));

    // this needs to be registered manually since the runtime module is not indexed by Jandex
    additionalBean.produce(AdditionalBeanBuildItem.unremovableOf(jsonContextResolver.toString()));
    Set<String> userSuppliedProducers = getUserSuppliedJsonProducerBeans(index, jsonImplementation);
    if (!userSuppliedProducers.isEmpty()) {
        unremovable.produce(
                new UnremovableBeanBuildItem(new UnremovableBeanBuildItem.BeanClassNamesExclusion(userSuppliedProducers)));
    }
}
 
Example #2
Source File: GrpcServerProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
HealthBuildItem addHealthChecks(GrpcServerBuildTimeConfig config,
        List<BindableServiceBuildItem> bindables,
        BuildProducer<AdditionalBeanBuildItem> beans) {
    if (!bindables.isEmpty()) {
        boolean healthEnabled = config.mpHealthEnabled;

        if (config.grpcHealthEnabled) {
            beans.produce(AdditionalBeanBuildItem.unremovableOf(GrpcHealthEndpoint.class));
            healthEnabled = true;
        }

        if (healthEnabled) {
            beans.produce(AdditionalBeanBuildItem.unremovableOf(GrpcHealthStorage.class));
        }
        return new HealthBuildItem("io.quarkus.grpc.runtime.health.GrpcHealthCheck",
                config.mpHealthEnabled);
    } else {
        return null;
    }
}
 
Example #3
Source File: SpringDataJPAProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
void build(CombinedIndexBuildItem index,
        BuildProducer<GeneratedClassBuildItem> generatedClasses,
        BuildProducer<GeneratedBeanBuildItem> generatedBeans,
        BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {

    detectAndLogSpecificSpringPropertiesIfExist();

    IndexView indexIndex = index.getIndex();
    List<ClassInfo> interfacesExtendingCrudRepository = getAllInterfacesExtending(DotNames.SUPPORTED_REPOSITORIES,
            indexIndex);

    removeNoRepositoryBeanClasses(interfacesExtendingCrudRepository);
    implementCrudRepositories(generatedBeans, generatedClasses, additionalBeans, reflectiveClasses,
            interfacesExtendingCrudRepository, indexIndex);
}
 
Example #4
Source File: SmallRyeJwtProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * Register the CDI beans that are needed by the MP-JWT extension
 *
 * @param additionalBeans - producer for additional bean items
 */
@BuildStep
void registerAdditionalBeans(BuildProducer<AdditionalBeanBuildItem> additionalBeans,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
    if (config.enabled) {
        AdditionalBeanBuildItem.Builder unremovable = AdditionalBeanBuildItem.builder().setUnremovable();
        unremovable.addBeanClass(MpJwtValidator.class);
        unremovable.addBeanClass(JWTAuthMechanism.class);
        unremovable.addBeanClass(ClaimValueProducer.class);
        additionalBeans.produce(unremovable.build());
    }
    AdditionalBeanBuildItem.Builder removable = AdditionalBeanBuildItem.builder();
    removable.addBeanClass(JWTAuthContextInfoProvider.class);
    removable.addBeanClass(DefaultJWTParser.class);
    removable.addBeanClass(CommonJwtProducer.class);
    removable.addBeanClass(RawClaimTypeProducer.class);
    removable.addBeanClass(JsonValueProducer.class);
    removable.addBeanClass(JwtPrincipalProducer.class);
    removable.addBeanClass(Claim.class);
    additionalBeans.produce(removable.build());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true, SignatureAlgorithm.class));
    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true, JwtProviderImpl.class));
}
 
Example #5
Source File: SmallRyeMetricsProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
void beans(BuildProducer<AdditionalBeanBuildItem> additionalBeans,
        BuildProducer<UnremovableBeanBuildItem> unremovableBeans) {
    additionalBeans.produce(new AdditionalBeanBuildItem(MetricProducer.class,
            MetricNameFactory.class,
            MetricRegistries.class,
            MetricsInterceptor.class,
            MeteredInterceptor.class,
            ConcurrentGaugeInterceptor.class,
            CountedInterceptor.class,
            TimedInterceptor.class,
            SimplyTimedInterceptor.class,
            MetricsRequestHandler.class));
    unremovableBeans.produce(new UnremovableBeanBuildItem(
            new UnremovableBeanBuildItem.BeanClassNameExclusion(MetricsRequestHandler.class.getName())));
}
 
Example #6
Source File: UndertowBuildStep.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
void integrateCdi(BuildProducer<AdditionalBeanBuildItem> additionalBeans,
        BuildProducer<ContextRegistrarBuildItem> contextRegistrars,
        BuildProducer<ListenerBuildItem> listeners,
        Capabilities capabilities) {
    additionalBeans.produce(new AdditionalBeanBuildItem(ServletProducer.class));
    if (capabilities.isPresent(Capability.SECURITY)) {
        additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(ServletHttpSecurityPolicy.class));
    }
    contextRegistrars.produce(new ContextRegistrarBuildItem(new ContextRegistrar() {
        @Override
        public void register(RegistrationContext registrationContext) {
            registrationContext.configure(SessionScoped.class).normal().contextClass(HttpSessionContext.class).done();
        }
    }, SessionScoped.class));
    listeners.produce(new ListenerBuildItem(HttpSessionContext.class.getName()));
}
 
Example #7
Source File: RestClientProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
@Record(ExecutionTime.STATIC_INIT)
void setup(BuildProducer<FeatureBuildItem> feature,
        BuildProducer<AdditionalBeanBuildItem> additionalBeans,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        RestClientRecorder restClientRecorder) {

    feature.produce(new FeatureBuildItem(Feature.REST_CLIENT));

    restClientRecorder.setRestClientBuilderResolver();

    additionalBeans.produce(new AdditionalBeanBuildItem(RestClient.class));

    reflectiveClass.produce(new ReflectiveClassBuildItem(false, false,
            DefaultResponseExceptionMapper.class.getName(),
            AsyncInterceptorRxInvokerProvider.class.getName(),
            ResteasyProviderFactoryImpl.class.getName(),
            ProxyBuilderImpl.class.getName(),
            ClientRequestFilter[].class.getName(),
            ClientResponseFilter[].class.getName(),
            javax.ws.rs.ext.ReaderInterceptor[].class.getName()));

    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false,
            ResteasyClientBuilder.class.getName()));
}
 
Example #8
Source File: SpringDataJPAProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private void implementCrudRepositories(BuildProducer<GeneratedBeanBuildItem> generatedBeans,
        BuildProducer<GeneratedClassBuildItem> generatedClasses,
        BuildProducer<AdditionalBeanBuildItem> additionalBeans,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        List<ClassInfo> crudRepositoriesToImplement, IndexView index) {

    ClassOutput beansClassOutput = new GeneratedBeanGizmoAdaptor(generatedBeans);
    ClassOutput otherClassOutput = new GeneratedClassGizmoAdaptor(generatedClasses, true);

    SpringDataRepositoryCreator repositoryCreator = new SpringDataRepositoryCreator(beansClassOutput, otherClassOutput,
            index, (n) -> {
                // the implementation of fragments don't need to be beans themselves
                additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(n));
            },
            (className -> {
                // the generated classes that implement interfaces for holding custom query results need
                // to be registered for reflection here since this is the only point where the generated class is known
                reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, className));
            }));

    for (ClassInfo crudRepositoryToImplement : crudRepositoriesToImplement) {
        repositoryCreator.implementCrudRepository(crudRepositoryToImplement);
    }
}
 
Example #9
Source File: ResteasyCommonProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
void registerJsonContextResolvers(CombinedIndexBuildItem combinedIndexBuildItem,
        Capabilities capabilities,
        BuildProducer<ResteasyJaxrsProviderBuildItem> jaxrsProvider,
        BuildProducer<AdditionalBeanBuildItem> additionalBean,
        BuildProducer<UnremovableBeanBuildItem> unremovable) {

    if (capabilities.isPresent(Capability.REST_JACKSON)) {
        registerJsonContextResolver(OBJECT_MAPPER, QUARKUS_OBJECT_MAPPER_CONTEXT_RESOLVER, combinedIndexBuildItem,
                jaxrsProvider, additionalBean, unremovable);
    }

    if (capabilities.isPresent(Capability.REST_JSONB)) {
        registerJsonContextResolver(JSONB, QUARKUS_JSONB_CONTEXT_RESOLVER, combinedIndexBuildItem, jaxrsProvider,
                additionalBean, unremovable);
    }
}
 
Example #10
Source File: JtaProcessor.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
void transactedPolicy(
        BuildProducer<AdditionalBeanBuildItem> additionalBeans,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        Capabilities capabilities) {
    if (capabilities.isCapabilityPresent(Capabilities.TRANSACTIONS)) {
        AdditionalBeanBuildItem.Builder builder = AdditionalBeanBuildItem.builder();
        builder.addBeanClass(RequiredJtaTransactionPolicy.class);
        builder.addBeanClass(RequiresNewJtaTransactionPolicy.class);
        builder.addBeanClass(MandatoryJtaTransactionPolicy.class);
        builder.addBeanClass(NeverJtaTransactionPolicy.class);
        builder.addBeanClass(NotSupportedJtaTransactionPolicy.class);
        builder.addBeanClass(SupportsJtaTransactionPolicy.class);

        additionalBeans.produce(builder.build());

        reflectiveClass.produce(new ReflectiveClassBuildItem(false, false,
                IllegalStateException.class.getName()));
    }
}
 
Example #11
Source File: PicocliProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
void picocliRunner(ApplicationIndexBuildItem applicationIndex,
        CombinedIndexBuildItem combinedIndex,
        BuildProducer<AdditionalBeanBuildItem> additionalBean,
        BuildProducer<QuarkusApplicationClassBuildItem> quarkusApplicationClass,
        BuildProducer<AnnotationsTransformerBuildItem> annotationsTransformer) {
    IndexView index = combinedIndex.getIndex();
    Collection<DotName> topCommands = classesAnnotatedWith(index, TopCommand.class.getName());
    if (topCommands.isEmpty()) {
        List<DotName> commands = classesAnnotatedWith(applicationIndex.getIndex(),
                CommandLine.Command.class.getName());
        if (commands.size() == 1) {
            annotationsTransformer.produce(createAnnotationTransformer(commands.get(0)));
        }
    }
    if (index.getAnnotations(DotName.createSimple(QuarkusMain.class.getName())).isEmpty()) {
        additionalBean.produce(AdditionalBeanBuildItem.unremovableOf(PicocliRunner.class));
        additionalBean.produce(AdditionalBeanBuildItem.unremovableOf(DefaultPicocliCommandLineFactory.class));
        quarkusApplicationClass.produce(new QuarkusApplicationClassBuildItem(PicocliRunner.class));
    }
}
 
Example #12
Source File: HttpSecurityProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
public void builtins(BuildProducer<HttpSecurityPolicyBuildItem> producer, HttpBuildTimeConfig buildTimeConfig,
        BuildProducer<AdditionalBeanBuildItem> beanProducer) {
    producer.produce(new HttpSecurityPolicyBuildItem("deny", new SupplierImpl<>(new DenySecurityPolicy())));
    producer.produce(new HttpSecurityPolicyBuildItem("permit", new SupplierImpl<>(new PermitSecurityPolicy())));
    producer.produce(
            new HttpSecurityPolicyBuildItem("authenticated", new SupplierImpl<>(new AuthenticatedHttpSecurityPolicy())));
    if (!buildTimeConfig.auth.permissions.isEmpty()) {
        beanProducer.produce(AdditionalBeanBuildItem.unremovableOf(PathMatchingHttpSecurityPolicy.class));
    }
    for (Map.Entry<String, PolicyConfig> e : buildTimeConfig.auth.rolePolicy.entrySet()) {
        producer.produce(new HttpSecurityPolicyBuildItem(e.getKey(),
                new SupplierImpl<>(new RolesAllowedHttpSecurityPolicy(e.getValue().rolesAllowed))));
    }

}
 
Example #13
Source File: ServletProcessor.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
static ServletBuildItem newServlet(String key, ServletConfig servletConfig,
        BuildProducer<AdditionalBeanBuildItem> additionalBean) {
    final String servletName = servletConfig.getEffectiveServletName(key);
    final Optional<List<String>> urlPatterns = servletConfig.urlPatterns;
    if (!urlPatterns.isPresent() || urlPatterns.get().isEmpty()) {
        throw new IllegalStateException(
                String.format("Missing quarkus.camel.servlet%s.url-patterns",
                        ServletConfig.DEFAULT_SERVLET_NAME.equals(servletName) ? "" : "." + servletName));
    }

    final Builder builder = ServletBuildItem.builder(servletName, servletConfig.servletClass);
    additionalBean.produce(new AdditionalBeanBuildItem(servletConfig.servletClass));
    for (String pattern : urlPatterns.get()) {
        builder.addMapping(pattern);
    }

    return builder.build();
}
 
Example #14
Source File: ServletProcessor.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
void build(BuildProducer<ServletBuildItem> servlet, BuildProducer<AdditionalBeanBuildItem> additionalBean) {
    boolean servletCreated = false;
    if (camelServletConfig.defaultServlet.isValid()) {
        servlet.produce(
                newServlet(ServletConfig.DEFAULT_SERVLET_NAME, camelServletConfig.defaultServlet, additionalBean));
        servletCreated = true;
    }

    for (Entry<String, ServletConfig> e : camelServletConfig.namedServlets.entrySet()) {
        if (ServletConfig.DEFAULT_SERVLET_NAME.equals(e.getKey())) {
            throw new IllegalStateException(
                    String.format("Use quarkus.camel.servlet.url-patterns instead of quarkus.camel.servlet.%s.url-patterns",
                            ServletConfig.DEFAULT_SERVLET_NAME));
        }
        servlet.produce(newServlet(e.getKey(), e.getValue(), additionalBean));
        servletCreated = true;
    }

    if (!servletCreated) {
        throw new IllegalStateException(
                "Map at least one servlet to a path using quarkus.camel.servlet.url-patterns or quarkus.camel.servlet.[your-servlet-name].url-patterns");
    }

}
 
Example #15
Source File: LiquibaseProcessor.java    From tutorials with MIT License 6 votes vote down vote up
@Record(ExecutionTime.STATIC_INIT)
@BuildStep
void build(BuildProducer<AdditionalBeanBuildItem> additionalBeanProducer,
           BuildProducer<FeatureBuildItem> featureProducer,
           LiquibaseRecorder recorder,
           BuildProducer<BeanContainerListenerBuildItem> containerListenerProducer,
           DataSourceInitializedBuildItem dataSourceInitializedBuildItem) {

    featureProducer.produce(new FeatureBuildItem("liquibase"));

    AdditionalBeanBuildItem unremovableProducer = AdditionalBeanBuildItem.unremovableOf(LiquibaseProducer.class);
    additionalBeanProducer.produce(unremovableProducer);

    containerListenerProducer.produce(
            new BeanContainerListenerBuildItem(recorder.setLiquibaseConfig(liquibaseConfig)));
}
 
Example #16
Source File: AmazonLambdaProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
void processProvidedLambda(Optional<ProvidedAmazonLambdaHandlerBuildItem> providedLambda,
        BuildProducer<AdditionalBeanBuildItem> additionalBeanBuildItemBuildProducer,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClassBuildItemBuildProducer) {
    if (!providedLambda.isPresent())
        return;

    AdditionalBeanBuildItem.Builder builder = AdditionalBeanBuildItem.builder().setUnremovable();
    Class handlerClass = providedLambda.get().getHandlerClass();
    builder.addBeanClass(handlerClass);
    additionalBeanBuildItemBuildProducer.produce(builder.build());

    reflectiveClassBuildItemBuildProducer
            .produce(new ReflectiveClassBuildItem(true, true, true, handlerClass));

    // TODO
    // This really isn't good enough.  We should recursively add reflection for all method and field types of the parameter
    // and return type.  Otherwise Jackson won't work.  In AWS Lambda HTTP extension, the whole jackson model is registered
    // for reflection.  Shouldn't have to do this.
    for (Method method : handlerClass.getMethods()) {
        if (method.getName().equals("handleRequest")
                && method.getParameterTypes().length == 2
                && !method.getParameterTypes()[0].equals(Object.class)) {
            reflectiveClassBuildItemBuildProducer
                    .produce(new ReflectiveClassBuildItem(true, true, true, method.getParameterTypes()[0].getName()));
            reflectiveClassBuildItemBuildProducer
                    .produce(new ReflectiveClassBuildItem(true, true, true, method.getReturnType().getName()));
            reflectiveClassBuildItemBuildProducer.produce(new ReflectiveClassBuildItem(true, true, true,
                    DateTime.class));
            break;
        }
    }
}
 
Example #17
Source File: HibernateReactiveProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
void registerBeans(BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
    additionalBeans.produce(AdditionalBeanBuildItem.builder()
            .addBeanClass(ReactiveSessionFactoryProducer.class)
            .addBeanClass(ReactiveSessionProducer.class)
            .build());
}
 
Example #18
Source File: CredentialsProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
AdditionalBeanBuildItem registerAdditionalBeans() {
    return new AdditionalBeanBuildItem.Builder()
            .setUnremovable()
            .addBeanClass(CredentialsProvider.class)
            .build();
}
 
Example #19
Source File: ArtemisCoreProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
void load(BuildProducer<AdditionalBeanBuildItem> additionalBean, BuildProducer<FeatureBuildItem> feature,
        Optional<ArtemisJmsBuildItem> artemisJms) {

    if (artemisJms.isPresent()) {
        return;
    }
    feature.produce(new FeatureBuildItem(Feature.ARTEMIS_CORE));
    additionalBean.produce(AdditionalBeanBuildItem.unremovableOf(ArtemisCoreProducer.class));
}
 
Example #20
Source File: SmallRyeHealthProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
void healthCheck(BuildProducer<AdditionalBeanBuildItem> buildItemBuildProducer,
        List<HealthBuildItem> healthBuildItems) {
    boolean extensionsEnabled = config.extensionsEnabled &&
            !ConfigProvider.getConfig().getOptionalValue("mp.health.disable-default-procedures", boolean.class)
                    .orElse(false);
    if (extensionsEnabled) {
        for (HealthBuildItem buildItem : healthBuildItems) {
            if (buildItem.isEnabled()) {
                buildItemBuildProducer.produce(new AdditionalBeanBuildItem(buildItem.getHealthCheckClass()));
            }
        }
    }
}
 
Example #21
Source File: CacheProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
List<AdditionalBeanBuildItem> additionalBeans() {
    return Arrays.asList(
            new AdditionalBeanBuildItem(CacheInvalidateAllInterceptor.class),
            new AdditionalBeanBuildItem(CacheInvalidateInterceptor.class),
            new AdditionalBeanBuildItem(CacheResultInterceptor.class));
}
 
Example #22
Source File: GrpcServerProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
void buildContainerBean(BuildProducer<AdditionalBeanBuildItem> beans,
        List<BindableServiceBuildItem> bindables, BuildProducer<FeatureBuildItem> features) {
    if (!bindables.isEmpty()) {
        beans.produce(AdditionalBeanBuildItem.unremovableOf(GrpcContainer.class));
        features.produce(new FeatureBuildItem(GRPC_SERVER));
    } else {
        logger.debug("Unable to find beans exposing the `BindableService` interface - not starting the gRPC server");
    }
}
 
Example #23
Source File: SpringSecurityProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
void registerSecurityInterceptors(BuildProducer<InterceptorBindingRegistrarBuildItem> registrars,
        BuildProducer<AdditionalBeanBuildItem> beans) {
    registrars.produce(new InterceptorBindingRegistrarBuildItem(new SpringSecurityAnnotationsRegistrar()));
    beans.produce(new AdditionalBeanBuildItem(SpringSecuredInterceptor.class));
    beans.produce(new AdditionalBeanBuildItem(SpringPreauthorizeInterceptor.class));
}
 
Example #24
Source File: RestClientProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
AdditionalBeanBuildItem registerProviderBeans(CombinedIndexBuildItem combinedIndex) {
    IndexView index = combinedIndex.getIndex();
    List<AnnotationInstance> allInstances = new ArrayList<>(index.getAnnotations(REGISTER_PROVIDER));
    for (AnnotationInstance annotation : index.getAnnotations(REGISTER_PROVIDERS)) {
        allInstances.addAll(Arrays.asList(annotation.value().asNestedArray()));
    }
    AdditionalBeanBuildItem.Builder builder = AdditionalBeanBuildItem.builder().setUnremovable();
    for (AnnotationInstance annotationInstance : allInstances) {
        // Make sure all providers not annotated with @Provider but used in @RegisterProvider are registered as beans
        builder.addBeanClass(annotationInstance.value().asClass().toString());
    }
    return builder.build();
}
 
Example #25
Source File: OAuth2DeploymentProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Configure a TokenSecurityRealm if enabled
 *
 * @param recorder - runtime OAuth2 security recorder
 * @param securityRealm - the producer factory for the SecurityRealmBuildItem
 * @return the AuthConfigBuildItem for the realm authentication mechanism if there was an enabled PropertiesRealmConfig,
 *         null otherwise
 * @throws Exception - on any failure
 */
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
AdditionalBeanBuildItem configureOauth2RealmAuthConfig(OAuth2Recorder recorder,
        BuildProducer<SecurityRealmBuildItem> securityRealm) throws Exception {
    if (oauth2.enabled) {
        RuntimeValue<SecurityRealm> realm = recorder.createRealm(oauth2);
        securityRealm.produce(new SecurityRealmBuildItem(realm, REALM_NAME, null));
        return AdditionalBeanBuildItem.unremovableOf(OAuth2AuthMechanism.class);
    }
    return null;
}
 
Example #26
Source File: ArtemisJmsProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
void load(BuildProducer<AdditionalBeanBuildItem> additionalBean, BuildProducer<FeatureBuildItem> feature,
        BuildProducer<ArtemisJmsBuildItem> artemisJms) {

    artemisJms.produce(new ArtemisJmsBuildItem());
    feature.produce(new FeatureBuildItem(Feature.ARTEMIS_JMS));
    additionalBean.produce(AdditionalBeanBuildItem.unremovableOf(ArtemisJmsProducer.class));
}
 
Example #27
Source File: SmallRyeGraphQLProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
void additionalBean(BuildProducer<AdditionalBeanBuildItem> additionalBeanProducer) {
    additionalBeanProducer.produce(AdditionalBeanBuildItem.builder()
            .addBeanClass(GraphQLConfig.class)
            .addBeanClass(GraphQLProducer.class)
            .setUnremovable().build());
}
 
Example #28
Source File: KeycloakPolicyEnforcerBuildStep.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
public AdditionalBeanBuildItem beans(KeycloakPolicyEnforcerConfig config) {
    if (config.policyEnforcer.enable) {
        return AdditionalBeanBuildItem.builder().setUnremovable()
                .addBeanClass(KeycloakPolicyEnforcerAuthorizer.class).build();
    }
    return null;
}
 
Example #29
Source File: TestProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Register the CDI beans that are needed by the test extension
 *
 * @param additionalBeans - producer for additional bean items
 */
@BuildStep
void registerAdditionalBeans(BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
    AdditionalBeanBuildItem additionalBeansItem = AdditionalBeanBuildItem.builder()
            .addBeanClass(PublicKeyProducer.class)
            .addBeanClass(CommandServlet.class)
            .setRemovable()
            .build();
    additionalBeans.produce(additionalBeansItem);
}
 
Example #30
Source File: MailerProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
AdditionalBeanBuildItem registerMailers() {
    return AdditionalBeanBuildItem.builder()
            .addBeanClasses(ReactiveMailerImpl.class, MutinyMailerImpl.class, BlockingMailerImpl.class,
                    MockMailboxImpl.class, MailTemplateProducer.class)
            .build();
}