Search in sources :

Example 26 with ConditionalOnMissingBean

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();
        });
    };
}
Also used : ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) ZipkinMySQLStorageProperties(zipkin.autoconfigure.storage.mysql.ZipkinMySQLStorageProperties) Executor(java.util.concurrent.Executor) Brave(com.github.kristofa.brave.Brave) ServerSpanState(com.github.kristofa.brave.ServerSpanState) Endpoint(com.twitter.zipkin.gen.Endpoint) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.jooq.tools.StringUtils) ServerSpan(com.github.kristofa.brave.ServerSpan) UnknownHostException(java.net.UnknownHostException) ByteBuffer(java.nio.ByteBuffer) InetAddress(java.net.InetAddress) Configuration(org.springframework.context.annotation.Configuration) ExecuteContext(org.jooq.ExecuteContext) DefaultExecuteListener(org.jooq.impl.DefaultExecuteListener) Qualifier(org.springframework.beans.factory.annotation.Qualifier) SQL_QUERY(zipkin.TraceKeys.SQL_QUERY) ExecuteListenerProvider(org.jooq.ExecuteListenerProvider) Lazy(org.springframework.context.annotation.Lazy) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty) DefaultExecuteListenerProvider(org.jooq.impl.DefaultExecuteListenerProvider) ServerSpan(com.github.kristofa.brave.ServerSpan) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 27 with ConditionalOnMissingBean

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;
        }
    };
}
Also used : DataFormatFactory(org.apache.camel.spi.DataFormatFactory) CamelContextAware(org.apache.camel.CamelContextAware) HashMap(java.util.HashMap) Base64DataFormat(org.apache.camel.dataformat.base64.Base64DataFormat) 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 28 with ConditionalOnMissingBean

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;
}
Also used : BeanValidatorComponent(org.apache.camel.component.bean.validator.BeanValidatorComponent) Lazy(org.springframework.context.annotation.Lazy) 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 29 with ConditionalOnMissingBean

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;
}
Also used : BeanstalkComponent(org.apache.camel.component.beanstalk.BeanstalkComponent) HashMap(java.util.HashMap) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) HashMap(java.util.HashMap) Map(java.util.Map) Lazy(org.springframework.context.annotation.Lazy) 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 30 with ConditionalOnMissingBean

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;
        }
    };
}
Also used : BindyCsvDataFormat(org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat) DataFormatFactory(org.apache.camel.spi.DataFormatFactory) 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)

Aggregations

ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)807 Bean (org.springframework.context.annotation.Bean)807 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)339 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)298 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)251 Lazy (org.springframework.context.annotation.Lazy)227 lombok.val (lombok.val)210 HashMap (java.util.HashMap)190 Map (java.util.Map)113 CamelContextAware (org.apache.camel.CamelContextAware)69 RuntimeCamelException (org.apache.camel.RuntimeCamelException)45 DataFormatFactory (org.apache.camel.spi.DataFormatFactory)45 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)29 Scope (org.springframework.context.annotation.Scope)26 Autowired (org.springframework.beans.factory.annotation.Autowired)23 Configuration (org.springframework.context.annotation.Configuration)21 Qualifier (org.springframework.beans.factory.annotation.Qualifier)20 DefaultChainingMultifactorAuthenticationBypassProvider (org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider)19 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)19 AuthenticationMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.AuthenticationMultifactorAuthenticationProviderBypassEvaluator)17