Search in sources :

Example 1 with CamelServiceFilterBuildItem

use of org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilterBuildItem in project camel-quarkus by apache.

the class CamelRegistryProcessor method bindBeansToRegistry.

@Record(ExecutionTime.STATIC_INIT)
@BuildStep
public void bindBeansToRegistry(CamelRecorder recorder, CamelConfig camelConfig, ApplicationArchivesBuildItem applicationArchives, ContainerBeansBuildItem containerBeans, CamelRegistryBuildItem registry, // CamelContextBuildItem placeholder ensures this build step runs after the CamelContext is created
CamelContextBuildItem camelContextBuildItem, List<CamelBeanBuildItem> registryItems, List<CamelServiceFilterBuildItem> serviceFilters, List<CamelServicePatternBuildItem> servicePatterns) {
    final ClassLoader TCCL = Thread.currentThread().getContextClassLoader();
    final PathFilter pathFilter = servicePatterns.stream().filter(patterns -> patterns.getDestination() == CamelServiceDestination.REGISTRY).collect(PathFilter.Builder::new, (builder, patterns) -> builder.patterns(patterns.isInclude(), patterns.getPatterns()), PathFilter.Builder::combine).include(camelConfig.service.registry.includePatterns).exclude(camelConfig.service.registry.excludePatterns).build();
    CamelSupport.services(applicationArchives, pathFilter).filter(si -> !containerBeans.getBeans().contains(si)).filter(si -> {
        // 
        // by default all the service found in META-INF/service/org/apache/camel are
        // bound to the registry but some of the services are then replaced or set
        // to the camel context directly by extension so it does not make sense to
        // instantiate them in this phase.
        // 
        boolean blacklisted = serviceFilters.stream().anyMatch(filter -> filter.getPredicate().test(si));
        if (blacklisted) {
            LOGGER.debug("Ignore service: {}", si);
        }
        return !blacklisted;
    }).forEach(si -> {
        LOGGER.debug("Binding bean with name: {}, type {}", si.name, si.type);
        recorder.bind(registry.getRegistry(), si.name, CamelSupport.loadClass(si.type, TCCL));
    });
    registryItems.stream().filter(item -> !containerBeans.getBeans().contains(item)).forEach(item -> {
        LOGGER.debug("Binding bean with name: {}, type {}", item.getName(), item.getType());
        if (item.getValue().isPresent()) {
            recorder.bind(registry.getRegistry(), item.getName(), CamelSupport.loadClass(item.getType(), TCCL), item.getValue().get());
        } else {
            // the instance of the service will be instantiated by the recorder, this avoid
            // creating a recorder for trivial services.
            recorder.bind(registry.getRegistry(), item.getName(), CamelSupport.loadClass(item.getType(), TCCL));
        }
    });
}
Also used : CamelRuntimeTaskBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeTaskBuildItem) Record(io.quarkus.deployment.annotations.Record) CamelSupport(org.apache.camel.quarkus.core.deployment.util.CamelSupport) CamelContextBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem) Logger(org.slf4j.Logger) ApplicationArchivesBuildItem(io.quarkus.deployment.builditem.ApplicationArchivesBuildItem) CamelBeanBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelBeanBuildItem) CamelRuntimeBeanBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeBeanBuildItem) PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) ExecutionTime(io.quarkus.deployment.annotations.ExecutionTime) LoggerFactory(org.slf4j.LoggerFactory) CamelServiceFilterBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilterBuildItem) ContainerBeansBuildItem(org.apache.camel.quarkus.core.deployment.spi.ContainerBeansBuildItem) CamelRegistryBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRegistryBuildItem) CamelServicePatternBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep) List(java.util.List) CamelConfig(org.apache.camel.quarkus.core.CamelConfig) CamelRecorder(org.apache.camel.quarkus.core.CamelRecorder) CamelServiceDestination(org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination) PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) Record(io.quarkus.deployment.annotations.Record) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 2 with CamelServiceFilterBuildItem

use of org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilterBuildItem in project camel-quarkus by apache.

the class CamelProcessor method coreServiceFilter.

/*
     * Configure filters for core services.
     */
@BuildStep
void coreServiceFilter(BuildProducer<CamelServiceFilterBuildItem> filterBuildItems) {
    filterBuildItems.produce(new CamelServiceFilterBuildItem(CamelServiceFilter.forService("properties-component-factory")));
    // The reactive executor is programmatically configured by an extension or
    // a default implementation is provided by this processor thus we can safely
    // prevent loading of this service.
    filterBuildItems.produce(new CamelServiceFilterBuildItem(CamelServiceFilter.forService("reactive-executor")));
}
Also used : CamelServiceFilterBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilterBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

BuildStep (io.quarkus.deployment.annotations.BuildStep)2 CamelServiceFilterBuildItem (org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilterBuildItem)2 ExecutionTime (io.quarkus.deployment.annotations.ExecutionTime)1 Record (io.quarkus.deployment.annotations.Record)1 ApplicationArchivesBuildItem (io.quarkus.deployment.builditem.ApplicationArchivesBuildItem)1 List (java.util.List)1 CamelConfig (org.apache.camel.quarkus.core.CamelConfig)1 CamelRecorder (org.apache.camel.quarkus.core.CamelRecorder)1 CamelBeanBuildItem (org.apache.camel.quarkus.core.deployment.spi.CamelBeanBuildItem)1 CamelContextBuildItem (org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem)1 CamelRegistryBuildItem (org.apache.camel.quarkus.core.deployment.spi.CamelRegistryBuildItem)1 CamelRuntimeBeanBuildItem (org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeBeanBuildItem)1 CamelRuntimeTaskBuildItem (org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeTaskBuildItem)1 CamelServiceDestination (org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination)1 CamelServicePatternBuildItem (org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem)1 ContainerBeansBuildItem (org.apache.camel.quarkus.core.deployment.spi.ContainerBeansBuildItem)1 CamelSupport (org.apache.camel.quarkus.core.deployment.util.CamelSupport)1 PathFilter (org.apache.camel.quarkus.core.deployment.util.PathFilter)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1