/** * * Base class for Reactive Spring Data Couchbase configuration java config * * @author Subhashni Balakrishnan */ @Configuration public abstract class AbstractReactiveCouchbaseConfiguration extends AbstractReactiveCouchbaseDataConfiguration implements CouchbaseConfigurer {
/** * Creates a {@link RxJavaCouchbaseTemplate}. * * This uses {@link #mappingCouchbaseConverter()}, {@link #translationService()} and {@link #getDefaultConsistency()} * for construction. * * * @throws Exception on Bean construction failure. */ @Bean(name = BeanNames.RXJAVA1_COUCHBASE_TEMPLATE) public RxJavaCouchbaseTemplate reactiveCouchbaseTemplate() throws Exception { RxJavaCouchbaseTemplate template = new RxJavaCouchbaseTemplate(couchbaseConfigurer().couchbaseClusterInfo(), couchbaseConfigurer().couchbaseClient(), mappingCouchbaseConverter(), translationService()); template.setDefaultConsistency(getDefaultConsistency()); return template; }
/** * Creates the {@link ReactiveRepositoryOperationsMapping} bean which will be used by the framework to choose which * {@link RxJavaCouchbaseOperations} should back which {@link ReactiveCouchbaseRepository}. * Override {@link #configureReactiveRepositoryOperationsMapping} in order to customize this. * * @throws Exception */ @Bean(name = BeanNames.REACTIVE_COUCHBASE_OPERATIONS_MAPPING) public ReactiveRepositoryOperationsMapping reactiveRepositoryOperationsMapping(RxJavaCouchbaseTemplate couchbaseTemplate) throws Exception { //create a base mapping that associates all repositories to the default template ReactiveRepositoryOperationsMapping baseMapping = new ReactiveRepositoryOperationsMapping(couchbaseTemplate); //let the user tune it configureReactiveRepositoryOperationsMapping(baseMapping); return baseMapping; }
/** * In order to customize the mapping between repositories/entity types to couchbase templates, * use the provided mapping's api (eg. in order to have different buckets backing different repositories). * * @param mapping the default mapping (will associate all repositories to the default template). */ protected void configureReactiveRepositoryOperationsMapping(ReactiveRepositoryOperationsMapping mapping) { //NO_OP } }