@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); }
@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"); } }
/** 営業日チェック */ @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)); } }; }
@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; }
@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; }
@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(); }
@Bean @ConditionalOnBean(ConnectionFactoryLocator.class) @ConditionalOnMissingBean(ResourceServerTokenServices.class) public SpringSocialTokenServices socialTokenServices() { return new SpringSocialTokenServices(this.connectionFactory, this.sso.getClientId()); }
@Profile("standalone") @ConditionalOnBean(name = "configurationPropertiesEnvironmentManager") @Bean @RefreshScope public MvcEndpoint internalConfigController() { return new ConfigurationStateController(casProperties); }
@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; }
@Bean @ConditionalOnBean(JmsTemplate.class) public ProducerService activemqProducerService(JmsTemplate jmsTemplate){ ActivemqProducerService activemqProducer = new ActivemqProducerService(); activemqProducer.setJmsTemplate(jmsTemplate); return activemqProducer; }
@Bean @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @ConditionalOnBean(SqlSession.class) @ConditionalOnMissingBean public SqlMapper sqlMapper(SqlSession sqlSession) { return new SqlMapper(sqlSession); }
@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 } }; }
@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 } }; }
@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); }
@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); }
@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); }
@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); }
@Bean @ConditionalOnBean(WebSocketMessageBrokerConfigurationSupport.class) public TracingChannelInterceptor tracingInboundChannelInterceptor( WebSocketMessageBrokerConfigurationSupport config) { TracingChannelInterceptor interceptor = new TracingChannelInterceptor(tracer, Tags.SPAN_KIND_SERVER); config.clientInboundChannel().addInterceptor(interceptor); return interceptor; }
@Bean @ConditionalOnBean(WebSocketMessageBrokerConfigurationSupport.class) public TracingChannelInterceptor tracingOutboundChannelInterceptor( WebSocketMessageBrokerConfigurationSupport config) { TracingChannelInterceptor interceptor = new TracingChannelInterceptor(tracer, Tags.SPAN_KIND_CLIENT); config.clientOutboundChannel().addInterceptor(interceptor); return interceptor; }
@Bean @ConditionalOnBean(SnapshotEventCreationEndpoint.class) @ConditionalOnEnabledEndpoint("snapshot_event_creation") public SnapshotEventCreationMvcEndpoint snapshotEventCreationMvcEndpoint( SnapshotEventCreationEndpoint snapshotEventCreationEndpoint) { return new SnapshotEventCreationMvcEndpoint(snapshotEventCreationEndpoint); }
@Bean("blueKitB2CPolicy") @ConditionalOnBean(B2CProperties.class) @ConfigurationProperties("blue-kit.b2c") public B2CProperties blueKitB2CProperties(){ return new B2CProperties(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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."); }
@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); }
@Bean @ConditionalOnBean(AuthenticationManager.class) public UserTokenAuthenticationSupplier userTokenAuthenticationSupplier(AuthenticationManager authenticationManager) { UserTokenAuthenticationSupplier supplier= new UserTokenAuthenticationSupplier(authenticationManager); AuthenticationHolder.addSupplier(supplier); return supplier; }
@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); }
@Bean @Autowired @ConditionalOnBean(ObjectMapper.class) @ConditionalOnMissingBean(JsonSerializationFactory.class) JsonSerializationFactory jsonSerializationFactory(final ObjectMapper mapper) { return new JacksonSerializationFactory(mapper); }
@Bean @ConditionalOnMissingBean({ WebClient.class, MockMvcWebClientBuilder.class }) @ConditionalOnBean(MockMvc.class) public MockMvcWebClientBuilder mockMvcWebClientBuilder(MockMvc mockMvc) { return MockMvcWebClientBuilder.mockMvcSetup(mockMvc) .withDelegate(new LocalHostWebClient(this.environment)); }
@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)); }
@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)); }
@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; }
@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; }
@Bean @ConditionalOnBean(DispatcherServlet.class) @ConditionalOnMissingBean public DefaultErrorViewResolver conventionErrorViewResolver() { return new DefaultErrorViewResolver(this.applicationContext, this.resourceProperties); }
@Bean @ConditionalOnBean(View.class) @ConditionalOnMissingBean public BeanNameViewResolver beanNameViewResolver() { BeanNameViewResolver resolver = new BeanNameViewResolver(); resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10); return resolver; }
@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; }