diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-04-17 15:34:48 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-04-17 15:34:48 +0200 |
commit | 7a003c9287be57fe90173e4dd728ad995ed7036e (patch) | |
tree | 0f1f9f82a5fee3acac64610181d3a1d89cf2b240 /src/main/java/at/gv/egiz/moazs/InMemoryDeliveryRepository.java | |
parent | 8e362d5feaf5535bb59bacc1be677d8f10d08f86 (diff) | |
download | moa-zs-7a003c9287be57fe90173e4dd728ad995ed7036e.tar.gz moa-zs-7a003c9287be57fe90173e4dd728ad995ed7036e.tar.bz2 moa-zs-7a003c9287be57fe90173e4dd728ad995ed7036e.zip |
Refactor: Move Repositories to Repository Package
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/InMemoryDeliveryRepository.java')
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/InMemoryDeliveryRepository.java | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/InMemoryDeliveryRepository.java b/src/main/java/at/gv/egiz/moazs/InMemoryDeliveryRepository.java deleted file mode 100644 index aa1e3e9..0000000 --- a/src/main/java/at/gv/egiz/moazs/InMemoryDeliveryRepository.java +++ /dev/null @@ -1,40 +0,0 @@ -package at.gv.egiz.moazs; - -import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Repository; - -import java.util.Optional; -import java.util.concurrent.TimeUnit; - -@Repository -@Profile("!cluster") -public class InMemoryDeliveryRepository implements DeliveryRepository { - - private static final Logger logger = LoggerFactory.getLogger(InMemoryDeliveryRepository.class); - - private static final Cache<String, DeliveryRequestType> rep = CacheBuilder.newBuilder() - .expireAfterWrite(30, TimeUnit.MINUTES) - .build(); - - public InMemoryDeliveryRepository() { - logger.info("InMemoryDeliveryRepository()"); - } - - @Override - public void add(DeliveryRequestType request) { - String key = request.getMetaData().getAppDeliveryID(); - logger.info("Save DeliveryRequest with AppDeliveryId = {} to Cache.", key); - rep.put(key, request); - } - - @Override - public Optional<DeliveryRequestType> getDeliveryRequest(String appDeliveryID) { - DeliveryRequestType deliveryRequestType = rep.getIfPresent(appDeliveryID); - return Optional.ofNullable(deliveryRequestType); - } -} |