/** * Create an {@link IndexManager} that allows index creation. * * @return */ @Bean(name = BeanNames.COUCHBASE_INDEX_MANAGER) public IndexManager indexManager() { return new IndexManager(true, true, false); }
viewAsync = buildAllView(viewIndexed, metadata, couchbaseOperations.getCouchbaseBucket(), couchbaseOperations.getConverter().getTypeKey()); n1qlPrimaryAsync = buildN1qlPrimary(metadata, couchbaseOperations.getCouchbaseBucket()); n1qlSecondaryAsync = buildN1qlSecondary(n1qlSecondaryIndexed, metadata, couchbaseOperations.getCouchbaseBucket(), couchbaseOperations.getConverter().getTypeKey());
/** * Returns a new Repository based on the metadata. Two categories of repositories can be instantiated: * {@link SimpleCouchbaseRepository} and {@link N1qlCouchbaseRepository}. * * This method performs feature checks to decide which of the two categories can be instantiated (eg. is N1QL available?). * Instantiation is done via reflection, see {@link #getRepositoryBaseClass(RepositoryMetadata)}. * * @param metadata the repository metadata. * * @return a new created repository. */ @Override protected final Object getTargetRepository(final RepositoryInformation metadata) { CouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(metadata.getRepositoryInterface(), metadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); ViewIndexed viewIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), ViewIndexed.class); N1qlPrimaryIndexed n1qlPrimaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlPrimaryIndexed.class); N1qlSecondaryIndexed n1qlSecondaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlSecondaryIndexed.class); checkFeatures(metadata, isN1qlAvailable, n1qlPrimaryIndexed, n1qlSecondaryIndexed); indexManager.buildIndexes(metadata, viewIndexed, n1qlPrimaryIndexed, n1qlSecondaryIndexed, couchbaseOperations); CouchbaseEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); SimpleCouchbaseRepository repo = getTargetRepositoryViaReflection(metadata, entityInformation, couchbaseOperations); repo.setViewMetadataProvider(viewPostProcessor.getViewMetadataProvider()); return repo; }
viewAsync = buildAllView(viewIndexed, metadata, rxjava1CouchbaseOperations.getCouchbaseBucket(), rxjava1CouchbaseOperations.getConverter().getTypeKey()); n1qlPrimaryAsync = buildN1qlPrimary(metadata, rxjava1CouchbaseOperations.getCouchbaseBucket()); n1qlSecondaryAsync = buildN1qlSecondary(n1qlSecondaryIndexed, metadata, rxjava1CouchbaseOperations.getCouchbaseBucket(), rxjava1CouchbaseOperations.getConverter().getTypeKey());
/** * Returns a new Repository based on the metadata. Two categories of repositories can be instantiated: * {@link SimpleCouchbaseRepository} and {@link N1qlCouchbaseRepository}. * * This method performs feature checks to decide which of the two categories can be instantiated (eg. is N1QL available?). * Instantiation is done via reflection, see {@link #getRepositoryBaseClass(RepositoryMetadata)}. * * @param metadata the repository metadata. * * @return a new created repository. */ @Override protected final Object getTargetRepository(final RepositoryInformation metadata) { CouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(metadata.getRepositoryInterface(), metadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); ViewIndexed viewIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), ViewIndexed.class); N1qlPrimaryIndexed n1qlPrimaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlPrimaryIndexed.class); N1qlSecondaryIndexed n1qlSecondaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlSecondaryIndexed.class); checkFeatures(metadata, isN1qlAvailable, n1qlPrimaryIndexed, n1qlSecondaryIndexed); indexManager.buildIndexes(metadata, viewIndexed, n1qlPrimaryIndexed, n1qlSecondaryIndexed, couchbaseOperations); CouchbaseEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); SimpleCouchbaseRepository repo = getTargetRepositoryViaReflection(metadata, entityInformation, couchbaseOperations); repo.setViewMetadataProvider(viewPostProcessor.getViewMetadataProvider()); return repo; }
/** * Create an {@link IndexManager} that allows index creation. * * @return */ @Bean(name = BeanNames.COUCHBASE_INDEX_MANAGER) public IndexManager indexManager() { return new IndexManager(true, true, false); }
viewAsync = buildAllView(viewIndexed, metadata, rxjava1CouchbaseOperations.getCouchbaseBucket(), rxjava1CouchbaseOperations.getConverter().getTypeKey()); n1qlPrimaryAsync = buildN1qlPrimary(metadata, rxjava1CouchbaseOperations.getCouchbaseBucket()); n1qlSecondaryAsync = buildN1qlSecondary(n1qlSecondaryIndexed, metadata, rxjava1CouchbaseOperations.getCouchbaseBucket(), rxjava1CouchbaseOperations.getConverter().getTypeKey());
/** * Returns a new Repository based on the metadata. Two categories of repositories can be instantiated: * {@link SimpleReactiveCouchbaseRepository} and {@link ReactiveN1qlCouchbaseRepository}. * * This method performs feature checks to decide which of the two categories can be instantiated (eg. is N1QL available?). * Instantiation is done via reflection, see {@link #getRepositoryBaseClass(RepositoryMetadata)}. * * @param metadata the repository metadata. * * @return a new created repository. */ @Override protected final Object getTargetRepository(final RepositoryInformation metadata) { RxJavaCouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(metadata.getRepositoryInterface(), metadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); ViewIndexed viewIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), ViewIndexed.class); N1qlPrimaryIndexed n1qlPrimaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlPrimaryIndexed.class); N1qlSecondaryIndexed n1qlSecondaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlSecondaryIndexed.class); checkFeatures(metadata, isN1qlAvailable, n1qlPrimaryIndexed, n1qlSecondaryIndexed); indexManager.buildIndexes(metadata, viewIndexed, n1qlPrimaryIndexed, n1qlSecondaryIndexed, couchbaseOperations); CouchbaseEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); SimpleReactiveCouchbaseRepository repo = getTargetRepositoryViaReflection(metadata, entityInformation, couchbaseOperations); repo.setViewMetadataProvider(viewPostProcessor.getViewMetadataProvider()); return repo; }
@Override public IndexManager indexManager() { return new IndexManager(); }
viewAsync = buildAllView(viewIndexed, metadata, couchbaseOperations.getCouchbaseBucket(), couchbaseOperations.getConverter().getTypeKey()); n1qlPrimaryAsync = buildN1qlPrimary(metadata, couchbaseOperations.getCouchbaseBucket()); n1qlSecondaryAsync = buildN1qlSecondary(n1qlSecondaryIndexed, metadata, couchbaseOperations.getCouchbaseBucket(), couchbaseOperations.getConverter().getTypeKey());
/** * Returns a new Repository based on the metadata. Two categories of repositories can be instantiated: * {@link SimpleReactiveCouchbaseRepository} and {@link ReactiveN1qlCouchbaseRepository}. * * This method performs feature checks to decide which of the two categories can be instantiated (eg. is N1QL available?). * Instantiation is done via reflection, see {@link #getRepositoryBaseClass(RepositoryMetadata)}. * * @param metadata the repository metadata. * * @return a new created repository. */ @Override protected final Object getTargetRepository(final RepositoryInformation metadata) { RxJavaCouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(metadata.getRepositoryInterface(), metadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); ViewIndexed viewIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), ViewIndexed.class); N1qlPrimaryIndexed n1qlPrimaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlPrimaryIndexed.class); N1qlSecondaryIndexed n1qlSecondaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlSecondaryIndexed.class); checkFeatures(metadata, isN1qlAvailable, n1qlPrimaryIndexed, n1qlSecondaryIndexed); indexManager.buildIndexes(metadata, viewIndexed, n1qlPrimaryIndexed, n1qlSecondaryIndexed, couchbaseOperations); CouchbaseEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); SimpleReactiveCouchbaseRepository repo = getTargetRepositoryViaReflection(metadata, entityInformation, couchbaseOperations); repo.setViewMetadataProvider(viewPostProcessor.getViewMetadataProvider()); return repo; }
/** * Register an {@link IndexManager} bean that will be used to process {@link ViewIndexed}, * {@link N1qlPrimaryIndexed} and {@link N1qlSecondaryIndexed} annotations on repositories * to automatically create indexes. By default, since such automatic creations are discouraged in * production envrironment, the configuration will assume the worst and will ignore these annotations. * <p/> * If you are sure this configuration used in a context where such automatic creations are desired (eg. * you want automatic index creation in Dev, just not in Prod, and this configuration is the Dev one), * override the bean and use the {@link IndexManager#IndexManager()} constructor (or * {@link IndexManager#IndexManager(boolean, boolean, boolean)} constructor with appropriate flags set to true to * activate). */ @Bean(name = BeanNames.COUCHBASE_INDEX_MANAGER) public IndexManager indexManager() { return new IndexManager(false, false, false); //this ignores view, N1QL primary and secondary annotations }
/** * Register an {@link IndexManager} bean that will be used to process {@link ViewIndexed}, * {@link N1qlPrimaryIndexed} and {@link N1qlSecondaryIndexed} annotations on repositories * to automatically create indexes. By default, since such automatic creations are discouraged in * production envrironment, the configuration will assume the worst and will ignore these annotations. * <p/> * If you are sure this configuration used in a context where such automatic creations are desired (eg. * you want automatic index creation in Dev, just not in Prod, and this configuration is the Dev one), * override the bean and use the {@link IndexManager#IndexManager()} constructor (or * {@link IndexManager#IndexManager(boolean, boolean, boolean)} constructor with appropriate flags set to true to * activate). */ @Bean(name = BeanNames.COUCHBASE_INDEX_MANAGER) public IndexManager indexManager() { return new IndexManager(false, false, false); //this ignores view, N1QL primary and secondary annotations }
@Override protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType, Optional<Object> customImplementation) { RxJavaCouchbaseOperations reactiveCouchbaseOperations = getDependencyInstance(reactiveCouchbaseOperationsBean, RxJavaCouchbaseOperations.class); ReactiveRepositoryOperationsMapping reactiveCouchbaseOperationsMapping = new ReactiveRepositoryOperationsMapping(reactiveCouchbaseOperations); IndexManager indexManager = new IndexManager(); ReactiveCouchbaseRepositoryFactory factory = new ReactiveCouchbaseRepositoryFactory(reactiveCouchbaseOperationsMapping, indexManager); return customImplementation.map(o -> factory.getRepository(repositoryType, o)) .orElseGet(() -> factory.getRepository(repositoryType)); }
@Override protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType, Optional<Object> customImplementation) { RxJavaCouchbaseOperations reactiveCouchbaseOperations = getDependencyInstance(reactiveCouchbaseOperationsBean, RxJavaCouchbaseOperations.class); ReactiveRepositoryOperationsMapping reactiveCouchbaseOperationsMapping = new ReactiveRepositoryOperationsMapping(reactiveCouchbaseOperations); IndexManager indexManager = new IndexManager(); ReactiveCouchbaseRepositoryFactory factory = new ReactiveCouchbaseRepositoryFactory(reactiveCouchbaseOperationsMapping, indexManager); return customImplementation.map(o -> factory.getRepository(repositoryType, o)) .orElseGet(() -> factory.getRepository(repositoryType)); }
@Override protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType) { CouchbaseOperations couchbaseOperations = getDependencyInstance(couchbaseOperationsBean, CouchbaseOperations.class); RepositoryOperationsMapping couchbaseOperationsMapping = new RepositoryOperationsMapping(couchbaseOperations); IndexManager indexManager = new IndexManager(); return create(() -> new CouchbaseRepositoryFactory(couchbaseOperationsMapping, indexManager), repositoryType); }
@Override protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType) { CouchbaseOperations couchbaseOperations = getDependencyInstance(couchbaseOperationsBean, CouchbaseOperations.class); RepositoryOperationsMapping couchbaseOperationsMapping = new RepositoryOperationsMapping(couchbaseOperations); IndexManager indexManager = new IndexManager(); return create(() -> new CouchbaseRepositoryFactory(couchbaseOperationsMapping, indexManager), repositoryType); }