Skip to content

Commit

Permalink
fix: fix condition, it doesn't work if the ConditionalOnMissingBean i…
Browse files Browse the repository at this point in the history
…s on a Component class

Fixes #874
  • Loading branch information
Lars Bilger committed Oct 6, 2023
1 parent 95b91cb commit c26eaba
Showing 1 changed file with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import org.axonframework.queryhandling.QueryHandler
import org.axonframework.queryhandling.QueryUpdateEmitter
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.data.domain.PageRequest
import org.springframework.data.domain.Sort
import org.springframework.stereotype.Component
import reactor.core.Disposable
import reactor.core.publisher.Mono
import reactor.kotlin.core.publisher.switchIfEmpty
Expand All @@ -40,12 +41,42 @@ import java.util.concurrent.CompletableFuture
import javax.annotation.PostConstruct
import javax.annotation.PreDestroy

/**
* Configuration class for conditionally creating the MongoViewService.
*/
@Configuration
class MongoViewServiceConfiguration {
@Bean
@ConditionalOnMissingBean
fun mongoViewService(
properties: TaskPoolMongoViewProperties,
taskRepository: TaskRepository,
dataEntryRepository: DataEntryRepository,
taskWithDataEntriesRepository: TaskWithDataEntriesRepository,
@Autowired(required = false)
taskChangeTracker: TaskChangeTracker?,
@Autowired(required = false)
dataEntryChangeTracker: DataEntryChangeTracker?,
queryUpdateEmitter: QueryUpdateEmitter,
configuration: EventProcessingConfiguration,
clock: Clock
) = MongoViewService(
properties,
taskRepository,
dataEntryRepository,
taskWithDataEntriesRepository,
taskChangeTracker,
dataEntryChangeTracker,
queryUpdateEmitter,
configuration,
clock
)
}

/**
* Mongo-based projection.
*/
@Component
@ProcessingGroup(MongoViewService.PROCESSING_GROUP)
@ConditionalOnMissingBean
class MongoViewService(
private val properties: TaskPoolMongoViewProperties,
private val taskRepository: TaskRepository,
Expand Down

0 comments on commit c26eaba

Please sign in to comment.