Search in sources :

Example 46 with CamelContextAware

use of org.apache.camel.CamelContextAware in project camel by apache.

the class AvroDataFormatAutoConfiguration method configureAvroDataFormatFactory.

@Bean(name = "avro-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(AvroDataFormat.class)
public DataFormatFactory configureAvroDataFormatFactory(final CamelContext camelContext, final AvroDataFormatConfiguration configuration) {
    return new DataFormatFactory() {

        public DataFormat newInstance() {
            AvroDataFormat dataformat = new AvroDataFormat();
            if (CamelContextAware.class.isAssignableFrom(AvroDataFormat.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);
                IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, parameters);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            return dataformat;
        }
    };
}
Also used : DataFormatFactory(org.apache.camel.spi.DataFormatFactory) CamelContextAware(org.apache.camel.CamelContextAware) HashMap(java.util.HashMap) AvroDataFormat(org.apache.camel.dataformat.avro.AvroDataFormat) RuntimeCamelException(org.apache.camel.RuntimeCamelException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) 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 47 with CamelContextAware

use of org.apache.camel.CamelContextAware in project camel by apache.

the class RssDataFormatAutoConfiguration method configureRssDataFormatFactory.

@Bean(name = "rss-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(RssDataFormat.class)
public DataFormatFactory configureRssDataFormatFactory(final CamelContext camelContext, final RssDataFormatConfiguration configuration) {
    return new DataFormatFactory() {

        public DataFormat newInstance() {
            RssDataFormat dataformat = new RssDataFormat();
            if (CamelContextAware.class.isAssignableFrom(RssDataFormat.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);
                IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, parameters);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            return dataformat;
        }
    };
}
Also used : DataFormatFactory(org.apache.camel.spi.DataFormatFactory) CamelContextAware(org.apache.camel.CamelContextAware) HashMap(java.util.HashMap) RssDataFormat(org.apache.camel.dataformat.rss.RssDataFormat) RuntimeCamelException(org.apache.camel.RuntimeCamelException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) 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 48 with CamelContextAware

use of org.apache.camel.CamelContextAware in project camel by apache.

the class XQueryLanguageAutoConfiguration method configureXQueryLanguage.

@Bean(name = "xquery-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(XQueryLanguage.class)
public XQueryLanguage configureXQueryLanguage(CamelContext camelContext, XQueryLanguageConfiguration configuration) throws Exception {
    XQueryLanguage language = new XQueryLanguage();
    if (CamelContextAware.class.isAssignableFrom(XQueryLanguage.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);
    IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), language, parameters);
    return language;
}
Also used : CamelContextAware(org.apache.camel.CamelContextAware) HashMap(java.util.HashMap) XQueryLanguage(org.apache.camel.language.xquery.XQueryLanguage) Scope(org.springframework.context.annotation.Scope) 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 49 with CamelContextAware

use of org.apache.camel.CamelContextAware in project camel by apache.

the class JavaScriptLanguageAutoConfiguration method configureJavaScriptLanguage.

@Bean(name = "javaScript-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JavaScriptLanguage.class)
public JavaScriptLanguage configureJavaScriptLanguage(CamelContext camelContext, JavaScriptLanguageConfiguration configuration) throws Exception {
    JavaScriptLanguage language = new JavaScriptLanguage();
    if (CamelContextAware.class.isAssignableFrom(JavaScriptLanguage.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);
    IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), language, parameters);
    return language;
}
Also used : JavaScriptLanguage(org.apache.camel.builder.script.JavaScriptLanguage) CamelContextAware(org.apache.camel.CamelContextAware) HashMap(java.util.HashMap) Scope(org.springframework.context.annotation.Scope) 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 50 with CamelContextAware

use of org.apache.camel.CamelContextAware in project camel by apache.

the class XmlJsonDataFormatAutoConfiguration method configureXmlJsonDataFormatFactory.

@Bean(name = "xmljson-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(XmlJsonDataFormat.class)
public DataFormatFactory configureXmlJsonDataFormatFactory(final CamelContext camelContext, final XmlJsonDataFormatConfiguration configuration) {
    return new DataFormatFactory() {

        public DataFormat newInstance() {
            XmlJsonDataFormat dataformat = new XmlJsonDataFormat();
            if (CamelContextAware.class.isAssignableFrom(XmlJsonDataFormat.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);
                IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, parameters);
            } catch (Exception e) {
                throw new RuntimeCamelException(e);
            }
            return dataformat;
        }
    };
}
Also used : DataFormatFactory(org.apache.camel.spi.DataFormatFactory) CamelContextAware(org.apache.camel.CamelContextAware) HashMap(java.util.HashMap) RuntimeCamelException(org.apache.camel.RuntimeCamelException) XmlJsonDataFormat(org.apache.camel.dataformat.xmljson.XmlJsonDataFormat) RuntimeCamelException(org.apache.camel.RuntimeCamelException) 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

CamelContextAware (org.apache.camel.CamelContextAware)82 HashMap (java.util.HashMap)70 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)69 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)69 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)69 Bean (org.springframework.context.annotation.Bean)69 RuntimeCamelException (org.apache.camel.RuntimeCamelException)47 DataFormatFactory (org.apache.camel.spi.DataFormatFactory)45 Scope (org.springframework.context.annotation.Scope)24 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 CamelContext (org.apache.camel.CamelContext)3 Service (org.apache.camel.Service)3 StatefulService (org.apache.camel.StatefulService)3 SuspendableService (org.apache.camel.SuspendableService)3 IOException (java.io.IOException)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 FailedToStartRouteException (org.apache.camel.FailedToStartRouteException)2 IsSingleton (org.apache.camel.IsSingleton)2 NoFactoryAvailableException (org.apache.camel.NoFactoryAvailableException)2 NoSuchEndpointException (org.apache.camel.NoSuchEndpointException)2