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

项目:spring-boot-autoconfigure    文件:OnBeansCondition.java   
BeanSearchSpec(ConditionContext context, AnnotatedTypeMetadata metadata, Class<?> annotationType) {
    this.annotationType = annotationType;
    MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(annotationType.getName(), true);
    collect(attributes, "name", this.names);
    collect(attributes, "value", this.types);
    collect(attributes, "type", this.types);
    collect(attributes, "annotation", this.annotations);
    collect(attributes, "ignored", this.ignoredTypes);
    collect(attributes, "ignoredType", this.ignoredTypes);
    this.strategy = (SearchStrategy) metadata.getAnnotationAttributes(annotationType.getName()).get("search");
    BeanTypeDeductionException deductionException = null;
    try {
        if (this.types.isEmpty() && this.names.isEmpty()) {
            addDeducedBeanType(context, metadata, this.types);
        }
    } catch (BeanTypeDeductionException ex) {
        deductionException = ex;
    }
    validate(deductionException);
}
项目:micrometer    文件:MetricsAutoConfiguration.java   
@Bean(name = IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME)
@ConditionalOnMissingBean(value = IntegrationManagementConfigurer.class, name = IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME, search = SearchStrategy.CURRENT)
public IntegrationManagementConfigurer integrationManagementConfigurer() {
    IntegrationManagementConfigurer configurer = new IntegrationManagementConfigurer();
    configurer.setDefaultCountsEnabled(true);
    configurer.setDefaultStatsEnabled(true);
    return configurer;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JmxAutoConfiguration.java   
@Bean
@Primary
@ConditionalOnMissingBean(value = MBeanExporter.class, search = SearchStrategy.CURRENT)
public AnnotationMBeanExporter mbeanExporter(ObjectNamingStrategy namingStrategy) {
    AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
    exporter.setRegistrationPolicy(RegistrationPolicy.FAIL_ON_EXISTING);
    exporter.setNamingStrategy(namingStrategy);
    String server = this.propertyResolver.getProperty("server", "mbeanServer");
    if (StringUtils.hasLength(server)) {
        exporter.setServer(this.beanFactory.getBean(server, MBeanServer.class));
    }
    return exporter;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JmxAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ObjectNamingStrategy.class, search = SearchStrategy.CURRENT)
public ParentAwareNamingStrategy objectNamingStrategy() {
    ParentAwareNamingStrategy namingStrategy = new ParentAwareNamingStrategy(
            new AnnotationJmxAttributeSource());
    String defaultDomain = this.propertyResolver.getProperty("default-domain");
    if (StringUtils.hasLength(defaultDomain)) {
        namingStrategy.setDefaultDomain(defaultDomain);
    }
    return namingStrategy;
}
项目:spring-boot-concourse    文件:JmxAutoConfiguration.java   
@Bean
@Primary
@ConditionalOnMissingBean(value = MBeanExporter.class, search = SearchStrategy.CURRENT)
public AnnotationMBeanExporter mbeanExporter(ObjectNamingStrategy namingStrategy) {
    AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
    exporter.setRegistrationPolicy(RegistrationPolicy.FAIL_ON_EXISTING);
    exporter.setNamingStrategy(namingStrategy);
    String server = this.propertyResolver.getProperty("server", "mbeanServer");
    if (StringUtils.hasLength(server)) {
        exporter.setServer(this.beanFactory.getBean(server, MBeanServer.class));
    }
    return exporter;
}
项目:spring-boot-concourse    文件:JmxAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ObjectNamingStrategy.class, search = SearchStrategy.CURRENT)
public ParentAwareNamingStrategy objectNamingStrategy() {
    ParentAwareNamingStrategy namingStrategy = new ParentAwareNamingStrategy(
            new AnnotationJmxAttributeSource());
    String defaultDomain = this.propertyResolver.getProperty("default-domain");
    if (StringUtils.hasLength(defaultDomain)) {
        namingStrategy.setDefaultDomain(defaultDomain);
    }
    return namingStrategy;
}
项目:contestparser    文件:JmxAutoConfiguration.java   
@Bean
@Primary
@ConditionalOnMissingBean(value = MBeanExporter.class, search = SearchStrategy.CURRENT)
public AnnotationMBeanExporter mbeanExporter(ObjectNamingStrategy namingStrategy) {
    AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
    exporter.setRegistrationPolicy(RegistrationPolicy.FAIL_ON_EXISTING);
    exporter.setNamingStrategy(namingStrategy);
    String server = this.propertyResolver.getProperty("server", "mbeanServer");
    if (StringUtils.hasLength(server)) {
        exporter.setServer(this.beanFactory.getBean(server, MBeanServer.class));
    }
    return exporter;
}
项目:contestparser    文件:JmxAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ObjectNamingStrategy.class, search = SearchStrategy.CURRENT)
public ParentAwareNamingStrategy objectNamingStrategy() {
    ParentAwareNamingStrategy namingStrategy = new ParentAwareNamingStrategy(
            new AnnotationJmxAttributeSource());
    String defaultDomain = this.propertyResolver.getProperty("default-domain");
    if (StringUtils.hasLength(defaultDomain)) {
        namingStrategy.setDefaultDomain(defaultDomain);
    }
    return namingStrategy;
}
项目:spring-cloud-commons    文件:ConfigurationPropertiesRebinderAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public ConfigurationPropertiesBeans configurationPropertiesBeans() {
    // Since this is a BeanPostProcessor we have to be super careful not to
    // cause a cascade of bean instantiation. Knowing the *name* of the beans we
    // need is super optimal, but a little brittle (unfortunately we have no
    // choice).
    ConfigurationBeanFactoryMetaData metaData = this.context.getBean(
            ConfigurationPropertiesBindingPostProcessorRegistrar.BINDER_BEAN_NAME
                    + ".store",
            ConfigurationBeanFactoryMetaData.class);
    ConfigurationPropertiesBeans beans = new ConfigurationPropertiesBeans();
    beans.setBeanMetaDataStore(metaData);
    return beans;
}
项目:spring-cloud-commons    文件:ConfigurationPropertiesRebinderAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public ConfigurationPropertiesRebinder configurationPropertiesRebinder(
        ConfigurationPropertiesBeans beans) {
    ConfigurationPropertiesRebinder rebinder = new ConfigurationPropertiesRebinder(
            beans);
    return rebinder;
}
项目:spring-cloud-netflix    文件:EurekaClientAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = EurekaClientConfig.class, search = SearchStrategy.CURRENT)
public EurekaClientConfigBean eurekaClientConfigBean() {
    EurekaClientConfigBean client = new EurekaClientConfigBean();
    if ("bootstrap".equals(this.env.getProperty("spring.config.name"))) {
        // We don't register during bootstrap by default, but there will be another
        // chance later.
        client.setRegisterWithEureka(false);
    }
    return client;
}
项目:spring-cloud-netflix    文件:EurekaClientAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ApplicationInfoManager.class, search = SearchStrategy.CURRENT)
public ApplicationInfoManager eurekaApplicationInfoManager(
        EurekaInstanceConfig config) {
    InstanceInfo instanceInfo = new InstanceInfoFactory().create(config);
    return new ApplicationInfoManager(config, instanceInfo);
}
项目:spring-cloud-netflix    文件:EurekaClientAutoConfigurationTests.java   
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT)
public EurekaClient eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config, ApplicationContext context) {
    return new CloudEurekaClient(manager, config, null, context) {
        @Override
        public synchronized void shutdown() {
            CountDownLatch latch = countDownLatch();
            if (latch.getCount() == 1) {
                latch.countDown();
            }
            super.shutdown();
        }
    };
}
项目:crnk-framework    文件:CrnkErrorControllerAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController jsonapiErrorController(ErrorAttributes errorAttributes) {
    return new CrnkErrorController(errorAttributes, this.serverProperties.getError(), this.errorViewResolvers);
}
项目:spring-boot-autoconfigure    文件:OnBeansCondition.java   
public SearchStrategy getStrategy() {
    return (this.strategy != null ? this.strategy : SearchStrategy.ALL);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointAutoConfiguration.java   
@Bean
@ConditionalOnBean(ConditionEvaluationReport.class)
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public AutoConfigurationReportEndpoint autoConfigurationReportEndpoint() {
    return new AutoConfigurationReportEndpoint();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ErrorMvcAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ErrorAttributes.class, search = SearchStrategy.CURRENT)
public DefaultErrorAttributes errorAttributes() {
    return new DefaultErrorAttributes();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ErrorMvcAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController basicErrorController(ErrorAttributes errorAttributes) {
    return new BasicErrorController(errorAttributes, this.serverProperties.getError(),
            this.errorViewResolvers);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ServerPropertiesAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public ServerProperties serverProperties() {
    return new ServerProperties();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertyPlaceholderAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
}
项目:spring-boot-concourse    文件:EndpointAutoConfiguration.java   
@Bean
@ConditionalOnBean(ConditionEvaluationReport.class)
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public AutoConfigurationReportEndpoint autoConfigurationReportEndpoint() {
    return new AutoConfigurationReportEndpoint();
}
项目:spring-boot-concourse    文件:ErrorMvcAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ErrorAttributes.class, search = SearchStrategy.CURRENT)
public DefaultErrorAttributes errorAttributes() {
    return new DefaultErrorAttributes();
}
项目:spring-boot-concourse    文件:ErrorMvcAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController basicErrorController(ErrorAttributes errorAttributes) {
    return new BasicErrorController(errorAttributes, this.serverProperties.getError(),
            this.errorViewResolvers);
}
项目:spring-boot-concourse    文件:ServerPropertiesAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public ServerProperties serverProperties() {
    return new ServerProperties();
}
项目:spring-boot-concourse    文件:PropertyPlaceholderAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
}
项目:contestparser    文件:EndpointAutoConfiguration.java   
@Bean
@ConditionalOnBean(ConditionEvaluationReport.class)
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public AutoConfigurationReportEndpoint autoConfigurationReportEndpoint() {
    return new AutoConfigurationReportEndpoint();
}
项目:contestparser    文件:ErrorMvcAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ErrorAttributes.class, search = SearchStrategy.CURRENT)
public DefaultErrorAttributes errorAttributes() {
    return new DefaultErrorAttributes();
}
项目:contestparser    文件:ErrorMvcAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController basicErrorController(ErrorAttributes errorAttributes) {
    return new BasicErrorController(errorAttributes, this.properties.getError());
}
项目:contestparser    文件:ServerPropertiesAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public ServerProperties serverProperties() {
    return new ServerProperties();
}
项目:contestparser    文件:PropertyPlaceholderAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
}
项目:spring-cloud-netflix    文件:EurekaClientAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(value = EurekaInstanceConfig.class, search = SearchStrategy.CURRENT)
public EurekaInstanceConfigBean eurekaInstanceConfigBean(InetUtils inetUtils,
                                                         ManagementMetadataProvider managementMetadataProvider) {
    String hostname = getProperty("eureka.instance.hostname");
    boolean preferIpAddress = Boolean.parseBoolean(getProperty("eureka.instance.prefer-ip-address"));
    String ipAddress = getProperty("eureka.instance.ipAddress");
    boolean isSecurePortEnabled = Boolean.parseBoolean(getProperty("eureka.instance.secure-port-enabled"));

    String serverContextPath = env.getProperty("server.context-path", "/");
    int serverPort = Integer.valueOf(env.getProperty("server.port", env.getProperty("port", "8080")));

    Integer managementPort = env.getProperty("management.server.port", Integer.class);// nullable. should be wrapped into optional
    String managementContextPath = env.getProperty("management.server.context-path");// nullable. should be wrapped into optional
    Integer jmxPort = env.getProperty("com.sun.management.jmxremote.port", Integer.class);//nullable
    EurekaInstanceConfigBean instance = new EurekaInstanceConfigBean(inetUtils);

    instance.setNonSecurePort(serverPort);
    instance.setInstanceId(getDefaultInstanceId(env));
    instance.setPreferIpAddress(preferIpAddress);
    if (StringUtils.hasText(ipAddress)) {
        instance.setIpAddress(ipAddress);
    }

    if(isSecurePortEnabled) {
        instance.setSecurePort(serverPort);
    }

    if (StringUtils.hasText(hostname)) {
        instance.setHostname(hostname);
    }
    String statusPageUrlPath = getProperty("eureka.instance.status-page-url-path");
    String healthCheckUrlPath = getProperty("eureka.instance.health-check-url-path");

    if (StringUtils.hasText(statusPageUrlPath)) {
        instance.setStatusPageUrlPath(statusPageUrlPath);
    }
    if (StringUtils.hasText(healthCheckUrlPath)) {
        instance.setHealthCheckUrlPath(healthCheckUrlPath);
    }

    ManagementMetadata metadata = managementMetadataProvider.get(instance, serverPort,
            serverContextPath, managementContextPath, managementPort);

    if(metadata != null) {
        instance.setStatusPageUrl(metadata.getStatusPageUrl());
        instance.setHealthCheckUrl(metadata.getHealthCheckUrl());
        Map<String, String> metadataMap = instance.getMetadataMap();
        if (metadataMap.get("management.port") == null) {
            metadataMap.put("management.port", String.valueOf(metadata.getManagementPort()));
        }
    }

    setupJmxPort(instance, jmxPort);
    return instance;
}
项目:spring-cloud-netflix    文件:EurekaClientAutoConfiguration.java   
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT)
public EurekaClient eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config) {
    return new CloudEurekaClient(manager, config, this.optionalArgs,
            this.context);
}
项目:spring-cloud-netflix    文件:DiscoveryClientOptionalArgsConfiguration.java   
@Bean
@ConditionalOnMissingClass("com.sun.jersey.api.client.filter.ClientFilter")
@ConditionalOnMissingBean(value = AbstractDiscoveryClientOptionalArgs.class, search = SearchStrategy.CURRENT)
public RestTemplateDiscoveryClientOptionalArgs restTemplateDiscoveryClientOptionalArgs() {
    return new RestTemplateDiscoveryClientOptionalArgs();
}
项目:spring-cloud-netflix    文件:DiscoveryClientOptionalArgsConfiguration.java   
@Bean
@ConditionalOnClass(name = "com.sun.jersey.api.client.filter.ClientFilter")
@ConditionalOnMissingBean(value = AbstractDiscoveryClientOptionalArgs.class, search = SearchStrategy.CURRENT)
public MutableDiscoveryClientOptionalArgs discoveryClientOptionalArgs() {
    return new MutableDiscoveryClientOptionalArgs();
}