use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project zipkin by openzipkin.
the class TraceZipkinMySQLStorageAutoConfiguration method executor.
@Bean
@ConditionalOnMissingBean(Executor.class)
public Executor executor(ServerSpanState serverState) {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("MySQLStorage-");
executor.initialize();
return command -> {
ServerSpan currentSpan = serverState.getCurrentServerSpan();
executor.execute(() -> {
serverState.setCurrentServerSpan(currentSpan);
command.run();
});
};
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class Base64DataFormatAutoConfiguration method configureBase64DataFormatFactory.
@Bean(name = "base64-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(Base64DataFormat.class)
public DataFormatFactory configureBase64DataFormatFactory(final CamelContext camelContext, final Base64DataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
Base64DataFormat dataformat = new Base64DataFormat();
if (CamelContextAware.class.isAssignableFrom(Base64DataFormat.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.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class BeanValidatorComponentAutoConfiguration method configureBeanValidatorComponent.
@Lazy
@Bean(name = "bean-validator-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BeanValidatorComponent.class)
public BeanValidatorComponent configureBeanValidatorComponent(CamelContext camelContext) throws Exception {
BeanValidatorComponent component = new BeanValidatorComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class BeanstalkComponentAutoConfiguration method configureBeanstalkComponent.
@Lazy
@Bean(name = "beanstalk-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BeanstalkComponent.class)
public BeanstalkComponent configureBeanstalkComponent(CamelContext camelContext, BeanstalkComponentConfiguration configuration) throws Exception {
BeanstalkComponent component = new BeanstalkComponent();
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;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class BindyCsvDataFormatAutoConfiguration method configureBindyCsvDataFormatFactory.
@Bean(name = "bindy-csv-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BindyCsvDataFormat.class)
public DataFormatFactory configureBindyCsvDataFormatFactory(final CamelContext camelContext, final BindyCsvDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
BindyCsvDataFormat dataformat = new BindyCsvDataFormat();
if (CamelContextAware.class.isAssignableFrom(BindyCsvDataFormat.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