Search in sources :

Example 1 with ODataCreateEntityComponent

use of io.syndesis.connector.odata.ODataCreateEntityComponent in project syndesis by syndesisio.

the class ODataCreateEntityConnectorAutoConfiguration method postConstructODataCreateEntityComponent.

@PostConstruct
public void postConstructODataCreateEntityComponent() {
    Map<String, Object> parameters = new HashMap<>();
    for (Map.Entry<String, ODataCreateEntityConnectorConfigurationCommon> entry : configuration.getConfigurations().entrySet()) {
        parameters.clear();
        ODataCreateEntityComponent connector = new ODataCreateEntityComponent(entry.getKey());
        connector.setCamelContext(camelContext);
        try {
            IntrospectionSupport.getProperties(entry.getValue(), parameters, null, false);
            CamelPropertiesHelper.setCamelProperties(camelContext, connector, parameters, false);
            connector.setOptions(parameters);
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (ConnectorCustomizer<ODataCreateEntityComponent> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-create-entity." + entry.getKey() + ".customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-create-entity." + entry.getKey() + ".customizer");
                    if (useCustomizer) {
                        LOGGER.debug("Configure connector {}, with customizer {}", connector, customizer);
                        customizer.customize(connector);
                    }
                }
            }
            camelContext.addComponent(entry.getKey(), connector);
        } catch (Exception e) {
            throw new BeanCreationException(entry.getKey(), e.getMessage(), e);
        }
    }
}
Also used : ODataCreateEntityComponent(io.syndesis.connector.odata.ODataCreateEntityComponent) BeanCreationException(org.springframework.beans.factory.BeanCreationException) HashMap(java.util.HashMap) BeanCreationException(org.springframework.beans.factory.BeanCreationException) HasId(org.apache.camel.spi.HasId) HashMap(java.util.HashMap) Map(java.util.Map) PostConstruct(javax.annotation.PostConstruct)

Example 2 with ODataCreateEntityComponent

use of io.syndesis.connector.odata.ODataCreateEntityComponent in project syndesis by syndesisio.

the class ODataCreateEntityConnectorAutoConfiguration method configureODataCreateEntityComponent.

@Lazy
@Bean(name = "odata-create-entity-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean
public ODataCreateEntityComponent configureODataCreateEntityComponent() throws Exception {
    ODataCreateEntityComponent connector = new ODataCreateEntityComponent();
    connector.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null, false);
    CamelPropertiesHelper.setCamelProperties(camelContext, connector, parameters, false);
    connector.setOptions(parameters);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ConnectorCustomizer<ODataCreateEntityComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-create-entity.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-create-entity.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure connector {}, with customizer {}", connector, customizer);
                customizer.customize(connector);
            }
        }
    }
    return connector;
}
Also used : ODataCreateEntityComponent(io.syndesis.connector.odata.ODataCreateEntityComponent) HasId(org.apache.camel.spi.HasId) HashMap(java.util.HashMap) Lazy(org.springframework.context.annotation.Lazy) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ODataCreateEntityComponent (io.syndesis.connector.odata.ODataCreateEntityComponent)2 HashMap (java.util.HashMap)2 HasId (org.apache.camel.spi.HasId)2 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1 BeanCreationException (org.springframework.beans.factory.BeanCreationException)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 Lazy (org.springframework.context.annotation.Lazy)1