Repository: camel
Updated Branches:
  refs/heads/master 178e74e79 -> 20ff9af84


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/20ff9af8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/20ff9af8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/20ff9af8

Branch: refs/heads/master
Commit: 20ff9af84eda407b15cb420b8d9af449b84f5021
Parents: 178e74e
Author: lburgazzoli <lburgazz...@gmail.com>
Authored: Thu May 12 10:31:34 2016 +0200
Committer: lburgazzoli <lburgazz...@gmail.com>
Committed: Thu May 12 10:31:34 2016 +0200

----------------------------------------------------------------------
 .../idempotent/EhcacheIdempotentRepository.java | 33 +++++++++++++-------
 1 file changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/20ff9af8/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

Reply via email to