org.springframework.context.annotation.Conditional.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(183)

本文整理了Java中org.springframework.context.annotation.Conditional.<init>()方法的一些代码示例,展示了Conditional.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Conditional.<init>()方法的具体详情如下:
包路径:org.springframework.context.annotation.Conditional
类名称:Conditional
方法名:<init>

Conditional.<init>介绍

暂无

代码示例

代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba

@Configuration
@Conditional(MigrateOnConditionClass.class)
public class MigrateRibbonCofiguration {

  @Bean
  public MigrateRibbonBeanPostProcessor migrateBeanPostProcessor(IClientConfig clientConfig) {

    return new MigrateRibbonBeanPostProcessor(clientConfig);
  }
}

代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba

/**
 * @author xiaolongzuo
 */
@Configuration
@Conditional(MigrateOnConditionMissingClass.class)
public class AnsRibbonClientConfiguration {

  @Bean
  @ConditionalOnMissingBean
  public ServerList<?> ansRibbonServerList(IClientConfig config) {
    AnsServerList serverList = new AnsServerList(config.getClientName());
    return serverList;
  }

}

代码示例来源:origin: spring-projects/spring-framework

@Configuration
@Conditional(NoBeanOneCondition.class)
static class BeanTwoConfiguration {
  @Bean
  public ExampleBean bean2() {
    return new ExampleBean();
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Configuration
@Conditional(HasBeanOneCondition.class)
static class BeanThreeConfiguration {
  @Bean
  public ExampleBean bean3() {
    return new ExampleBean();
  }
}

代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba

/**
 * @author xiaolongzuo
 */
@Configuration
@Conditional(MigrateOnConditionMissingClass.class)
@ConditionalOnMissingBean(DiscoveryClient.class)
@EnableConfigurationProperties
@AutoConfigureBefore(SimpleDiscoveryClientAutoConfiguration.class)
public class AnsDiscoveryClientAutoConfiguration {

  @Bean
  public DiscoveryClient ansDiscoveryClient() {
    return new AnsDiscoveryClient();
  }

}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

/**
 * @author Jeff Fischer
 */
@Configuration("blProfileData")
@Conditional(ImportCondition.class)
public class ImportSQLConfig {

  @Bean
  @Conditional(DemoCondition.class)
  public AutoImportSql blProfileBasicData() {
    return new AutoImportSql(AutoImportPersistenceUnit.BL_PU,"config/bc/sql/demo/load_code_tables.sql", AutoImportStage.PRIMARY_PRE_BASIC_DATA);
  }

  @Bean
  @Conditional(DemoCondition.class)
  public AutoImportSql blProfileSequenceData() {
    return new AutoImportSql(AutoImportPersistenceUnit.ALL,"config/bc/sql/demo/load_profile_table_sequences.sql", AutoImportStage.ALL_TABLE_SEQUENCE);
  }

}

代码示例来源:origin: spring-projects/spring-framework

@Configuration
@Conditional(NeverMatchingCondition.class)
@Import(BeanProvidingConfiguration.class)
protected static class ConditionalConfiguration {
}

代码示例来源:origin: spring-projects/spring-framework

@Configuration
@EnableTransactionManagement
@Conditional(NeverCondition.class)
static class ParentEnableTxConfig {
  @Bean
  Object someBean() {
    return new Object();
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

/**
 * @author Jeff Fischer
 */
@Configuration("blCommonData")
@Conditional(ImportCondition.class)
public class ImportSQLConfig {

  @Bean
  @Conditional(DemoCondition.class)
  public AutoImportSql blCommonPreBasicData() {
    return new AutoImportSql(AutoImportPersistenceUnit.BL_PU,"config/bc/sql/demo/load_i18n_countries.sql", AutoImportStage.PRIMARY_PRE_BASIC_DATA);
  }

  @Bean
  @Conditional(DemoCondition.class)
  public AutoImportSql blCommonBasicData() {
    return new AutoImportSql(AutoImportPersistenceUnit.BL_PU,"config/bc/sql/demo/load_admin_users.sql,config/bc/sql/demo/load_sitemap_data.sql", AutoImportStage.PRIMARY_BASIC_DATA);
  }

  @Bean
  @Conditional({MTCondition.class, DemoCondition.class})
  public AutoImportSql blCommonLateData() {
    return new AutoImportSql(AutoImportPersistenceUnit.BL_PU,"config/bc/sql/demo/fix_admin_user_data.sql,config/bc/sql/demo/fix_system_property_data.sql", AutoImportStage.PRIMARY_LATE);
  }

}

代码示例来源:origin: spring-projects/spring-framework

@Configuration
  @Conditional(NeverConfigurationCondition.class)
  static class ConditionWithPropertyValueInjection {

    @Value("${idontexist}")
    private String property;
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

/**
 * @author Jeff Fischer
 */
@Configuration("blCMSData")
@Conditional(ImportCondition.class)
public class ImportSQLConfig {

  public static final int BASIC_DATA_SPECIAL = AutoImportStage.PRIMARY_PRE_BASIC_DATA + 200;

  @Bean
  @Conditional(DemoCondition.class)
  public AutoImportSql blCMSBasicData() {
    return new AutoImportSql(AutoImportPersistenceUnit.BL_PU,"config/bc/sql/demo/load_content_structure.sql," +
        "config/bc/sql/demo/load_content_data.sql,config/bc/sql/demo/load_content_structure_i18n.sql," +
        "config/bc/sql/demo/load_content_data_i18n.sql", BASIC_DATA_SPECIAL);
  }

  @Bean
  @Conditional(DemoCondition.class)
  public AutoImportSql blCMSSequenceData() {
    return new AutoImportSql(AutoImportPersistenceUnit.ALL,"config/bc/sql/demo/load_cms_table_sequences.sql", AutoImportStage.ALL_TABLE_SEQUENCE);
  }

  @Bean
  @Conditional({MTCondition.class, DemoCondition.class})
  public AutoImportSql blCMSLateData() {
    return new AutoImportSql(AutoImportPersistenceUnit.BL_PU,"config/bc/sql/demo/fix_static_asset_data.sql", AutoImportStage.PRIMARY_LATE);
  }
}

代码示例来源:origin: cloudfoundry/uaa

@Configuration
@Conditional(LdapGroupsNullConfig.IfConfigured.class)
public class LdapGroupsNullConfig {

 public static class IfConfigured implements Condition {
  @Override
  public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
   String ldapGroupsFile = context.getEnvironment().getProperty("ldap.groups.file");
   return ldapGroupsFile == null || ldapGroupsFile.equals("ldap/ldap-groups-null.xml");
  }
 }

 @Bean
 public LdapAuthoritiesPopulator ldapAuthoritiesPopulator() {
  return new NullLdapAuthoritiesPopulator();
 }

 @Bean
 public GrantedAuthoritiesMapper ldapAuthoritiesMapper() {
  return new SimpleAuthorityMapper();
 }

 @Bean
 public String testLdapGroup() {
  return "ldap-groups-null.xml";
 }
}

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

@Configuration
@ConditionalOnBean(CachingConnectionFactory.class)
@ConditionalOnMissingBean(name = ZipkinAutoConfiguration.SENDER_BEAN_NAME)
@Conditional(ZipkinSenderCondition.class)
class ZipkinRabbitSenderConfiguration {

  @Value("${spring.zipkin.rabbitmq.queue:zipkin}")
  private String queue;

  @Bean(ZipkinAutoConfiguration.SENDER_BEAN_NAME)
  Sender rabbitSender(CachingConnectionFactory connectionFactory,
      RabbitProperties config) {
    return RabbitMQSender.newBuilder()
        .connectionFactory(connectionFactory.getRabbitConnectionFactory())
        .queue(this.queue).addresses(config.determineAddresses()).build();
  }

}

代码示例来源:origin: cloudfoundry/uaa

@Configuration
@Conditional(LdapGroupsAsScopesConfig.IfConfigured.class)
@Import(LdapGroupsConfig.class)
public class LdapGroupsAsScopesConfig {

 public static class IfConfigured implements Condition {
  @Override
  public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
   String ldapGroupsFile = context.getEnvironment().getProperty("ldap.groups.file");
   return ldapGroupsFile != null && ldapGroupsFile.equals("ldap/ldap-groups-as-scopes.xml");
  }
 }

 @Bean
 public String configuredGroupRoleAttribute(Environment environment) {
   return Optional.ofNullable(environment.getProperty("ldap.groups.groupRoleAttribute")).orElse("description");
 }

 @Bean
 public GrantedAuthoritiesMapper ldapAuthoritiesMapper() {
  return new CommaSeparatedScopesMapper();
 }

 @Bean
 public String testLdapGroup() {
  return "ldap-groups-as-scopes.xml";
 }
}

代码示例来源:origin: codecentric/spring-boot-admin

@Configuration
@ConditionalOnWebApplication
@ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY)
@Conditional(SpringBootAdminClientEnabledCondition.class)
@EnableConfigurationProperties(CloudFoundryApplicationProperties.class)
@AutoConfigureBefore({SpringBootAdminClientAutoConfiguration.class})
public class SpringBootAdminClientCloudFoundryAutoConfiguration {
  @Bean
  @ConditionalOnMissingBean
  public CloudFoundryMetadataContributor cloudFoundryMetadataContributor(CloudFoundryApplicationProperties cloudFoundryApplicationProperties) {
    return new CloudFoundryMetadataContributor(cloudFoundryApplicationProperties);
  }

  @Bean
  @ConditionalOnMissingBean
  public CloudFoundryApplicationFactory applicationFactory(InstanceProperties instance,
                               ManagementServerProperties management,
                               ServerProperties server,
                               PathMappedEndpoints pathMappedEndpoints,
                               WebEndpointProperties webEndpoint,
                               MetadataContributor metadataContributor,
                               CloudFoundryApplicationProperties cfApplicationProperties) {
    return new CloudFoundryApplicationFactory(instance, management, server, pathMappedEndpoints, webEndpoint,
      metadataContributor, cfApplicationProperties);
  }
}

代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba

@Configuration
@EnableConfigurationProperties
@Conditional(MigrateOnConditionClass.class)
@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true)
@ConditionalOnAnsEnabled
public class MigrationAutoconfiguration {

  @Bean
  public MigrateServiceRegistry migrationManger(AnsProperties ansProperties,
      ApplicationContext applicationContext) {

    return new MigrateServiceRegistry(ansProperties, applicationContext);
  }

  @Bean
  public MigrateRefreshEventListener migrateRefreshEventListener(
      Environment environment,
      @Qualifier(value = "springClientFactory") NamedContextFactory namedContextFactory) {

    return new MigrateRefreshEventListener(environment, namedContextFactory);
  }
}

代码示例来源:origin: cloudfoundry/uaa

@Configuration
@Conditional(LdapSimpleBindConfig.IfConfigured.class)
public class LdapSimpleBindConfig {
 public static class IfConfigured implements Condition {

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

@Configuration("blCoreData")
@Conditional(ImportCondition.class)
public class ImportSQLConfig {

代码示例来源:origin: cloudfoundry/uaa

@Configuration
@Conditional(LdapSearchAndBindConfig.IfConfigured.class)
public class LdapSearchAndBindConfig {
 public static class IfConfigured implements Condition {

代码示例来源:origin: alibaba/jetcache

@Configuration
@Conditional(RedisLettuce4AutoConfiguration.RedisLettuceCondition.class)
public class RedisLettuce4AutoConfiguration {
  public static final String AUTO_INIT_BEAN_NAME = "redisLettuce4AutoInit";

相关文章