org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JacksonConfig.java    From xmall with MIT License 7 votes vote down vote up
@Bean
    @Primary
    @ConditionalOnMissingBean(ObjectMapper.class)
    public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
        ObjectMapper objectMapper = builder.createXmlMapper(false).build();

        // 通过该方法对mapper对象进行设置,所有序列化的对象都将按改规则进行系列化
        // Include.Include.ALWAYS 默认
        // Include.NON_DEFAULT 属性为默认值不序列化
        // Include.NON_EMPTY 属性为 空("") 或者为 NULL 都不序列化,则返回的json是没有这个字段的。这样对移动端会更省流量
        // Include.NON_NULL 属性为NULL 不序列化,就是为null的字段不参加序列化
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

        // 字段保留,将null值转为""
//        objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>()
//        {
//            @Override
//            public void serialize(Object o, JsonGenerator jsonGenerator,
//                                  SerializerProvider serializerProvider)
//                    throws IOException, JsonProcessingException
//            {
//                jsonGenerator.writeString("");
//            }
//        });
        return objectMapper;
    }
 
Example #2
Source File: AliYunOSSAutoConfiguration.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public ClientBuilderConfiguration clientConfiguration(OSSProperties ossProperties) {
	Properties properties = asProperties(ossProperties.getProperties());
	ClientBuilderConfiguration configuration = new ClientBuilderConfiguration();
	configuration.setMaxConnections(Integer.parseInt(properties.getProperty("aliyun.maxConnections", "5")));
	configuration.setSocketTimeout(Integer.parseInt(properties.getProperty("aliyun.socketTimeout", "50000")));
	configuration
			.setConnectionTimeout(Integer.parseInt(properties.getProperty("aliyun.connectionTimeout", "50000")));
	configuration.setConnectionRequestTimeout(
			Integer.parseInt(properties.getProperty("aliyun.connectionRequestTimeout", "-1")));
	configuration
			.setIdleConnectionTime(Integer.parseInt(properties.getProperty("aliyun.idleConnectionTime", "60000")));
	configuration.setMaxErrorRetry(Integer.parseInt(properties.getProperty("aliyun.maxErrorRetry", "3")));
	configuration.setSupportCname(Boolean.parseBoolean(properties.getProperty("aliyun.supportCname", "false")));
	configuration.setSLDEnabled(Boolean.parseBoolean(properties.getProperty("aliyun.sldEnabled", "false")));
	configuration.setProtocol(Protocol.HTTP);
	if (Protocol.HTTPS.toString().equals(properties.getProperty("aliyun.protocol"))) {
		configuration.setProtocol(Protocol.HTTPS);
	}
	if (properties.getProperty("aliyun.userAgent") != null) {
		configuration.setUserAgent(properties.getProperty("aliyun.userAgent"));
	}

	return configuration;
}
 
Example #3
Source File: FrostmourneSpiAutoConfiguration.java    From frostmourne with MIT License 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public IFrostmourneSpiApi frostmourneSpiApi() {

    if(frostmourneSpiProperties.getMock()) {
        return new MockFrostmourneSpi();
    }

    return Feign.builder().options(defaultOptions())
            .encoder(new JacksonEncoder())
            .decoder(new JacksonDecoder())
            .retryer(feignRetryer())
            .client(okHttpClient)
            .logLevel(feignLoggerLevel())
            .target(IFrostmourneSpiApi.class, frostmourneSpiProperties.getServiceAddr());
}
 
Example #4
Source File: FaradayConfiguration.java    From staffjoy with MIT License 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public MappingsProvider faradayConfigurationMappingsProvider(EnvConfig envConfig,
                                                MappingsValidator mappingsValidator,
                                                HttpClientProvider httpClientProvider) {
    if (faradayProperties.isEnableProgrammaticMapping()) {
        return new ProgrammaticMappingsProvider(
                envConfig, serverProperties,
                faradayProperties, mappingsValidator,
                httpClientProvider);
    } else {
        return new ConfigurationMappingsProvider(
                serverProperties,
                faradayProperties, mappingsValidator,
                httpClientProvider);
    }
}
 
Example #5
Source File: MinIoAutoConfiguration.java    From magic-starter with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
@SneakyThrows
@ConditionalOnMissingBean
public MinioClient minioClient() {
	return new MinioClient(ossProperties.getMinIo()
		.getEndpoint(), ossProperties.getMinIo()
		.getAccessKey(), ossProperties.getMinIo()
		.getSecretKey());
}
 
Example #6
Source File: DropboxComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "dropbox-component")
@ConditionalOnMissingBean(DropboxComponent.class)
public DropboxComponent configureDropboxComponent() throws Exception {
    DropboxComponent component = new DropboxComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<DropboxComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.dropbox.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.dropbox.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #7
Source File: ServletComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "servlet-component")
@ConditionalOnMissingBean(ServletComponent.class)
public ServletComponent configureServletComponent() throws Exception {
    ServletComponent component = new ServletComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<ServletComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.servlet.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.servlet.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #8
Source File: DroolsConfig.java    From fw-spring-cloud with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public KieContainer kieContainer() throws IOException {
    KieRepository kieRepository = kieServices.getRepository();
    kieRepository.addKieModule(kieRepository::getDefaultReleaseId);
    KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem());
    kieBuilder.buildAll();
    return kieServices.newKieContainer(kieRepository.getDefaultReleaseId());
}
 
Example #9
Source File: KMSComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "aws-kms-component")
@ConditionalOnMissingBean(KMSComponent.class)
public KMSComponent configureKMSComponent() throws Exception {
    KMSComponent component = new KMSComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<KMSComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.aws-kms.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.aws-kms.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #10
Source File: ApiBootMyBatisEnhanceAutoConfiguration.java    From beihu-boot with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
    ExecutorType executorType = this.properties.getExecutorType();
    if (executorType != null) {
        return new SqlSessionTemplate(sqlSessionFactory, executorType);
    } else {
        return new SqlSessionTemplate(sqlSessionFactory);
    }
}
 
Example #11
Source File: MyStarterServiceAutoConfiguration.java    From Spring-Boot-Book with Apache License 2.0 5 votes vote down vote up
@Bean
/**
 * Description: 当容器中没有指定Bean的情况下,自动配置MyStarterService类
 */
@ConditionalOnMissingBean(MyStarter.class)
public MyStarter MyStarterService(){
    MyStarter myStarterService = new MyStarter(myproperties);
    return myStarterService;
}
 
Example #12
Source File: RxJavaMvcAutoConfiguration.java    From Java-programming-methodology-Rxjava-articles with Apache License 2.0 5 votes vote down vote up
@Bean
@RxMVC
@ConditionalOnMissingBean
@ConditionalOnClass(Observable.class)
public ObservableReturnValueHandler observableReturnValueHandler() {
    return new ObservableReturnValueHandler();
}
 
Example #13
Source File: SpringLdapComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "spring-ldap-component")
@ConditionalOnMissingBean(SpringLdapComponent.class)
public SpringLdapComponent configureSpringLdapComponent() throws Exception {
    SpringLdapComponent component = new SpringLdapComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<SpringLdapComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.spring-ldap.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.spring-ldap.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #14
Source File: AhcComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "ahc-component")
@ConditionalOnMissingBean(AhcComponent.class)
public AhcComponent configureAhcComponent() throws Exception {
    AhcComponent component = new AhcComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<AhcComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.ahc.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.ahc.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #15
Source File: JsonRedisSerializable.java    From codeway_service with GNU General Public License v3.0 5 votes vote down vote up
/**
*  配置Redis
* @param redisConnectionFactory redis连接工厂
*/
  @Bean
  @ConditionalOnMissingBean(name = "redisTemplate")
  public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
      RedisTemplate<Object, Object> template = new RedisTemplate<>();
      template.setConnectionFactory(redisConnectionFactory);
      template.setDefaultSerializer(new Jackson2JsonRedisSerializer<>(Object.class));
      return template;
  }
 
Example #16
Source File: JobQuartzAutoConfiguration.java    From spring-boot-starter-micro-job with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public SchedulerFactoryBean quartzScheduler() {
    SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
    SpringBeanJobFactory jobFactory = new SpringBeanJobFactory();
    jobFactory.setApplicationContext(this.applicationContext);
    schedulerFactoryBean.setJobFactory(jobFactory);
    if (this.properties.getSchedulerName() != null) {
        schedulerFactoryBean.setSchedulerName(this.properties.getSchedulerName());
    }

    schedulerFactoryBean.setAutoStartup(this.properties.isAutoStartup());
    schedulerFactoryBean.setStartupDelay((int) this.properties.getStartupDelay().getSeconds());
    schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(this.properties.isWaitForJobsToCompleteOnShutdown());
    schedulerFactoryBean.setOverwriteExistingJobs(this.properties.isOverwriteExistingJobs());
    if (!this.properties.getProperties().isEmpty()) {
        schedulerFactoryBean.setQuartzProperties(this.asProperties(this.properties.getProperties()));
    }

    if (this.jobDetails != null && this.jobDetails.length > 0) {
        schedulerFactoryBean.setJobDetails(this.jobDetails);
    }

    if (this.calendars != null && !this.calendars.isEmpty()) {
        schedulerFactoryBean.setCalendars(this.calendars);
    }

    if (this.triggers != null && this.triggers.length > 0) {
        schedulerFactoryBean.setTriggers(this.triggers);
    }

    this.customize(schedulerFactoryBean);
    return schedulerFactoryBean;
}
 
Example #17
Source File: CryptoCmsComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "crypto-cms-component")
@ConditionalOnMissingBean(CryptoCmsComponent.class)
public CryptoCmsComponent configureCryptoCmsComponent() throws Exception {
    CryptoCmsComponent component = new CryptoCmsComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<CryptoCmsComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.crypto-cms.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.crypto-cms.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #18
Source File: SnsComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "aws-sns-component")
@ConditionalOnMissingBean(SnsComponent.class)
public SnsComponent configureSnsComponent() throws Exception {
    SnsComponent component = new SnsComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<SnsComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.aws-sns.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.aws-sns.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #19
Source File: DisruptorVmComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "disruptor-vm-component")
@ConditionalOnMissingBean(DisruptorVmComponent.class)
public DisruptorVmComponent configureDisruptorVmComponent() throws Exception {
    DisruptorVmComponent component = new DisruptorVmComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<DisruptorVmComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.disruptor-vm.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.disruptor-vm.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #20
Source File: IPFSComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "ipfs-component")
@ConditionalOnMissingBean(IPFSComponent.class)
public IPFSComponent configureIPFSComponent() throws Exception {
    IPFSComponent component = new IPFSComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<IPFSComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.ipfs.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.ipfs.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #21
Source File: OpenshiftBuildsComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "openshift-builds-component")
@ConditionalOnMissingBean(OpenshiftBuildsComponent.class)
public OpenshiftBuildsComponent configureOpenshiftBuildsComponent()
        throws Exception {
    OpenshiftBuildsComponent component = new OpenshiftBuildsComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<OpenshiftBuildsComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.openshift-builds.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.openshift-builds.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #22
Source File: SpringDocConfiguration.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
/**
 * Polymorphic model converter polymorphic model converter.
 *
 * @return the polymorphic model converter
 */
@Bean
@ConditionalOnMissingBean
@Lazy(false)
PolymorphicModelConverter polymorphicModelConverter() {
	return new PolymorphicModelConverter();
}
 
Example #23
Source File: JdbcTemplateAutoConfiguration.java    From sqlhelper with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
@Primary
@ConditionalOnSingleCandidate(JdbcTemplate.class)
@ConditionalOnMissingBean(NamedParameterJdbcOperations.class)
public NamedParameterJdbcTemplate namedParameterJdbcTemplate(JdbcTemplate jdbcTemplate) {
    return new NamedParameterJdbcTemplate(jdbcTemplate);
}
 
Example #24
Source File: ServiceNowComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "servicenow-component")
@ConditionalOnMissingBean(ServiceNowComponent.class)
public ServiceNowComponent configureServiceNowComponent() throws Exception {
    ServiceNowComponent component = new ServiceNowComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<ServiceNowComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.servicenow.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.servicenow.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #25
Source File: DataSetTestComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "dataset-test-component")
@ConditionalOnMissingBean(DataSetTestComponent.class)
public DataSetTestComponent configureDataSetTestComponent() throws Exception {
    DataSetTestComponent component = new DataSetTestComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<DataSetTestComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.dataset-test.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.dataset-test.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #26
Source File: DataSetComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "dataset-component")
@ConditionalOnMissingBean(DataSetComponent.class)
public DataSetComponent configureDataSetComponent() throws Exception {
    DataSetComponent component = new DataSetComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<DataSetComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.dataset.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.dataset.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #27
Source File: GoogleSheetsComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "google-sheets-component")
@ConditionalOnMissingBean(GoogleSheetsComponent.class)
public GoogleSheetsComponent configureGoogleSheetsComponent()
        throws Exception {
    GoogleSheetsComponent component = new GoogleSheetsComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<GoogleSheetsComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.google-sheets.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.google-sheets.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #28
Source File: VmComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "vm-component")
@ConditionalOnMissingBean(VmComponent.class)
public VmComponent configureVmComponent() throws Exception {
    VmComponent component = new VmComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<VmComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.vm.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.vm.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #29
Source File: DubboConfiguration.java    From chronus with Apache License 2.0 5 votes vote down vote up
@Bean(name = "DUBBO")
@Scope("prototype")
@ConditionalOnMissingBean
public DubboJobDispatcherImpl jobByDubboType(ChronusSdkProcessor chronusSdkFacade) {
    DubboJobDispatcherImpl dubboJobDispatcher = new DubboJobDispatcherImpl(chronusSdkFacade);
    return dubboJobDispatcher;
}
 
Example #30
Source File: HealthAutoConfiguration.java    From mykit-delay with Apache License 2.0 5 votes vote down vote up
@Bean
@Autowired(required = false)
@ConditionalOnMissingBean
public HealthIndicator jikexiuHealthIndicator(RedisQueue redisQueue, RedisQueueProperties properties) {
    CompositeHealthIndicator compositeHealthIndicator = new  CompositeHealthIndicator(healthAggregator);
    Map<String, LeaderManager> leaderManagerMap = AppEnvContext.getCtx().getBeansOfType(LeaderManager.class);
    LeaderManager manager = null;
    if (leaderManagerMap != null && !leaderManagerMap.isEmpty()) {
        manager = AppEnvContext.getCtx().getBean(SimpleLeaderManager.class);
    }

    compositeHealthIndicator.addHealthIndicator(Constants.HEALTH_INDICATOR_NAME, new QueueHealthIndicator(redisQueue, manager, properties));
    return compositeHealthIndicator;
}