public void process()

in components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java [1121:1205]


        public void process(ComponentDefinitionRegistry componentDefinitionRegistry) {
            CamelContextFactoryBean ccfb = (CamelContextFactoryBean) blueprintContainer.getComponentInstance(".camelBlueprint.factory." + camelContextName);
            CamelContext camelContext = ccfb.getContext();

            Set<String> components = new HashSet<>();
            Set<String> languages = new HashSet<>();
            Set<String> dataformats = new HashSet<>();

            // regular camel routes
            for (RouteDefinition rd : camelContext.getCamelContextExtension().getContextPlugin(Model.class).getRouteDefinitions()) {
                findInputComponents(rd.getInput(), components, languages, dataformats);
                findOutputComponents(rd.getOutputs(), components, languages, dataformats);
            }

            // rest services can have embedded routes or a singular to
            for (RestDefinition rd : camelContext.getCamelContextExtension().getContextPlugin(Model.class).getRestDefinitions()) {
                for (VerbDefinition vd : rd.getVerbs()) {
                    ToDefinition to = vd.getTo();
                    if (to != null) {
                        findUriComponent(to.getUri(), components);
                    }
                }
            }

            if (ccfb.getRestConfiguration() != null) {
                // rest configuration may refer to a component to use
                String component = ccfb.getRestConfiguration().getComponent();
                if (component != null) {
                    components.add(component);
                }
                component = ccfb.getRestConfiguration().getApiComponent();
                if (component != null) {
                    components.add(component);
                }

                // check what data formats are used in binding mode
                RestBindingMode mode = ccfb.getRestConfiguration().getBindingMode();
                String json = ccfb.getRestConfiguration().getJsonDataFormat();
                if (json == null && mode != null) {
                    if (RestBindingMode.json.equals(mode) || RestBindingMode.json_xml.equals(mode)) {
                        // jackson is the default json data format
                        json = "jackson";
                    }
                }
                if (json != null) {
                    dataformats.add(json);
                }
                String xml = ccfb.getRestConfiguration().getXmlDataFormat();
                if (xml == null && mode != null) {
                    if (RestBindingMode.xml.equals(mode) || RestBindingMode.json_xml.equals(mode)) {
                        // jaxb is the default xml data format
                        dataformats.add("jaxb");
                    }
                }
                if (xml != null) {
                    dataformats.add(xml);
                }
            }

            // We can only add service references to resolvers, but we can't make the factory depends on those
            // because the factory has already been instantiated
            try {
                for (String component : components) {
                    if (camelContext.getComponent(component, false) == null) {
                        // component not already in camel-context so resolve an OSGi reference to it
                        getComponentResolverReference(context, component);
                    } else {
                        LOG.debug("Not creating a service reference for component {} because a component already exists in the Camel Context", component);
                    }
                }
                for (String language : languages) {
                    getLanguageResolverReference(context, language);
                }
                for (String dataformat : dataformats) {
                    getDataformatResolverReference(context, dataformat);
                }
            } catch (UnsupportedOperationException e) {
                LOG.warn("Unable to add dependencies to Camel components OSGi services. "
                        + "The Apache Aries blueprint implementation used is too old and the blueprint bundle cannot see the org.apache.camel.spi package.");
                components.clear();
                languages.clear();
                dataformats.clear();
            }

        }