I do have an initial design proposal to help (I think) clarify these points you make. First, I think we should split the concept of QueryRegion from Region. Basically we will make the distinction between QueryRegion and CacheableRegion (entity, ...) and expose that on RegionFactory by adding a new RegionFactory#createQueryRegion. QueryRegion and however we decide to expose update-timestamps are each accessed directly (not protected by "access" contract). So I'd propose the following changes:
interface RegionFactory {
...
CacheableRegion buildCacheableRegion(String regionName, CacheableRegionNameMapping regionNameMapping, RegionBuildingContext buildingContext);
QueryResultsRegion buildQueryResultsRegion(String regionName, RegionBuildingContext buildingContext);
UpdateTimestampsRegion buildUpdateTimestampsRegion()
}
interface CacheableRegion {
EntityStorageAccess getEntityStorageAccess(NavigableRole rootEntityRole) throws CacheException;
NaturalIdStorageAccess getNaturalIdStorageAccess(NavigableRole rootEntityRole) throws CacheException;
CollectionStorageAccess getCollectionStorageAccess(NavigableRole collectionRole) throws CacheException;
}
interface QueryResultsRegion extends DirectAccessRegion {
}
interface UpdateTimestampsRegion extends DirectAccessRegion {
}
interface DirectAccessRegion {
Object get(SharedSessionContractImplementor session, Object key) throws CacheException;
void put(SharedSessionContractImplementor session, Object key, Object value) throws CacheException;
}
|