Search in sources :

Example 1 with BindyKeyValuePairDataFormat

use of org.apache.camel.dataformat.bindy.kvp.BindyKeyValuePairDataFormat in project camel by apache.

the class BindyComplexKeyValuePairStandaloneTest method init.

@Before
public void init() throws Exception {
    // Set factory
    BindyKeyValuePairDataFormat dataFormat = new BindyKeyValuePairDataFormat(org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Order.class);
    factory = dataFormat.getFactory();
    // Set model class
    models.add(org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Order.class);
    models.add(org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Header.class);
    // f.models.add(org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Security.class);
    models.add(org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Trailer.class);
    // Init model
    model.put("org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Order", new Order());
    model.put("org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Header", new Header());
    model.put("org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Trailer", new Trailer());
    // set counter = 1
    counter = 1;
}
Also used : Order(org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Order) Header(org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Header) BindyKeyValuePairDataFormat(org.apache.camel.dataformat.bindy.kvp.BindyKeyValuePairDataFormat) Trailer(org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Trailer) Before(org.junit.Before)

Example 2 with BindyKeyValuePairDataFormat

use of org.apache.camel.dataformat.bindy.kvp.BindyKeyValuePairDataFormat in project camel by apache.

the class BindyKeyValuePairDataFormatAutoConfiguration method configureBindyKeyValuePairDataFormatFactory.

@Bean(name = "bindy-kvp-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BindyKeyValuePairDataFormat.class)
public DataFormatFactory configureBindyKeyValuePairDataFormatFactory(final CamelContext camelContext, final BindyKeyValuePairDataFormatConfiguration configuration) {
    return new DataFormatFactory() {

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

BindyKeyValuePairDataFormat (org.apache.camel.dataformat.bindy.kvp.BindyKeyValuePairDataFormat)2 HashMap (java.util.HashMap)1 CamelContextAware (org.apache.camel.CamelContextAware)1 RuntimeCamelException (org.apache.camel.RuntimeCamelException)1 Header (org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Header)1 Order (org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Order)1 Trailer (org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Trailer)1 DataFormatFactory (org.apache.camel.spi.DataFormatFactory)1 Before (org.junit.Before)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