use of org.apache.camel.spi.DataFormatFactory in project camel by apache.
the class ProtobufDataFormatAutoConfiguration method configureProtobufDataFormatFactory.
@Bean(name = "protobuf-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ProtobufDataFormat.class)
public DataFormatFactory configureProtobufDataFormatFactory(final CamelContext camelContext, final ProtobufDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
ProtobufDataFormat dataformat = new ProtobufDataFormat();
if (CamelContextAware.class.isAssignableFrom(ProtobufDataFormat.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;
}
};
}
use of org.apache.camel.spi.DataFormatFactory in project camel by apache.
the class DefaultDataFormatResolver method createDataFormat.
@Override
public DataFormat createDataFormat(String name, CamelContext context) {
DataFormat dataFormat = null;
// lookup in registry first
DataFormatFactory dataFormatFactory = ResolverHelper.lookupDataFormatFactoryInRegistryWithFallback(context, name);
if (dataFormatFactory != null) {
dataFormat = dataFormatFactory.newInstance();
}
if (dataFormat == null) {
dataFormat = createDataFormatFromResource(name, context);
}
return dataFormat;
}
use of org.apache.camel.spi.DataFormatFactory 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;
}
};
}
use of org.apache.camel.spi.DataFormatFactory 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;
}
};
}
use of org.apache.camel.spi.DataFormatFactory in project camel by apache.
the class PGPDataFormatAutoConfiguration method configurePGPDataFormatFactory.
@Bean(name = "pgp-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(PGPDataFormat.class)
public DataFormatFactory configurePGPDataFormatFactory(final CamelContext camelContext, final PGPDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
PGPDataFormat dataformat = new PGPDataFormat();
if (CamelContextAware.class.isAssignableFrom(PGPDataFormat.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;
}
};
}
Aggregations