Search in sources :

Example 81 with ConditionalOnClass

use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.

the class FtpComponentAutoConfiguration method configureFtpComponent.

@Lazy
@Bean(name = "ftp-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(FtpComponent.class)
public FtpComponent configureFtpComponent(CamelContext camelContext) throws Exception {
    FtpComponent component = new FtpComponent();
    component.setCamelContext(camelContext);
    return component;
}
Also used : FtpComponent(org.apache.camel.component.file.remote.FtpComponent) 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 82 with ConditionalOnClass

use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.

the class GitHubComponentAutoConfiguration method configureGitHubComponent.

@Lazy
@Bean(name = "github-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(GitHubComponent.class)
public GitHubComponent configureGitHubComponent(CamelContext camelContext) throws Exception {
    GitHubComponent component = new GitHubComponent();
    component.setCamelContext(camelContext);
    return component;
}
Also used : GitHubComponent(org.apache.camel.component.github.GitHubComponent) 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 83 with ConditionalOnClass

use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.

the class JcrComponentAutoConfiguration method configureJcrComponent.

@Lazy
@Bean(name = "jcr-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JcrComponent.class)
public JcrComponent configureJcrComponent(CamelContext camelContext) throws Exception {
    JcrComponent component = new JcrComponent();
    component.setCamelContext(camelContext);
    return component;
}
Also used : JcrComponent(org.apache.camel.component.jcr.JcrComponent) 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 84 with ConditionalOnClass

use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.

the class JdbcComponentAutoConfiguration method configureJdbcComponent.

@Lazy
@Bean(name = "jdbc-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JdbcComponent.class)
public JdbcComponent configureJdbcComponent(CamelContext camelContext, JdbcComponentConfiguration configuration) throws Exception {
    JdbcComponent component = new JdbcComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null, false);
    for (Map.Entry<String, Object> entry : parameters.entrySet()) {
        Object value = entry.getValue();
        Class<?> paramClass = value.getClass();
        if (paramClass.getName().endsWith("NestedConfiguration")) {
            Class nestedClass = null;
            try {
                nestedClass = (Class) paramClass.getDeclaredField("CAMEL_NESTED_CLASS").get(null);
                HashMap<String, Object> nestedParameters = new HashMap<>();
                IntrospectionSupport.getProperties(value, nestedParameters, null, false);
                Object nestedProperty = nestedClass.newInstance();
                IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), nestedProperty, nestedParameters);
                entry.setValue(nestedProperty);
            } catch (NoSuchFieldException e) {
            }
        }
    }
    IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters);
    return component;
}
Also used : HashMap(java.util.HashMap) JdbcComponent(org.apache.camel.component.jdbc.JdbcComponent) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) HashMap(java.util.HashMap) Map(java.util.Map) 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 85 with ConditionalOnClass

use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.

the class JettyHttpComponentAutoConfiguration9 method configureJettyHttpComponent9.

@Lazy
@Bean(name = "jetty-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JettyHttpComponent9.class)
public JettyHttpComponent9 configureJettyHttpComponent9(CamelContext camelContext, JettyHttpComponentConfiguration9 configuration) throws Exception {
    JettyHttpComponent9 component = new JettyHttpComponent9();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null, false);
    for (Map.Entry<String, Object> entry : parameters.entrySet()) {
        Object value = entry.getValue();
        Class<?> paramClass = value.getClass();
        if (paramClass.getName().endsWith("NestedConfiguration")) {
            Class nestedClass = null;
            try {
                nestedClass = (Class) paramClass.getDeclaredField("CAMEL_NESTED_CLASS").get(null);
                HashMap<String, Object> nestedParameters = new HashMap<>();
                IntrospectionSupport.getProperties(value, nestedParameters, null, false);
                Object nestedProperty = nestedClass.newInstance();
                IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), nestedProperty, nestedParameters);
                entry.setValue(nestedProperty);
            } catch (NoSuchFieldException e) {
            }
        }
    }
    IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters);
    return component;
}
Also used : JettyHttpComponent9(org.apache.camel.component.jetty9.JettyHttpComponent9) HashMap(java.util.HashMap) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) HashMap(java.util.HashMap) Map(java.util.Map) 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

ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)296 Bean (org.springframework.context.annotation.Bean)296 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)295 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)290 Lazy (org.springframework.context.annotation.Lazy)223 HashMap (java.util.HashMap)183 Map (java.util.Map)106 CamelContextAware (org.apache.camel.CamelContextAware)69 RuntimeCamelException (org.apache.camel.RuntimeCamelException)45 DataFormatFactory (org.apache.camel.spi.DataFormatFactory)45 Scope (org.springframework.context.annotation.Scope)24 JavaScriptLanguage (org.apache.camel.builder.script.JavaScriptLanguage)1 PhpLanguage (org.apache.camel.builder.script.PhpLanguage)1 PythonLanguage (org.apache.camel.builder.script.PythonLanguage)1 RubyLanguage (org.apache.camel.builder.script.RubyLanguage)1 CoAPComponent (org.apache.camel.coap.CoAPComponent)1 AhcComponent (org.apache.camel.component.ahc.AhcComponent)1 WsComponent (org.apache.camel.component.ahc.ws.WsComponent)1 AMQPComponent (org.apache.camel.component.amqp.AMQPComponent)1 ApnsComponent (org.apache.camel.component.apns.ApnsComponent)1