Class ExecutorReactiveOperations
- java.lang.Object
-
- io.micronaut.data.runtime.operations.ExecutorReactiveOperations
-
- All Implemented Interfaces:
ReactiveRepositoryOperations
public class ExecutorReactiveOperations extends java.lang.Object implements ReactiveRepositoryOperations
An implementation ofReactiveRepositoryOperations
that delegates to a blocking operations and specifiedExecutor
. This can be used in absence of true reactive support at the driver level an allows composing blocking operations within reactive flows.If a backing implementation provides a reactive API then the backing implementation should not use this class and instead directly implement the
ReactiveRepositoryOperations
interface.- Since:
- 1.0.0
- Author:
- graemerocher
- See Also:
ReactiveRepositoryOperations
-
-
Constructor Summary
Constructors Constructor Description ExecutorReactiveOperations(RepositoryOperations datastore, java.util.concurrent.Executor executor)
Deprecated.ExecutorReactiveOperations(RepositoryOperations datastore, java.util.concurrent.Executor executor, DataConversionService<?> dataConversionService)
Default constructor.ExecutorReactiveOperations(ExecutorAsyncOperations asyncOperations)
Deprecated.ExecutorReactiveOperations(ExecutorAsyncOperations asyncOperations, DataConversionService dataConversionService)
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> org.reactivestreams.Publisher<java.lang.Long>
count(PagedQuery<T> pagedQuery)
Counts all results for the given query.<T> org.reactivestreams.Publisher<java.lang.Number>
delete(DeleteOperation<T> operation)
Deletes the entity.<T> org.reactivestreams.Publisher<java.lang.Number>
deleteAll(DeleteBatchOperation<T> operation)
Deletes all the entities of the given type.org.reactivestreams.Publisher<java.lang.Number>
executeUpdate(PreparedQuery<?,java.lang.Number> preparedQuery)
Executes an update for the given query and parameter values.<T> org.reactivestreams.Publisher<java.lang.Boolean>
exists(PreparedQuery<T,java.lang.Boolean> preparedQuery)
Check with an record exists for the given query.<T> org.reactivestreams.Publisher<T>
findAll(PagedQuery<T> pagedQuery)
Finds all results for the given query.<T,R>
org.reactivestreams.Publisher<R>findAll(PreparedQuery<T,R> preparedQuery)
Finds all results for the given query.<T,R>
org.reactivestreams.Publisher<R>findOne(PreparedQuery<T,R> preparedQuery)
Find one by Query.<T> org.reactivestreams.Publisher<T>
findOne(java.lang.Class<T> type, java.io.Serializable id)
Find one by ID.<T,R>
org.reactivestreams.Publisher<R>findOptional(PreparedQuery<T,R> preparedQuery)
Find one by Query.<T> org.reactivestreams.Publisher<T>
findOptional(java.lang.Class<T> type, java.io.Serializable id)
Find one by ID.<R> org.reactivestreams.Publisher<Page<R>>
findPage(PagedQuery<R> pagedQuery)
Find a page for the given entity and pageable.<T> org.reactivestreams.Publisher<T>
persist(InsertOperation<T> entity)
Persist the entity returning a possibly new entity.<T> org.reactivestreams.Publisher<T>
persistAll(InsertBatchOperation<T> operation)
Persist all the given entities.<T> org.reactivestreams.Publisher<T>
update(UpdateOperation<T> operation)
Updates the entity returning a possibly new entity.<T> org.reactivestreams.Publisher<T>
updateAll(UpdateBatchOperation<T> operation)
Updates the entities for the given operation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.data.operations.reactive.ReactiveRepositoryOperations
executeDelete
-
-
-
-
Constructor Detail
-
ExecutorReactiveOperations
@Deprecated public ExecutorReactiveOperations(@NonNull RepositoryOperations datastore, @NonNull java.util.concurrent.Executor executor)
Deprecated.Default constructor.- Parameters:
datastore
- The target operationsexecutor
- The executor to use.
-
ExecutorReactiveOperations
public ExecutorReactiveOperations(@NonNull RepositoryOperations datastore, @NonNull java.util.concurrent.Executor executor, DataConversionService<?> dataConversionService)
Default constructor.- Parameters:
datastore
- The target operationsexecutor
- The executor to use.dataConversionService
- The data conversion service
-
ExecutorReactiveOperations
@Deprecated public ExecutorReactiveOperations(@NonNull ExecutorAsyncOperations asyncOperations)
Deprecated.Default constructor.- Parameters:
asyncOperations
- The instance operations instance
-
ExecutorReactiveOperations
public ExecutorReactiveOperations(@NonNull ExecutorAsyncOperations asyncOperations, DataConversionService dataConversionService)
Default constructor.- Parameters:
asyncOperations
- The instance operations instancedataConversionService
- The data conversion service
-
-
Method Detail
-
findOne
@NonNull public <T> org.reactivestreams.Publisher<T> findOne(@NonNull java.lang.Class<T> type, @NonNull java.io.Serializable id)
Description copied from interface:ReactiveRepositoryOperations
Find one by ID.- Specified by:
findOne
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
type
- The typeid
- The id- Returns:
- A publisher that emits the result
-
exists
public <T> org.reactivestreams.Publisher<java.lang.Boolean> exists(@NonNull PreparedQuery<T,java.lang.Boolean> preparedQuery)
Description copied from interface:ReactiveRepositoryOperations
Check with an record exists for the given query.- Specified by:
exists
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The declaring type- Parameters:
preparedQuery
- The query- Returns:
- True if it exists
-
findOne
@NonNull public <T,R> org.reactivestreams.Publisher<R> findOne(@NonNull PreparedQuery<T,R> preparedQuery)
Description copied from interface:ReactiveRepositoryOperations
Find one by Query.- Specified by:
findOne
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic resultTypeR
- The result type- Parameters:
preparedQuery
- The prepared query- Returns:
- A publisher that emits the result
-
findOptional
@NonNull public <T> org.reactivestreams.Publisher<T> findOptional(@NonNull java.lang.Class<T> type, @NonNull java.io.Serializable id)
Description copied from interface:ReactiveRepositoryOperations
Find one by ID.- Specified by:
findOptional
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
type
- The typeid
- The id- Returns:
- A publisher that emits zero or one result
-
findOptional
@NonNull public <T,R> org.reactivestreams.Publisher<R> findOptional(@NonNull PreparedQuery<T,R> preparedQuery)
Description copied from interface:ReactiveRepositoryOperations
Find one by Query.- Specified by:
findOptional
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic resultTypeR
- The result type- Parameters:
preparedQuery
- The prepared query- Returns:
- A publisher that emits the zero or one result
-
findAll
@NonNull public <T> org.reactivestreams.Publisher<T> findAll(PagedQuery<T> pagedQuery)
Description copied from interface:ReactiveRepositoryOperations
Finds all results for the given query.- Specified by:
findAll
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
pagedQuery
- The paged query- Returns:
- A publisher that emits the results
-
count
@NonNull public <T> org.reactivestreams.Publisher<java.lang.Long> count(PagedQuery<T> pagedQuery)
Description copied from interface:ReactiveRepositoryOperations
Counts all results for the given query.- Specified by:
count
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
pagedQuery
- The paged query- Returns:
- A publisher that emits the count as a long
-
findPage
@NonNull public <R> org.reactivestreams.Publisher<Page<R>> findPage(@NonNull PagedQuery<R> pagedQuery)
Description copied from interface:ReactiveRepositoryOperations
Find a page for the given entity and pageable.- Specified by:
findPage
in interfaceReactiveRepositoryOperations
- Type Parameters:
R
- The entity generic type- Parameters:
pagedQuery
- The paged query- Returns:
- The page type
-
findAll
@NonNull public <T,R> org.reactivestreams.Publisher<R> findAll(@NonNull PreparedQuery<T,R> preparedQuery)
Description copied from interface:ReactiveRepositoryOperations
Finds all results for the given query.- Specified by:
findAll
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The entity typeR
- The result type- Parameters:
preparedQuery
- The prepared query- Returns:
- A publisher that emits an iterable with all results
-
persist
@NonNull public <T> org.reactivestreams.Publisher<T> persist(@NonNull InsertOperation<T> entity)
Description copied from interface:ReactiveRepositoryOperations
Persist the entity returning a possibly new entity.- Specified by:
persist
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
entity
- The entity operation- Returns:
- A publisher that emits the entity
-
update
@NonNull public <T> org.reactivestreams.Publisher<T> update(@NonNull UpdateOperation<T> operation)
Description copied from interface:ReactiveRepositoryOperations
Updates the entity returning a possibly new entity.- Specified by:
update
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The entity operation- Returns:
- A publisher that emits the entity
-
updateAll
@NonNull public <T> org.reactivestreams.Publisher<T> updateAll(@NonNull UpdateBatchOperation<T> operation)
Description copied from interface:ReactiveRepositoryOperations
Updates the entities for the given operation.- Specified by:
updateAll
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The operation- Returns:
- The updated entities
-
persistAll
@NonNull public <T> org.reactivestreams.Publisher<T> persistAll(@NonNull InsertBatchOperation<T> operation)
Description copied from interface:ReactiveRepositoryOperations
Persist all the given entities.- Specified by:
persistAll
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The batch operation- Returns:
- The entities, possibly mutated
-
executeUpdate
@NonNull public org.reactivestreams.Publisher<java.lang.Number> executeUpdate(@NonNull PreparedQuery<?,java.lang.Number> preparedQuery)
Description copied from interface:ReactiveRepositoryOperations
Executes an update for the given query and parameter values. If it is possible to return the number of objects updated, then do so.- Specified by:
executeUpdate
in interfaceReactiveRepositoryOperations
- Parameters:
preparedQuery
- The prepared query- Returns:
- A publisher that emits a boolean true if the update was successful
-
delete
@NonNull public <T> org.reactivestreams.Publisher<java.lang.Number> delete(@NonNull DeleteOperation<T> operation)
Description copied from interface:ReactiveRepositoryOperations
Deletes the entity.- Specified by:
delete
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The batch operation- Returns:
- A publisher that emits the number of entities deleted
-
deleteAll
@NonNull public <T> org.reactivestreams.Publisher<java.lang.Number> deleteAll(@NonNull DeleteBatchOperation<T> operation)
Description copied from interface:ReactiveRepositoryOperations
Deletes all the entities of the given type.- Specified by:
deleteAll
in interfaceReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The batch operation- Returns:
- A publisher that emits the number of entities deleted
-
-