core-java
core-java copied to clipboard
Storages and delegation
Currently, it is not easy to create an implementation of, e.g. ProjectionStorage, which would delegate its operations to another instance of ProjectionStorage.
The problem is in protected methods.
package org.example;
// ...
class MyProjectionStorage<I> extends ProjectionStorage<I> {
private final ProjectionStorage<I> delegate;
@Override
protected Optional<EntityRecord> readRecord(I id) {
return delagate.readRecord(id);
// ^
// Compiler error here, cannot access protected method `readRecord`
// outside the Spine package.
}
// ...
}
There are a few methods in ProjectionStorage and other case-specific storages such as readRecord, which are declared protected making it impossible to delegate them.
Currently, I offer to resolve this when we re-design out storages to fit all purposes with just one MessageStorage.
@armiol, FYI. @nick-dolgiy, please feel free to add further details.