Search in sources :

Example 56 with CamelContextAware

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

the class TarFileDataFormatAutoConfiguration method configureTarFileDataFormatFactory.

@Bean(name = "tarfile-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(TarFileDataFormat.class)
public DataFormatFactory configureTarFileDataFormatFactory(final CamelContext camelContext, final TarFileDataFormatConfiguration configuration) {
    return new DataFormatFactory() {

        public DataFormat newInstance() {
            TarFileDataFormat dataformat = new TarFileDataFormat();
            if (CamelContextAware.class.isAssignableFrom(TarFileDataFormat.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) TarFileDataFormat(org.apache.camel.dataformat.tarfile.TarFileDataFormat) CamelContextAware(org.apache.camel.CamelContextAware) HashMap(java.util.HashMap) 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 57 with CamelContextAware

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

the class UniVocityCsvDataFormatAutoConfiguration method configureUniVocityCsvDataFormatFactory.

@Bean(name = "univocity-csv-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(UniVocityCsvDataFormat.class)
public DataFormatFactory configureUniVocityCsvDataFormatFactory(final CamelContext camelContext, final UniVocityCsvDataFormatConfiguration configuration) {
    return new DataFormatFactory() {

        public DataFormat newInstance() {
            UniVocityCsvDataFormat dataformat = new UniVocityCsvDataFormat();
            if (CamelContextAware.class.isAssignableFrom(UniVocityCsvDataFormat.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) UniVocityCsvDataFormat(org.apache.camel.dataformat.univocity.UniVocityCsvDataFormat) CamelContextAware(org.apache.camel.CamelContextAware) HashMap(java.util.HashMap) 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 58 with CamelContextAware

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

the class UniVocityFixedWidthDataFormatAutoConfiguration method configureUniVocityFixedWidthDataFormatFactory.

@Bean(name = "univocity-fixed-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(UniVocityFixedWidthDataFormat.class)
public DataFormatFactory configureUniVocityFixedWidthDataFormatFactory(final CamelContext camelContext, final UniVocityFixedWidthDataFormatConfiguration configuration) {
    return new DataFormatFactory() {

        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);
                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) UniVocityFixedWidthDataFormat(org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormat) 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 59 with CamelContextAware

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

the class SerializationDataFormatAutoConfiguration method configureSerializationDataFormatFactory.

@Bean(name = "serialization-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(SerializationDataFormat.class)
public DataFormatFactory configureSerializationDataFormatFactory(final CamelContext camelContext, final SerializationDataFormatConfiguration configuration) {
    return new DataFormatFactory() {

        public DataFormat newInstance() {
            SerializationDataFormat dataformat = new SerializationDataFormat();
            if (CamelContextAware.class.isAssignableFrom(SerializationDataFormat.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) SerializationDataFormat(org.apache.camel.impl.SerializationDataFormat) HashMap(java.util.HashMap) 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 60 with CamelContextAware

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

the class StringDataFormatAutoConfiguration method configureStringDataFormatFactory.

@Bean(name = "string-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(StringDataFormat.class)
public DataFormatFactory configureStringDataFormatFactory(final CamelContext camelContext, final StringDataFormatConfiguration configuration) {
    return new DataFormatFactory() {

        public DataFormat newInstance() {
            StringDataFormat dataformat = new StringDataFormat();
            if (CamelContextAware.class.isAssignableFrom(StringDataFormat.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) StringDataFormat(org.apache.camel.impl.StringDataFormat) 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)

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