Java 类org.springframework.boot.autoconfigure.condition.ConditionalOnProperty 实例源码

项目:myth    文件:AmqpConfig.java   
@Bean
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host")
public SimpleMessageListenerContainer messageContainer() {
    SimpleMessageListenerContainer container =
            new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(queue());
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(2);
    container.setConcurrentConsumers(1);
    //设置确认模式手工确认
    container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
    container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> {
        byte[] messageBody = message.getBody();
        LOGGER.debug("motan 框架接收到的消息");
        //确认消息成功消费
        final Boolean success = mythMqReceiveService.processMessage(messageBody);
        if (success) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }
    });
    return container;
}
项目:spring-cloud-skipper    文件:SkipperServerPlatformConfiguration.java   
@Bean
@ConditionalOnProperty(value = "spring.cloud.skipper.server.enableLocalPlatform", matchIfMissing = true)
public Platform localDeployers(LocalPlatformProperties localPlatformProperties) {
    List<Deployer> deployers = new ArrayList<>();
    Map<String, LocalDeployerProperties> localDeployerPropertiesMap = localPlatformProperties.getAccounts();
    if (localDeployerPropertiesMap.isEmpty()) {
        localDeployerPropertiesMap.put("default", new LocalDeployerProperties());
    }
    for (Map.Entry<String, LocalDeployerProperties> entry : localDeployerPropertiesMap
            .entrySet()) {
        LocalAppDeployer localAppDeployer = new LocalAppDeployer(entry.getValue());
        Deployer deployer = new Deployer(entry.getKey(), "local", localAppDeployer);
        deployer.setDescription(prettyPrintLocalDeployerProperties(entry.getValue()));
        deployers.add(deployer);
    }

    return new Platform("Local", deployers);
}
项目:cas-5.1.0    文件:CasFiltersConfiguration.java   
@ConditionalOnProperty(prefix = "cas.httpWebRequest.cors", name = "enabled", havingValue = "true")
@Bean
@RefreshScope
public FilterRegistrationBean casCorsFilter() {
    final HttpWebRequestProperties.Cors cors = casProperties.getHttpWebRequest().getCors();
    final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    final CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(cors.isEnabled());
    config.setAllowedOrigins(cors.getAllowOrigins());
    config.setAllowedMethods(cors.getAllowMethods());
    config.setAllowedHeaders(cors.getAllowHeaders());
    config.setMaxAge(cors.getMaxAge());
    config.setExposedHeaders(cors.getExposedHeaders());
    source.registerCorsConfiguration("/**", config);
    final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setName("casCorsFilter");
    bean.setAsyncSupported(true);
    bean.setOrder(0);
    return bean;
}
项目:spring-boot-starter-rocketmq    文件:RocketMQAutoConfiguration.java   
@Bean
@ConditionalOnClass(DefaultMQProducer.class)
@ConditionalOnMissingBean(DefaultMQProducer.class)
@ConditionalOnProperty(prefix = "spring.rocketmq", value = {"nameServer", "producer.group"})
public DefaultMQProducer mqProducer(RocketMQProperties rocketMQProperties) {

    RocketMQProperties.Producer producerConfig = rocketMQProperties.getProducer();
    String groupName = producerConfig.getGroup();
    Assert.hasText(groupName, "[spring.rocketmq.producer.group] must not be null");

    DefaultMQProducer producer = new DefaultMQProducer(producerConfig.getGroup());
    producer.setNamesrvAddr(rocketMQProperties.getNameServer());
    producer.setSendMsgTimeout(producerConfig.getSendMsgTimeout());
    producer.setRetryTimesWhenSendFailed(producerConfig.getRetryTimesWhenSendFailed());
    producer.setRetryTimesWhenSendAsyncFailed(producerConfig.getRetryTimesWhenSendAsyncFailed());
    producer.setMaxMessageSize(producerConfig.getMaxMessageSize());
    producer.setCompressMsgBodyOverHowmuch(producerConfig.getCompressMsgBodyOverHowmuch());
    producer.setRetryAnotherBrokerWhenNotStoreOK(producerConfig.isRetryAnotherBrokerWhenNotStoreOk());

    return producer;
}
项目:micrometer    文件:MetricsAutoConfiguration.java   
/**
 * If AOP is not enabled, scheduled interception will not work.
 */
@Bean
@ConditionalOnClass(name = "org.aspectj.lang.ProceedingJoinPoint")
@ConditionalOnProperty(value = "spring.aop.enabled", havingValue = "true", matchIfMissing = true)
public ScheduledMethodMetrics metricsSchedulingAspect(MeterRegistry registry) {
    return new ScheduledMethodMetrics(registry);
}
项目:generator-jhipster-storage    文件:_StorageConfiguration.java   
/**
 * S3 储存客户端
 *
 * @return 客户端
 */
@Bean
@ConditionalOnProperty(value = "bigbug.storage.s3.enable", havingValue = "true")
AmazonS3Client amazonS3Client() {
    ClientConfiguration clientConfig = new ClientConfiguration();
    clientConfig.setProtocol(Protocol.HTTP);

    BasicAWSCredentials basicAWSCredentials =
            new BasicAWSCredentials(
                    storageProperties.getStorage().getS3().getAccessKey(),
                    storageProperties.getStorage().getS3().getSecretKey());

    return (AmazonS3Client) AmazonS3ClientBuilder.standard()
            .withClientConfiguration(clientConfig)
            .withEndpointConfiguration(
                    new AwsClientBuilder.EndpointConfiguration(
                            storageProperties.getStorage().getS3().getEndpoint(), Regions.DEFAULT_REGION.getName()))
            .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials))
            .build();
}
项目:myth    文件:AmqpConfig.java   
@Bean
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host")
public SimpleMessageListenerContainer messageContainer() {
    SimpleMessageListenerContainer container =
            new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(queue());
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(1);
    container.setConcurrentConsumers(1);
    //设置确认模式手工确认
    container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
    container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> {
        byte[] messageBody = message.getBody();
        //确认消息成功消费
        final Boolean success = mythMqReceiveService.processMessage(messageBody);
        if (success) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }
    });
    return container;
}
项目:myth    文件:JmsConfig.java   
@Bean(name = "queueListenerContainerFactory")
@ConditionalOnProperty(prefix = "spring.activemq", name = "broker-url")
public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) {
    DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory();
    bean.setConnectionFactory(activeMQConnectionFactory);
    bean.setPubSubDomain(Boolean.FALSE);
    return bean;
}
项目:myth    文件:AmqpConfig.java   
@Bean
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host")
public SimpleMessageListenerContainer messageContainer() {
    SimpleMessageListenerContainer container =
            new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(queue());
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(3);
    container.setConcurrentConsumers(1);
    //设置确认模式手工确认
    container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
    container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> {
        byte[] messageBody = message.getBody();
        LogUtil.debug(LOGGER,()->"springcloud  account服务  amqp接收消息");
        //确认消息成功消费
        final Boolean success = mythMqReceiveService.processMessage(messageBody);
        if (success) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }
    });
    return container;
}
项目:jhipster-microservices-example    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
项目:jhipster-microservices-example    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
项目:jhipster-microservices-example    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
项目:xitikit-blue    文件:B2CPolicyAutoConfiguration.java   
@Bean("blueKitResetPasswordPolicy")
@ConditionalOnBean(ResetPasswordPolicy.class)
@ConditionalOnProperty(prefix = "blue-kit.b2c.policy.edit-profile", value = {"name", "redirect-url"})
@ConfigurationProperties("blue-kit.b2c.policy.reset-password")
public ResetPasswordPolicy blueKitResetPasswordPolicy(){

    return new ResetPasswordPolicy();
}
项目:cas-5.1.0    文件:CasCoreTicketsSchedulingConfiguration.java   
@ConditionalOnMissingBean(name = "ticketRegistryCleanerScheduler")
@ConditionalOnProperty(prefix = "cas.ticket.registry.cleaner", name = "enabled", havingValue = "true", matchIfMissing = true)
@Bean
@Autowired
@RefreshScope
public TicketRegistryCleanerScheduler ticketRegistryCleanerScheduler(@Qualifier("ticketRegistryCleaner") 
                                                                     final TicketRegistryCleaner ticketRegistryCleaner) {
    return new TicketRegistryCleanerScheduler(ticketRegistryCleaner);
}
项目:spring-boot-multidatasource    文件:DataSourceAutoConfiguration.java   
@Bean
@ConditionalOnProperty(name = "spring.datasource4.url")
@ConfigurationProperties(prefix = "spring.datasource4")
public DataSourceInitializer dataSourceInitializer4(DataSourceProperties properties,
        ApplicationContext applicationContext) {
    return new DataSourceInitializer(properties, applicationContext, 4);
}
项目:xm-ms-balance    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader spectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
项目:spring-cloud-sleuth-amqp-starter    文件:SleuthAmqpMessagingAutoConfiguration.java   
@Bean
@ConditionalOnProperty(value = "spring.sleuth.amqp.enabled", matchIfMissing = true)
@ConditionalOnMissingBean(AmqpMessagingSpanManager.class)
public AmqpMessagingSpanManager amqpMessagingSpanManager(
    AmqpMessagingSpanInjector amqpMessagingSpanInjector,
    AmqpMessagingSpanExtractor amqpMessagingSpanExtractor,
    Tracer tracer) {
  return new DefaultAmqpMessagingSpanManager(
      amqpMessagingSpanInjector, amqpMessagingSpanExtractor, tracer);
}
项目:Microservices-with-JHipster-and-Spring-Boot    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
项目:xm-ms-timeline    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
项目:Armory    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
项目:xm-ms-dashboard    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
项目:incubator-servicecomb-saga    文件:SagaSpringConfig.java   
@ConditionalOnProperty(value = "saga.runningMode", havingValue = "graph", matchIfMissing = true)
@Bean
SagaFactory graphBasedSagaFactory(
    @Value("${saga.thread.count:5}") int numberOfThreads,
    @Value("${saga.retry.delay:3000}") int retryDelay,
    PersistentStore persistentStore,
    FromJsonFormat<Set<String>> childrenExtractor) {

  return new GraphBasedSagaFactory(
      retryDelay,
      persistentStore,
      childrenExtractor,
      Executors.newFixedThreadPool(numberOfThreads, sagaThreadFactory()));
}
项目:incubator-servicecomb-saga    文件:SagaSpringConfig.java   
@ConditionalOnProperty(value = "saga.runningMode", havingValue = "actor")
@Bean
SagaFactory actorBasedSagaFactory(
    @Value("${saga.retry.delay:3000}") int retryDelay,
    PersistentStore persistentStore,
    FromJsonFormat<Set<String>> childrenExtractor) {

  return new ActorBasedSagaFactory(
      retryDelay,
      persistentStore,
      childrenExtractor);
}
项目:Microservices-with-JHipster-and-Spring-Boot    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
项目:xitikit-blue    文件:B2CPolicyAutoConfiguration.java   
@Bean("blueKitChangeEmailPolicy")
@ConditionalOnBean(ChangeEmailPolicy.class)
@ConditionalOnProperty(prefix = "blue-kit.b2c.policy.change-email", value = {"name", "redirect-url", "template-url"})
@ConfigurationProperties("blue-kit.b2c.policy.change-email")
public ChangeEmailPolicy blueKitChangeEmailPolicy(){

    throw new NotFoundException("'change-email' is not a valid policy (yet) provided by Microsoft's Azure AD B2C. You must manually change the email using the GraphApi instead.");
}
项目:micrometer    文件:MeterBindersConfiguration.java   
@Bean
@ConditionalOnMissingBean(LogbackMetrics.class)
@ConditionalOnProperty(value = "management.metrics.binders.logback.enabled", matchIfMissing = true)
@ConditionalOnClass(name = "ch.qos.logback.classic.Logger")
public LogbackMetrics logbackMetrics() {
    return new LogbackMetrics();
}
项目:xitikit-blue    文件:B2CPolicyAutoConfiguration.java   
@Bean("blueKitSignUpPolicy")
@ConditionalOnBean(SignUpPolicy.class)
@ConditionalOnProperty(prefix = "blue-kit.b2c.policy.sign-up", value = {"name", "redirect-url"})
@ConfigurationProperties("blue-kit.b2c.policy.sign-up")
public SignUpPolicy blueKitSignUpPolicy(){

    return new SignUpPolicy();
}
项目:nakadi-producer-spring-boot-starter    文件:NakadiProducerAutoConfiguration.java   
@Bean(destroyMethod = "stop")
@ConditionalOnProperty({ "nakadi-producer.access-token-uri", "nakadi-producer.access-token-scopes" })
@ConditionalOnMissingBean(AccessTokenProvider.class)
public StupsTokenComponent accessTokenProvider(
        @Value("${nakadi-producer.access-token-uri}") URI accessTokenUri,
        @Value("${nakadi-producer.access-token-scopes}") String[] accessTokenScopes) {
    return new StupsTokenComponent(accessTokenUri, Arrays.asList(accessTokenScopes));
}
项目:sentry    文件:WebConfigurer.java   
@Bean
@ConditionalOnProperty(name = "jhipster.cors.allowed-origins")
public CorsFilter corsFilter() {
    log.debug("Registering CORS filter");
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = jHipsterProperties.getCors();
    source.registerCorsConfiguration("/api/**", config);
    source.registerCorsConfiguration("/v2/api-docs", config);
    source.registerCorsConfiguration("/oauth/**", config);
    return new CorsFilter(source);
}
项目:xitikit-blue    文件:B2CPolicyAutoConfiguration.java   
@Bean("blueKitSignOutPolicy")
@ConditionalOnBean(SignOutPolicy.class)
@ConditionalOnProperty(prefix = "blue-kit.b2c.policy.sign-out")
@ConfigurationProperties("blue-kit.b2c.policy.sign-out")
public SignOutPolicy blueKitSignOutPolicy(){

    return new SignOutPolicy();
}
项目:devoxxus-jhipster-microservices-demo    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
项目:druid-spring-boot    文件:DruidAutoConfiguration.java   
@Bean
@ConditionalOnProperty(prefix = DRUID_WALL_FILTER_PREFIX, name = "enabled", havingValue = "true")
@ConfigurationProperties(DRUID_WALL_FILTER_PREFIX)
public WallFilter wallFilter(WallConfig wallConfig) {
    log.debug("druid wall-filter init...");
    WallFilter filter = new WallFilter();
    filter.setConfig(wallConfig);
    return filter;
}
项目:druid-spring-boot    文件:DruidAutoConfiguration.java   
@Bean
@ConditionalOnProperty(prefix = DRUID_SLF4J_FILTER_PREFIX, name = "enabled", havingValue = "true")
@ConfigurationProperties(DRUID_SLF4J_FILTER_PREFIX)
public Slf4jLogFilter slf4jLogFilter() {
    log.debug("druid slf4j-filter init...");
    return new Slf4jLogFilter();
}
项目:druid-spring-boot    文件:DruidAutoConfiguration.java   
@Bean
@ConditionalOnProperty(prefix = DRUID_COMMONS_LOG_FILTER_PREFIX, name = "enabled", havingValue = "true")
@ConfigurationProperties(DRUID_COMMONS_LOG_FILTER_PREFIX)
public CommonsLogFilter commonsLogFilter() {
    log.debug("druid commons-log-filter init...");
    return new CommonsLogFilter();
}
项目:flowing-retail    文件:CamundaJobExecutorConfiguration.java   
@Bean
  @ConditionalOnProperty(prefix = "camunda.bpm.job-execution", name = "enabled", havingValue = "true", matchIfMissing = true)  
  public static JobExecutor jobExecutor(@Qualifier(JobConfiguration.CAMUNDA_TASK_EXECUTOR_QUALIFIER) final TaskExecutor taskExecutor) {
    final SpringJobExecutor springJobExecutor = new SpringJobExecutor();
    springJobExecutor.setTaskExecutor(taskExecutor);
    springJobExecutor.setRejectedJobsHandler(new CallerRunsRejectedJobsHandler());

    springJobExecutor.setWaitTimeInMillis(10);
//    springJobExecutor.setWaitIncreaseFactor(1.0f);
    springJobExecutor.setMaxWait(20);

    return springJobExecutor;
  }
项目:zipkin-sparkstreaming    文件:ZipkinFinagleAdjusterAutoConfiguration.java   
@Bean
@ConditionalOnProperty(
    value = "zipkin.sparkstreaming.adjuster.finagle.adjust-issue343",
    havingValue = "true"
)
Adjuster finagleIssue343Adjuster() {
  return FinagleIssue343Adjuster.create();
}
项目:syndesis    文件:TwitterVerifierAutoConfiguration.java   
@Bean("twitter")
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Lazy
@ConditionalOnProperty(prefix = "io.syndesis.connector.twitter.verifier", name = "enabled", matchIfMissing = true)
public Verifier twitterVerifier() {
    return new TwitterVerifier();
}
项目:cas-security-spring-boot-starter    文件:CasSecurityAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(ServiceProperties.class)
@ConditionalOnProperty(value = "security.cas.service.resolution-mode", havingValue = "dynamic")
ServiceProperties laxServiceProperties() {
    LaxServiceProperties serviceProperties = new LaxServiceProperties();
    serviceProperties.setAuthenticateAllArtifacts(true);
    return serviceProperties;
}
项目:elephant    文件:ServerConfiguration.java   
@Bean(initMethod="init",destroyMethod="destroy")
@ConditionalOnProperty(prefix = "elephant",value = {"zk-server"})
public ZkClientRegisterCenter zkClientRegisterCenter(@Value("${elephant.zk-server}")String zkServer){
    ZkClientRegisterCenter registerCenter = new ZkClientRegisterCenter();
    registerCenter.setZkAddress(zkServer);
    return registerCenter;
}
项目:xm-ms-entity    文件:MetricsConfiguration.java   
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}