Search in sources :

Example 1 with HasId

use of org.apache.camel.spi.HasId in project syndesis by syndesisio.

the class SwaggerConnectorConnectorAutoConfiguration method postConstructSwaggerConnectorComponent.

@PostConstruct
public void postConstructSwaggerConnectorComponent() {
    Map<String, Object> parameters = new HashMap<>();
    for (Map.Entry<String, SwaggerConnectorConnectorConfigurationCommon> entry : configuration.getConfigurations().entrySet()) {
        parameters.clear();
        SwaggerConnectorComponent connector = new SwaggerConnectorComponent(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<SwaggerConnectorComponent> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.swagger-operation." + entry.getKey() + ".customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.swagger-operation." + 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 : BeanCreationException(org.springframework.beans.factory.BeanCreationException) HashMap(java.util.HashMap) SwaggerConnectorComponent(io.syndesis.connector.rest.swagger.SwaggerConnectorComponent) 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 HasId

use of org.apache.camel.spi.HasId 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 3 with HasId

use of org.apache.camel.spi.HasId 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)

Example 4 with HasId

use of org.apache.camel.spi.HasId in project syndesis by syndesisio.

the class ODataDeleteEntityConnectorAutoConfiguration method postConstructODataDeleteEntityComponent.

@PostConstruct
public void postConstructODataDeleteEntityComponent() {
    Map<String, Object> parameters = new HashMap<>();
    for (Map.Entry<String, ODataDeleteEntityConnectorConfigurationCommon> entry : configuration.getConfigurations().entrySet()) {
        parameters.clear();
        ODataDeleteEntityComponent connector = new ODataDeleteEntityComponent(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<ODataDeleteEntityComponent> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-delete-entity." + entry.getKey() + ".customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-delete-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 : BeanCreationException(org.springframework.beans.factory.BeanCreationException) ODataDeleteEntityComponent(io.syndesis.connector.odata.ODataDeleteEntityComponent) 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 5 with HasId

use of org.apache.camel.spi.HasId in project syndesis by syndesisio.

the class ODataRetrieveEntityConnectorAutoConfiguration method configureODataRetrieveEntityComponent.

@Lazy
@Bean(name = "odata-retrieve-entity-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean
public ODataRetrieveEntityComponent configureODataRetrieveEntityComponent() throws Exception {
    ODataRetrieveEntityComponent connector = new ODataRetrieveEntityComponent();
    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<ODataRetrieveEntityComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-retrieve-entity.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-retrieve-entity.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure connector {}, with customizer {}", connector, customizer);
                customizer.customize(connector);
            }
        }
    }
    return connector;
}
Also used : HasId(org.apache.camel.spi.HasId) ODataRetrieveEntityComponent(io.syndesis.connector.odata.ODataRetrieveEntityComponent) 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

HashMap (java.util.HashMap)12 HasId (org.apache.camel.spi.HasId)12 Map (java.util.Map)6 PostConstruct (javax.annotation.PostConstruct)6 BeanCreationException (org.springframework.beans.factory.BeanCreationException)6 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)6 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)6 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)6 Bean (org.springframework.context.annotation.Bean)6 Lazy (org.springframework.context.annotation.Lazy)6 ODataCreateEntityComponent (io.syndesis.connector.odata.ODataCreateEntityComponent)2 ODataDeleteEntityComponent (io.syndesis.connector.odata.ODataDeleteEntityComponent)2 ODataReplaceEntityComponent (io.syndesis.connector.odata.ODataReplaceEntityComponent)2 ODataRetrieveEntityComponent (io.syndesis.connector.odata.ODataRetrieveEntityComponent)2 ODataUpdateEntityComponent (io.syndesis.connector.odata.ODataUpdateEntityComponent)2 SwaggerConnectorComponent (io.syndesis.connector.rest.swagger.SwaggerConnectorComponent)2