CAMEL-9958 : add management annotations to ehcache idempotent repository
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ca6dae65 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ca6dae65 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ca6dae65 Branch: refs/heads/kube-lb Commit: ca6dae65cb5676694b8f0827472c3a775c32ee85 Parents: 3742612 Author: lburgazzoli <lburgazz...@gmail.com> Authored: Thu May 12 10:31:34 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon May 16 09:59:33 2016 +0200 ---------------------------------------------------------------------- .../idempotent/EhcacheIdempotentRepository.java | 33 +++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/ca6dae65/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/processor/idempotent/EhcacheIdempotentRepository.java ---------------------------------------------------------------------- diff --git a/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/processor/idempotent/EhcacheIdempotentRepository.java b/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/processor/idempotent/EhcacheIdempotentRepository.java index 6018fb8..41a5456 100644 --- a/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/processor/idempotent/EhcacheIdempotentRepository.java +++ b/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/processor/idempotent/EhcacheIdempotentRepository.java @@ -16,14 +16,18 @@ */ package org.apache.camel.component.ehcache.processor.idempotent; +import org.apache.camel.api.management.ManagedAttribute; +import org.apache.camel.api.management.ManagedOperation; +import org.apache.camel.api.management.ManagedResource; import org.apache.camel.spi.IdempotentRepository; import org.apache.camel.support.ServiceSupport; import org.ehcache.Cache; import org.ehcache.CacheManager; +@ManagedResource(description = "Ehcache based message id repository") public class EhcacheIdempotentRepository extends ServiceSupport implements IdempotentRepository<String> { - private String repositoryName; + private String cacheName; private Cache<String, Boolean> cache; private CacheManager cacheManager; @@ -32,21 +36,17 @@ public class EhcacheIdempotentRepository extends ServiceSupport implements Idemp } public EhcacheIdempotentRepository(CacheManager cacheManager, String repositoryName) { - this.repositoryName = repositoryName; + this.cacheName = repositoryName; this.cacheManager = cacheManager; } - @Override - protected void doStart() throws Exception { - cache = cacheManager.getCache(repositoryName, String.class, Boolean.class); - } - - @Override - protected void doStop() throws Exception { - // noop + @ManagedAttribute(description = "The processor name") + public String getCacheName() { + return cacheName; } @Override + @ManagedOperation(description = "Adds the key to the store") public boolean add(String key) { return cache.putIfAbsent(key, false) == null; } @@ -57,22 +57,31 @@ public class EhcacheIdempotentRepository extends ServiceSupport implements Idemp } @Override + @ManagedOperation(description = "Does the store contain the given key") public boolean contains(String key) { return this.cache.containsKey(key); } @Override + @ManagedOperation(description = "Remove the key from the store") public boolean remove(String key) { cache.remove(key); return true; } @Override + @ManagedOperation(description = "Clear the store") public void clear() { cache.clear(); } - public String getRepositoryName() { - return repositoryName; + @Override + protected void doStart() throws Exception { + cache = cacheManager.getCache(cacheName, String.class, Boolean.class); + } + + @Override + protected void doStop() throws Exception { + // noop } } \ No newline at end of file