org.zodiac.scaff.crud.service.GenericReactiveCacheSupportCrudService Maven / Gradle / Ivy
package org.zodiac.scaff.crud.service;
import org.zodiac.cache.reactive.ReactiveCache;
import org.zodiac.cache.reactive.ReactiveCacheManager;
import org.zodiac.cache.reactive.supports.UnsupportedReactiveCache;
import org.zodiac.fastorm.rdb.mapping.ReactiveRepository;
public abstract class GenericReactiveCacheSupportCrudService implements EnableCacheReactiveCrudService {
//@Autowired
private ReactiveRepository repository;
//@Autowired(required = false)
private ReactiveCacheManager cacheManager;
protected ReactiveCache cache;
protected GenericReactiveCacheSupportCrudService() {
super();
}
protected GenericReactiveCacheSupportCrudService(ReactiveRepository repository,
ReactiveCacheManager cacheManager) {
this.repository = repository;
this.cacheManager = cacheManager;
}
public GenericReactiveCacheSupportCrudService setRepository(ReactiveRepository repository) {
this.repository = repository;
return this;
}
public GenericReactiveCacheSupportCrudService setCacheManager(ReactiveCacheManager cacheManager) {
this.cacheManager = cacheManager;
return this;
}
@Override
public ReactiveRepository getRepository() {
return repository;
}
@Override
public ReactiveCache getCache() {
if (cache != null) {
return cache;
}
if (cacheManager == null) {
return cache = UnsupportedReactiveCache.getInstance();
}
return cache = cacheManager.getCache(getCacheName());
}
public String getCacheName() {
return this.getClass().getSimpleName();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy