The "maestro" persistence class has synchronous and asynchronous. These interfaces are extended mainly to add a feature that has a Diana driver, but the Artemis API does not support, eg., the live query at OrientDB, consistency level. To make secure an extension there is template method class.
AbstractKeyValueRepository
AbstractColumnRepository
AbstractColumnRepositoryAsync
AbstractDocumentRepository
AbstractDocumentRepositoryAsync
To demonstrate, it will create a ColumnRepository extension to supports a Cassandra methods that do exists on diana-driver: Cassandra Query Language and consistency level.
publicclassCassandraColumnRepositoryextendsAbstractColumnRepository { @InjectprivateColumnEntityConverter converter; @InjectprivateCassandraColumnFamilyManager manager; @InjectprivateColumnWorkflow workflow; @InjectprivateColumnEventPersistManager eventManager; @OverrideprotectedColumnEntityConvertergetConverter() {return converter; } @OverrideprotectedColumnFamilyManagergetManager() {return manager; } @OverrideprotectedColumnWorkflowgetFlow() {return workflow; } @OverrideprotectedColumnEventPersistManagergetEventManager() {return eventManager; }public <T> Tsave(T entity,ConsistencyLevel level) {Objects.requireNonNull(entity,"entity is required");Objects.requireNonNull(level,"level is required");UnaryOperator<ColumnEntity> save = e ->manager.save(e, level);returnworkflow.flow(entity, save); }public <T> Tsave(T entity,Duration ttl,ConsistencyLevel level) throwsNullPointerException {Objects.requireNonNull(entity,"entity is required");Objects.requireNonNull(level,"level is required");UnaryOperator<ColumnEntity> save = e ->manager.save(e, ttl, level);returnworkflow.flow(entity, save); }public <T> List<T> cql(String query) throwsNullPointerException {Objects.requireNonNull(query,"query is required");List<ColumnEntity> entities =manager.cql(query);returnentities.stream().map(converter::toEntity).map(c -> (T) c).collect(Collectors.toList()); }publicvoiddelete(ColumnDeleteQuery query,ConsistencyLevel level) throwsNullPointerException {manager.delete(query, level); }}
To conclude, extending the AbstractColumnRepository the CassandraColumnRepository will have support to the methods on Artemis interface and also append the Cassandra resources.