camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/8] camel git commit: CAMEL-10599: Add ReloadStrategy to allow watching for file changes and reload routes on the fly.
Date Mon, 19 Dec 2016 15:35:14 GMT
CAMEL-10599: Add ReloadStrategy to allow watching for file changes and reload routes on the
fly.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b868b5f7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b868b5f7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b868b5f7

Branch: refs/heads/master
Commit: b868b5f7a3bf839dc6e96834007cb5fbdaea6a05
Parents: 4df1650
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Dec 19 15:32:45 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Dec 19 16:34:46 2016 +0100

----------------------------------------------------------------------
 .../mbean/ManagedReloadStrategyMBean.java       |  3 +++
 .../camel/management/mbean/ManagedConsumer.java |  5 -----
 .../management/mbean/ManagedReloadStrategy.java | 21 ++++++++++++++++++--
 .../mbean/ManagedStreamCachingStrategy.java     |  4 ----
 .../org/apache/camel/model/ModelHelper.java     |  4 +++-
 .../org/apache/camel/spi/ReloadStrategy.java    |  5 +++++
 .../camel/support/ReloadStrategySupport.java    |  6 ++++++
 7 files changed, 36 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b868b5f7/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedReloadStrategyMBean.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedReloadStrategyMBean.java
b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedReloadStrategyMBean.java
index 3154557..dc13f27 100644
--- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedReloadStrategyMBean.java
+++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedReloadStrategyMBean.java
@@ -33,4 +33,7 @@ public interface ManagedReloadStrategyMBean extends ManagedServiceMBean
{
     @ManagedAttribute(description = "Number of reloads failed")
     int getFailedCounter();
 
+    @ManagedOperation(description = "Reset counters")
+    void resetCounters();
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/b868b5f7/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedConsumer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedConsumer.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedConsumer.java
index 1506365..a940286 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedConsumer.java
@@ -34,11 +34,6 @@ public class ManagedConsumer extends ManagedService implements ManagedConsumerMB
         this.consumer = consumer;
     }
 
-    @Override
-    public void init(ManagementStrategy strategy) {
-        // noop
-    }
-
     public Consumer getConsumer() {
         return consumer;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/b868b5f7/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedReloadStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedReloadStrategy.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedReloadStrategy.java
index 9660a30..616ff5d 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedReloadStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedReloadStrategy.java
@@ -19,6 +19,7 @@ package org.apache.camel.management.mbean;
 import org.apache.camel.CamelContext;
 import org.apache.camel.api.management.ManagedResource;
 import org.apache.camel.api.management.mbean.ManagedReloadStrategyMBean;
+import org.apache.camel.spi.ManagementStrategy;
 import org.apache.camel.spi.ReloadStrategy;
 
 /**
@@ -26,13 +27,24 @@ import org.apache.camel.spi.ReloadStrategy;
  */
 @ManagedResource(description = "Managed ReloadStrategy")
 public class ManagedReloadStrategy extends ManagedService implements ManagedReloadStrategyMBean
{
+
+    private final CamelContext camelContext;
     private final ReloadStrategy reloadStrategy;
 
-    public ManagedReloadStrategy(CamelContext context, ReloadStrategy reloadStrategy) {
-        super(context, reloadStrategy);
+    public ManagedReloadStrategy(CamelContext camelContext, ReloadStrategy reloadStrategy)
{
+        super(camelContext, reloadStrategy);
+        this.camelContext = camelContext;
         this.reloadStrategy = reloadStrategy;
     }
 
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    public ReloadStrategy getReloadStrategy() {
+        return reloadStrategy;
+    }
+
     @Override
     public void forceReloadCamelContext() {
         reloadStrategy.onReloadCamelContext(getContext());
@@ -52,4 +64,9 @@ public class ManagedReloadStrategy extends ManagedService implements ManagedRelo
     public int getFailedCounter() {
         return reloadStrategy.getFailedCounter();
     }
+
+    @Override
+    public void resetCounters() {
+        reloadStrategy.resetCounters();
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b868b5f7/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedStreamCachingStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedStreamCachingStrategy.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedStreamCachingStrategy.java
index 284ac52..99d88e9 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedStreamCachingStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedStreamCachingStrategy.java
@@ -34,10 +34,6 @@ public class ManagedStreamCachingStrategy extends ManagedService implements
Mana
         this.streamCachingStrategy = streamCachingStrategy;
     }
 
-    public void init(ManagementStrategy strategy) {
-        // do nothing
-    }
-
     public CamelContext getCamelContext() {
         return camelContext;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/b868b5f7/camel-core/src/main/java/org/apache/camel/model/ModelHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ModelHelper.java b/camel-core/src/main/java/org/apache/camel/model/ModelHelper.java
index 3a41d1a..b681b38 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ModelHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ModelHelper.java
@@ -160,7 +160,9 @@ public final class ModelHelper {
         JAXBContext jaxbContext = getJAXBContext(context);
 
         Map<String, String> namespaces = new LinkedHashMap<>();
-        extractNamespaces(node.getOwnerDocument(), namespaces);
+
+        Document dom = node instanceof Document ? (Document) node : node.getOwnerDocument();
+        extractNamespaces(dom, namespaces);
 
         Binder<Node> binder = jaxbContext.createBinder();
         Object result = binder.unmarshal(node);

http://git-wip-us.apache.org/repos/asf/camel/blob/b868b5f7/camel-core/src/main/java/org/apache/camel/spi/ReloadStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/ReloadStrategy.java b/camel-core/src/main/java/org/apache/camel/spi/ReloadStrategy.java
index 3c74dac..0385301 100644
--- a/camel-core/src/main/java/org/apache/camel/spi/ReloadStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/spi/ReloadStrategy.java
@@ -55,4 +55,9 @@ public interface ReloadStrategy extends Service, StaticService, CamelContextAwar
      * Number of reloads failed.
      */
     int getFailedCounter();
+
+    /**
+     * Reset the counters.
+     */
+    void resetCounters();
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b868b5f7/camel-core/src/main/java/org/apache/camel/support/ReloadStrategySupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/support/ReloadStrategySupport.java
b/camel-core/src/main/java/org/apache/camel/support/ReloadStrategySupport.java
index aa775f5..a2b1ec0 100644
--- a/camel-core/src/main/java/org/apache/camel/support/ReloadStrategySupport.java
+++ b/camel-core/src/main/java/org/apache/camel/support/ReloadStrategySupport.java
@@ -111,4 +111,10 @@ public abstract class ReloadStrategySupport extends ServiceSupport implements
Re
     public int getFailedCounter() {
         return failed;
     }
+
+    @Override
+    public void resetCounters() {
+        succeeded = 0;
+        failed = 0;
+    }
 }


Mime
View raw message