Java Code Examples for org.apache.camel.CamelContextAware#setCamelContext()

The following examples show how to use org.apache.camel.CamelContextAware#setCamelContext() . 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: KnativeComponent.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
@Override
protected void doInit() throws Exception {
    super.doInit();

    if (transport == null) {
        this.transport = getCamelContext().getRegistry().lookupByNameAndType(protocol.name(), KnativeTransport.class);

        if (this.transport == null) {
            this.transport = getCamelContext()
                .adapt(ExtendedCamelContext.class)
                .getFactoryFinder(Knative.KNATIVE_TRANSPORT_RESOURCE_PATH)
                .newInstance(protocol.name(), KnativeTransport.class)
                .orElseThrow(() -> new RuntimeException("Error creating knative transport for protocol: " + protocol.name()));
        }
    }

    if (this.transport instanceof CamelContextAware) {
        CamelContextAware camelContextAware = (CamelContextAware)this.transport;

        if (camelContextAware.getCamelContext() == null) {
            camelContextAware.setCamelContext(getCamelContext());
        }
    }

    LOGGER.info("found knative transport: {} for protocol: {}", transport, protocol.name());
}
 
Example 2
Source File: XPathLanguageAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Bean(name = "xpath-language")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ConditionalOnMissingBean(XPathLanguage.class)
public XPathLanguage configureXPathLanguage() throws Exception {
    XPathLanguage language = new XPathLanguage();
    if (CamelContextAware.class.isAssignableFrom(XPathLanguage.class)) {
        CamelContextAware contextAware = CamelContextAware.class
                .cast(language);
        if (contextAware != null) {
            contextAware.setCamelContext(camelContext);
        }
    }
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, language,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (LanguageCustomizer<XPathLanguage> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.language.customizer",
                            "camel.language.xpath.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.language.customizer",
                            "camel.language.xpath.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure language {}, with customizer {}",
                        language, customizer);
                customizer.customize(language);
            }
        }
    }
    return language;
}
 
Example 3
Source File: MvelLanguageAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Bean(name = "mvel-language")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ConditionalOnMissingBean(MvelLanguage.class)
public MvelLanguage configureMvelLanguage() throws Exception {
    MvelLanguage language = new MvelLanguage();
    if (CamelContextAware.class.isAssignableFrom(MvelLanguage.class)) {
        CamelContextAware contextAware = CamelContextAware.class
                .cast(language);
        if (contextAware != null) {
            contextAware.setCamelContext(camelContext);
        }
    }
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, language,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (LanguageCustomizer<MvelLanguage> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.language.customizer",
                            "camel.language.mvel.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.language.customizer",
                            "camel.language.mvel.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure language {}, with customizer {}",
                        language, customizer);
                customizer.customize(language);
            }
        }
    }
    return language;
}
 
Example 4
Source File: GsonDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "json-gson-dataformat-factory")
@ConditionalOnMissingBean(GsonDataFormat.class)
public DataFormatFactory configureGsonDataFormatFactory() throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            GsonDataFormat dataformat = new GsonDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(GsonDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<GsonDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.json-gson.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.json-gson.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 5
Source File: XStreamDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "xstream-dataformat-factory")
@ConditionalOnMissingBean(XStreamDataFormat.class)
public DataFormatFactory configureXStreamDataFormatFactory() throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            XStreamDataFormat dataformat = new XStreamDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(XStreamDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<XStreamDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.xstream.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.xstream.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 6
Source File: JsonApiDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "jsonApi-dataformat-factory")
@ConditionalOnMissingBean(JsonApiDataFormat.class)
public DataFormatFactory configureJsonApiDataFormatFactory() throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            JsonApiDataFormat dataformat = new JsonApiDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(JsonApiDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<JsonApiDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.jsonapi.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.jsonapi.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 7
Source File: BindyKeyValuePairDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "bindy-kvp-dataformat-factory")
@ConditionalOnMissingBean(BindyKeyValuePairDataFormat.class)
public DataFormatFactory configureBindyKeyValuePairDataFormatFactory()
        throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            BindyKeyValuePairDataFormat dataformat = new BindyKeyValuePairDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(BindyKeyValuePairDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<BindyKeyValuePairDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.bindy-kvp.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.bindy-kvp.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 8
Source File: UniVocityFixedWidthDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "univocity-fixed-dataformat-factory")
@ConditionalOnMissingBean(UniVocityFixedWidthDataFormat.class)
public DataFormatFactory configureUniVocityFixedWidthDataFormatFactory()
        throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            UniVocityFixedWidthDataFormat dataformat = new UniVocityFixedWidthDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(UniVocityFixedWidthDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<UniVocityFixedWidthDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.univocity-fixed.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.univocity-fixed.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 9
Source File: JacksonXMLDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "jacksonxml-dataformat-factory")
@ConditionalOnMissingBean(JacksonXMLDataFormat.class)
public DataFormatFactory configureJacksonXMLDataFormatFactory()
        throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            JacksonXMLDataFormat dataformat = new JacksonXMLDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(JacksonXMLDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<JacksonXMLDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.jacksonxml.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.jacksonxml.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 10
Source File: JsonDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "json-xstream-dataformat-factory")
@ConditionalOnMissingBean(JsonDataFormat.class)
public DataFormatFactory configureJsonDataFormatFactory() throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            JsonDataFormat dataformat = new JsonDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(JsonDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<JsonDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.json-xstream.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.json-xstream.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 11
Source File: FlatpackDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "flatpack-dataformat-factory")
@ConditionalOnMissingBean(FlatpackDataFormat.class)
public DataFormatFactory configureFlatpackDataFormatFactory()
        throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            FlatpackDataFormat dataformat = new FlatpackDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(FlatpackDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<FlatpackDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.flatpack.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.flatpack.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 12
Source File: BindyFixedLengthDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "bindy-fixed-dataformat-factory")
@ConditionalOnMissingBean(BindyFixedLengthDataFormat.class)
public DataFormatFactory configureBindyFixedLengthDataFormatFactory()
        throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            BindyFixedLengthDataFormat dataformat = new BindyFixedLengthDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(BindyFixedLengthDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<BindyFixedLengthDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.bindy-fixed.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.bindy-fixed.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 13
Source File: TidyMarkupDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "tidyMarkup-dataformat-factory")
@ConditionalOnMissingBean(TidyMarkupDataFormat.class)
public DataFormatFactory configureTidyMarkupDataFormatFactory()
        throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            TidyMarkupDataFormat dataformat = new TidyMarkupDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(TidyMarkupDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<TidyMarkupDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.tidymarkup.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.tidymarkup.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 14
Source File: SoapJaxbDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "soapjaxb-dataformat-factory")
@ConditionalOnMissingBean(SoapJaxbDataFormat.class)
public DataFormatFactory configureSoapJaxbDataFormatFactory()
        throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            SoapJaxbDataFormat dataformat = new SoapJaxbDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(SoapJaxbDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<SoapJaxbDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.soapjaxb.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.soapjaxb.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 15
Source File: BeanIODataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "beanio-dataformat-factory")
@ConditionalOnMissingBean(BeanIODataFormat.class)
public DataFormatFactory configureBeanIODataFormatFactory() throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            BeanIODataFormat dataformat = new BeanIODataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(BeanIODataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<BeanIODataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.beanio.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.beanio.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 16
Source File: BarcodeDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "barcode-dataformat-factory")
@ConditionalOnMissingBean(BarcodeDataFormat.class)
public DataFormatFactory configureBarcodeDataFormatFactory() throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            BarcodeDataFormat dataformat = new BarcodeDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(BarcodeDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<BarcodeDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.barcode.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.barcode.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 17
Source File: JacksonDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "json-jackson-dataformat-factory")
@ConditionalOnMissingBean(JacksonDataFormat.class)
public DataFormatFactory configureJacksonDataFormatFactory() throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            JacksonDataFormat dataformat = new JacksonDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(JacksonDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<JacksonDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.json-jackson.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.json-jackson.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 18
Source File: PGPDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "pgp-dataformat-factory")
@ConditionalOnMissingBean(PGPDataFormat.class)
public DataFormatFactory configurePGPDataFormatFactory() throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            PGPDataFormat dataformat = new PGPDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(PGPDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<PGPDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.pgp.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.pgp.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 19
Source File: CryptoDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "crypto-dataformat-factory")
@ConditionalOnMissingBean(CryptoDataFormat.class)
public DataFormatFactory configureCryptoDataFormatFactory() throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            CryptoDataFormat dataformat = new CryptoDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(CryptoDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<CryptoDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.crypto.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.crypto.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}
 
Example 20
Source File: CBORDataFormatAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "cbor-dataformat-factory")
@ConditionalOnMissingBean(CBORDataFormat.class)
public DataFormatFactory configureCBORDataFormatFactory() throws Exception {
    return new DataFormatFactory() {
        @Override
        public DataFormat newInstance() {
            CBORDataFormat dataformat = new CBORDataFormat();
            if (CamelContextAware.class
                    .isAssignableFrom(CBORDataFormat.class)) {
                CamelContextAware contextAware = CamelContextAware.class
                        .cast(dataformat);
                if (contextAware != null) {
                    contextAware.setCamelContext(camelContext);
                }
            }
            try {
                Map<String, Object> parameters = new HashMap<>();
                IntrospectionSupport.getProperties(configuration,
                        parameters, null, false);
                CamelPropertiesHelper.setCamelProperties(camelContext,
                        dataformat, parameters, false);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (DataFormatCustomizer<CBORDataFormat> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId)
                            ? HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.cbor.customizer",
                                    ((HasId) customizer).getId())
                            : HierarchicalPropertiesEvaluator.evaluate(
                                    applicationContext.getEnvironment(),
                                    "camel.dataformat.customizer",
                                    "camel.dataformat.cbor.customizer");
                    if (useCustomizer) {
                        LOGGER.debug(
                                "Configure dataformat {}, with customizer {}",
                                dataformat, customizer);
                        customizer.customize(dataformat);
                    }
                }
            }
            return dataformat;
        }
    };
}