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

项目:xitikit-blue    文件:B2CServicesAutoConfiguration.java   
@Bean("blueKitB2CAuthenticationService")
@Autowired
@ConditionalOnMissingBean(B2CAuthenticationService.class)
@ConditionalOnBean(
  value = {B2CProperties.class, SignUpPolicy.class, SignInPolicy.class, SignUpOrSignInPolicy.class, ResetPasswordPolicy.class, EditProfilePolicy.class, SignOutPolicy.class, NonceProperties.class, NonceService.class})
public B2CAuthenticationService blueKitB2CAuthenticationService(
  final ClaimValidationService claimValidationService,
  final NonceService nonceService,
  final UrlService urlService,
  final RestTemplate restTemplate){

    return new SimpleB2CAuthenticationService(
      claimValidationService,
      nonceService,
      urlService,
      restTemplate);
}
项目:zipkin-sparkstreaming    文件:ZipkinStorageConsumerAutoConfiguration.java   
@ConditionalOnBean(StorageComponent.class)
@Bean StorageConsumer storageConsumer(
    StorageComponent component,
    @Value("${zipkin.sparkstreaming.consumer.storage.fail-fast:true}") boolean failFast,
    BeanFactory bf
) throws IOException {
  if (failFast) checkStorageOk(component);
  Properties properties = extractZipkinProperties(bf.getBean(ConfigurableEnvironment.class));
  if (component instanceof V2StorageComponent) {
    zipkin2.storage.StorageComponent v2Storage = ((V2StorageComponent) component).delegate();
    if (v2Storage instanceof ElasticsearchHttpStorage) {
      return new ElasticsearchStorageConsumer(properties);
    } else if (v2Storage instanceof zipkin2.storage.cassandra.CassandraStorage) {
      return new Cassandra3StorageConsumer(properties);
    } else {
      throw new UnsupportedOperationException(v2Storage + " not yet supported");
    }
  } else if (component instanceof CassandraStorage) {
    return new CassandraStorageConsumer(properties);
  } else if (component instanceof MySQLStorage) {
    return new MySQLStorageConsumer(properties);
  } else {
    throw new UnsupportedOperationException(component + " not yet supported");
  }
}
项目:sample-boot-hibernate    文件:ApplicationConfig.java   
/** 営業日チェック */
@Bean
@ConditionalOnBean(BusinessDayHandler.class)
HealthIndicator dayIndicator(final Timestamper time, final BusinessDayHandler day) {
    return new AbstractHealthIndicator() {
        @Override
        protected void doHealthCheck(Builder builder) throws Exception {
            builder.up();
            builder.withDetail("day", day.day())
                    .withDetail("dayMinus1", day.day(-1))
                    .withDetail("dayPlus1", day.day(1))
                    .withDetail("dayPlus2", day.day(2))
                    .withDetail("dayPlus3", day.day(3));
        }
    };
}
项目:onetwo    文件:BootSecurityCommonContextConfig.java   
@Bean
@ConditionalOnMissingBean({LoggerInterceptor.class})
@ConditionalOnBean(BootSiteConfig.class)
@ConditionalOnProperty(value=AccessLogProperties.ENABLE_MVC_LOGGER_INTERCEPTOR, matchIfMissing=true, havingValue="true")
public LoggerInterceptor loggerInterceptor(){
    LoggerInterceptor log = new LoggerInterceptor();
    log.setUserDetailRetriever(()->{
        if(SecurityContextHolder.getContext().getAuthentication()==null)
            return null;
        Object user = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if(UserDetail.class.isInstance(user)){
            return (UserDetail)user;
        }else if(User.class.isInstance(user)){
            User suser = (User)user;
            SimpleUserDetail ud = new SimpleUserDetail();
            ud.setUserName(suser.getUsername());
            return ud;
        }
        return null;
    });
    log.setPathPatterns(accessLogProperties.getPathPatterns());
    return log;
}
项目:onetwo    文件:WebAdminPluginContext.java   
@Bean
    @Autowired
    @ConditionalOnBean(RootMenuClassProvider.class)
    public AdminPermissionConfigListAdapetor adminPermissionConfigListAdapetor(List<RootMenuClassProvider> providers){
        AdminPermissionConfigListAdapetor list = new AdminPermissionConfigListAdapetor();
        providers.forEach(provider->{
            Collection<Class<?>> rooMenuClassList = new HashSet<>();
            if(provider instanceof RootMenuClassListProvider){
                rooMenuClassList.addAll(((RootMenuClassListProvider)provider).rootMenuClassList());
            }else{
                rooMenuClassList.add(provider.rootMenuClass());
            }
            rooMenuClassList.forEach(rootMenuClass->{
                WebAdminPermissionConfig config = new WebAdminPermissionConfig();
//              config.setRootMenuClassProvider(provider);
                config.setRootMenuClass(rootMenuClass);
                list.add(config);
            });
        });
        return list;
    }
项目:uimaster    文件:PersistentConfig.java   
@Bean
    @ConditionalOnBean(name = "dataSource")
    public EntityManagerFactory entityManagerFactory() {
        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        vendorAdapter.setGenerateDdl(true);

        LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
        factory.setJpaVendorAdapter(vendorAdapter);
        factory.setPackagesToScan("org.shaolin");
        factory.setDataSource(dataSource());
//      factory.setPersistenceUnitManager(persistenceUnitManager);
//      factory.setMappingResources(mappingResources);
        factory.afterPropertiesSet();

        return factory.getObject();
    }
项目:spring-security-oauth2-boot    文件:ResourceServerTokenServicesConfiguration.java   
@Bean
@ConditionalOnBean(ConnectionFactoryLocator.class)
@ConditionalOnMissingBean(ResourceServerTokenServices.class)
public SpringSocialTokenServices socialTokenServices() {
    return new SpringSocialTokenServices(this.connectionFactory,
            this.sso.getClientId());
}
项目:cas-5.1.0    文件:CasReportsConfiguration.java   
@Profile("standalone")
@ConditionalOnBean(name = "configurationPropertiesEnvironmentManager")
@Bean
@RefreshScope
public MvcEndpoint internalConfigController() {
    return new ConfigurationStateController(casProperties);
}
项目:cereebro    文件:CereebroEurekaInstanceAutoConfiguration.java   
@Bean
@ConditionalOnBean(SnitchEndpoint.class)
public EurekaMetadataPopulator eurekaMetadataPopulator(SnitchEndpoint snitch, ApplicationInfoManager manager,
        ObjectMapper mapper) {
    RelaxedPropertyResolver relaxedPropertyResolver = new RelaxedPropertyResolver(env, "cereebro.snitch.eureka.");
    EurekaInstanceSnitchProperties props = new EurekaInstanceSnitchProperties();
    props.setEndpointUrl(relaxedPropertyResolver.getProperty("endpointUrl"));
    props.setEndpointUrlPath(relaxedPropertyResolver.getProperty("endpointUrlPath"));
    EurekaMetadataPopulator metadataPopulator = new EurekaMetadataPopulator(snitch, manager, props, mapper);
    metadataPopulator.populate();
    return metadataPopulator;
}
项目:elephant    文件:ActivemqConfig.java   
@Bean
@ConditionalOnBean(JmsTemplate.class)
public ProducerService activemqProducerService(JmsTemplate jmsTemplate){
    ActivemqProducerService activemqProducer = new ActivemqProducerService();
    activemqProducer.setJmsTemplate(jmsTemplate);
    return activemqProducer;
}
项目:spring-boot-autoconfigure    文件:MyBatisAutoConfiguration.java   
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ConditionalOnBean(SqlSession.class)
@ConditionalOnMissingBean
public SqlMapper sqlMapper(SqlSession sqlSession) {
    return new SqlMapper(sqlSession);
}
项目:spring-data-snowdrop    文件:SnowdropDataInfinispanEmbeddedAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(EntityToCacheMapper.class)
@ConditionalOnBean(EmbeddedCacheManager.class)
public EntityToCacheMapper createDefaultEntityToCacheMapper(final EmbeddedCacheManager cacheManager) {
    return new EntityToCacheMapper() {
        public <ID, T> Cache<ID, T> getCache(Class<T> entityClass) {
            return cacheManager.getCache(); // always return default cache
        }
    };
}
项目:spring-data-snowdrop    文件:SnowdropDataInfinispanRemoteAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(EntityToRemoteCacheMapper.class)
@ConditionalOnBean(RemoteCacheManager.class)
public EntityToRemoteCacheMapper createDefaultEntityToCacheMapper(final RemoteCacheManager cacheManager) {
    return new EntityToRemoteCacheMapper() {
        public <ID, T> RemoteCache<ID, T> getRemoteCache(Class<T> entityClass) {
            return cacheManager.getCache(); // always return default cache
        }
    };
}
项目:quickfixj-spring-boot-starter    文件:QuickFixJServerEndpointAutoConfiguration.java   
@Bean
@ConditionalOnBean(name = {"serverAcceptor", "serverSessionSettings"})
@ConditionalOnClass({Acceptor.class, SessionSettings.class})
@ConditionalOnMissingBean
@ConditionalOnEnabledEndpoint("quickfixjserver")
public QuickFixJServerEndpoint quickfixjServerEndpoint(Acceptor serverAcceptor, SessionSettings serverSessionSettings) {
    return new QuickFixJServerEndpoint(serverAcceptor, serverSessionSettings);
}
项目:quickfixj-spring-boot-starter    文件:QuickFixJClientEndpointAutoConfiguration.java   
@Bean
   @ConditionalOnBean(name = {"clientInitiator", "clientSessionSettings"})
   @ConditionalOnClass({Initiator.class, SessionSettings.class})
   @ConditionalOnMissingBean
@ConditionalOnEnabledEndpoint("quickfixjclient")
   public QuickFixJClientEndpoint quickfixjClientEndpoint(Initiator clientInitiator, SessionSettings clientSessionSettings) {
       return new QuickFixJClientEndpoint(clientInitiator, clientSessionSettings);
   }
项目:spring-cloud-dashboard    文件:DataFlowControllerAutoConfiguration.java   
@Bean
@ConditionalOnBean(ApplicationDefinitionRepository.class)
public ApplicationDefinitionController applicationDefinitionController(ApplicationDefinitionRepository repository,
        DeploymentIdRepository deploymentIdRepository, ApplicationDeploymentController deploymentController,
        AppDeployer deployer, AppRegistry appRegistry) {
    return new ApplicationDefinitionController(repository, deploymentIdRepository, deploymentController, deployer, appRegistry);
}
项目:spring-cloud-dashboard    文件:DataFlowControllerAutoConfiguration.java   
@Bean
@ConditionalOnBean(ApplicationDefinitionRepository.class)
public ApplicationDeploymentController applicationDeploymentController(ApplicationDefinitionRepository repository,
        DeploymentIdRepository deploymentIdRepository, EavRegistryRepository eavRegistryRepository,
        AppDeployer deployer, AppRegistry appRegistry, ApplicationConfigurationMetadataResolver metadataResolver,
        CommonApplicationProperties appsProperties) {
    return new ApplicationDeploymentController(repository, deploymentIdRepository, eavRegistryRepository, deployer,
            appRegistry, metadataResolver, appsProperties);
}
项目:java-spring-cloud    文件:WebsocketAutoConfiguration.java   
@Bean
@ConditionalOnBean(WebSocketMessageBrokerConfigurationSupport.class)
public TracingChannelInterceptor tracingInboundChannelInterceptor(
    WebSocketMessageBrokerConfigurationSupport config) {
  TracingChannelInterceptor interceptor = new TracingChannelInterceptor(tracer,
      Tags.SPAN_KIND_SERVER);
  config.clientInboundChannel().addInterceptor(interceptor);
  return interceptor;
}
项目:java-spring-cloud    文件:WebsocketAutoConfiguration.java   
@Bean
@ConditionalOnBean(WebSocketMessageBrokerConfigurationSupport.class)
public TracingChannelInterceptor tracingOutboundChannelInterceptor(
    WebSocketMessageBrokerConfigurationSupport config) {
  TracingChannelInterceptor interceptor = new TracingChannelInterceptor(tracer,
      Tags.SPAN_KIND_CLIENT);
  config.clientOutboundChannel().addInterceptor(interceptor);
  return interceptor;
}
项目:nakadi-producer-spring-boot-starter    文件:NakadiProducerAutoConfiguration.java   
@Bean
@ConditionalOnBean(SnapshotEventCreationEndpoint.class)
@ConditionalOnEnabledEndpoint("snapshot_event_creation")
public SnapshotEventCreationMvcEndpoint snapshotEventCreationMvcEndpoint(
        SnapshotEventCreationEndpoint snapshotEventCreationEndpoint) {
    return new SnapshotEventCreationMvcEndpoint(snapshotEventCreationEndpoint);
}
项目:xitikit-blue    文件:B2CPolicyAutoConfiguration.java   
@Bean("blueKitB2CPolicy")
@ConditionalOnBean(B2CProperties.class)
@ConfigurationProperties("blue-kit.b2c")
public B2CProperties blueKitB2CProperties(){

    return new B2CProperties();
}
项目: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();
}
项目:xitikit-blue    文件:B2CPolicyAutoConfiguration.java   
@Bean("blueKitSignInPolicy")
@ConditionalOnBean(SignInPolicy.class)
@ConditionalOnProperty(prefix = "blue-kit.b2c.policy.sign-in", value = {"name", "redirect-url"})
@ConfigurationProperties("blue-kit.b2c.policy.sign-in")
public SignInPolicy blueKitSignInPolicy(){

    return new SignInPolicy();
}
项目:xitikit-blue    文件:B2CPolicyAutoConfiguration.java   
@Bean("blueKitSignUpOrSignInPolicy")
@ConditionalOnBean(SignUpOrSignInPolicy.class)
@ConditionalOnProperty(prefix = "blue-kit.b2c.policy.sign-up-or-sign-in", value = {"name", "redirect-url"})
@ConfigurationProperties("blue-kit.b2c.policy.sign-up-or-sign-in")
public SignUpOrSignInPolicy blueKitSignUpOrSignInPolicy(){

    return new SignUpOrSignInPolicy();
}
项目:xitikit-blue    文件:B2CPolicyAutoConfiguration.java   
@Bean("blueKitEditProfilePolicy")
@ConditionalOnBean(EditProfilePolicy.class)
@ConditionalOnProperty(prefix = "blue-kit.b2c.policy.edit-profile", value = {"name", "redirect-url"})
@ConfigurationProperties("blue-kit.b2c.policy.edit-profile")
public EditProfilePolicy blueKitEditProfilePolicy(){

    return new EditProfilePolicy();
}
项目: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();
}
项目: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();
}
项目: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.");
}
项目:xitikit-blue    文件:B2CServicesAutoConfiguration.java   
@Bean
@Autowired
@ConditionalOnBean(NonceProperties.class)
@ConditionalOnMissingBean(NonceService.class)
public NonceService blueKitNonceService(final NonceStore nonceStore, final NonceProperties nonceProperties){
    //TODO: Add logic for checking whether a shared caching framework is enabled
    if(nonceProperties.isDisabled()){
        return new NonceService(){

            @Override
            @NonNull
            public Nonce generate(){

                return new Nonce();
            }

            @Override
            public boolean isValid(final String nonce){

                return false;
            }

            @Override
            public boolean isDisabled(){

                return true;
            }
        };
    }
    return new SimpleNonceService(nonceStore, nonceProperties);
}
项目:hsweb-framework    文件:DefaultAuthorizationAutoConfiguration.java   
@Bean
@ConditionalOnBean(AuthenticationManager.class)
public UserTokenAuthenticationSupplier userTokenAuthenticationSupplier(AuthenticationManager authenticationManager) {
    UserTokenAuthenticationSupplier supplier= new UserTokenAuthenticationSupplier(authenticationManager);
    AuthenticationHolder.addSupplier(supplier);
    return supplier;
}
项目:elastic-crud    文件:ElasticSearchRepositoryFactoryAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(DatabaseRepositoryFactory.class)
@ConditionalOnBean(value={Client.class, JsonSerializationFactory.class, DatabaseScrollingFactory.class})
DatabaseRepositoryFactory databaseRepositoryFactory(
  final Client client,
  final JsonSerializationFactory serialization,
  final DatabaseScrollingFactory factory) {
  return new ElasticSearchRepositoryFactory(serialization, client, factory);
}
项目:elastic-crud    文件:JacksonConversionAutoConfiguration.java   
@Bean
@Autowired
@ConditionalOnBean(ObjectMapper.class)
@ConditionalOnMissingBean(JsonSerializationFactory.class)
JsonSerializationFactory jsonSerializationFactory(final ObjectMapper mapper) {
  return new JacksonSerializationFactory(mapper);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MockMvcWebClientAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean({ WebClient.class, MockMvcWebClientBuilder.class })
@ConditionalOnBean(MockMvc.class)
public MockMvcWebClientBuilder mockMvcWebClientBuilder(MockMvc mockMvc) {
    return MockMvcWebClientBuilder.mockMvcSetup(mockMvc)
            .withDelegate(new LocalHostWebClient(this.environment));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MockMvcWebDriverAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean({ WebDriver.class, MockMvcHtmlUnitDriverBuilder.class })
@ConditionalOnBean(MockMvc.class)
public MockMvcHtmlUnitDriverBuilder mockMvcHtmlUnitDriverBuilder(MockMvc mockMvc) {
    return MockMvcHtmlUnitDriverBuilder.mockMvcSetup(mockMvc)
            .withDelegate(new LocalHostWebConnectionHtmlUnitDriver(this.environment,
                    BrowserVersion.CHROME));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcHypermediaManagementContextConfiguration.java   
@Bean
@ConditionalOnBean(DocsMvcEndpoint.class)
@ConditionalOnMissingBean(CurieProvider.class)
@ConditionalOnProperty(prefix = "endpoints.docs.curies", name = "enabled", matchIfMissing = false)
public DefaultCurieProvider curieProvider(ServerProperties server,
        ManagementServerProperties management, DocsMvcEndpoint endpoint) {
    String path = management.getContextPath() + endpoint.getPath()
            + "/#spring_boot_actuator__{rel}";
    if (server.getPort().equals(management.getPort()) && management.getPort() != 0) {
        path = server.getPath(path);
    }
    return new DefaultCurieProvider("boot", new UriTemplate(path));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DispatcherServletAutoConfiguration.java   
@Bean
@ConditionalOnBean(MultipartResolver.class)
@ConditionalOnMissingBean(name = DispatcherServlet.MULTIPART_RESOLVER_BEAN_NAME)
public MultipartResolver multipartResolver(MultipartResolver resolver) {
    // Detect if the user has created a MultipartResolver but named it incorrectly
    return resolver;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DispatcherServletAutoConfiguration.java   
@Bean(name = DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME)
@ConditionalOnBean(value = DispatcherServlet.class, name = DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
public ServletRegistrationBean dispatcherServletRegistration(
        DispatcherServlet dispatcherServlet) {
    ServletRegistrationBean registration = new ServletRegistrationBean(
            dispatcherServlet, this.serverProperties.getServletMapping());
    registration.setName(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
    registration.setLoadOnStartup(
            this.webMvcProperties.getServlet().getLoadOnStartup());
    if (this.multipartConfig != null) {
        registration.setMultipartConfig(this.multipartConfig);
    }
    return registration;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ErrorMvcAutoConfiguration.java   
@Bean
@ConditionalOnBean(DispatcherServlet.class)
@ConditionalOnMissingBean
public DefaultErrorViewResolver conventionErrorViewResolver() {
    return new DefaultErrorViewResolver(this.applicationContext,
            this.resourceProperties);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WebMvcAutoConfiguration.java   
@Bean
@ConditionalOnBean(View.class)
@ConditionalOnMissingBean
public BeanNameViewResolver beanNameViewResolver() {
    BeanNameViewResolver resolver = new BeanNameViewResolver();
    resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10);
    return resolver;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WebMvcAutoConfiguration.java   
@Bean
@ConditionalOnBean(ViewResolver.class)
@ConditionalOnMissingBean(name = "viewResolver", value = ContentNegotiatingViewResolver.class)
public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {
    ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
    resolver.setContentNegotiationManager(
            beanFactory.getBean(ContentNegotiationManager.class));
    // ContentNegotiatingViewResolver uses all the other view resolvers to locate
    // a view so it should have a high precedence
    resolver.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return resolver;
}