camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r831859 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/management/ camel-core/src/main/java/org/apache/camel/management/mbean/ camel-co...
Date Mon, 02 Nov 2009 10:58:30 GMT
Author: davsclaus
Date: Mon Nov  2 10:58:29 2009
New Revision: 831859

URL: http://svn.apache.org/viewvc?rev=831859&view=rev
Log:
CAMEL-1048: ThrottlingRoutePolicy is JMX managed.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrottlingRoutePolicy.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingRoutePolicy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedManagementStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutePolicyProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementNamingStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThrottlingRoutePolicyTest.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Mon Nov  2 10:58:29
2009
@@ -74,6 +74,14 @@
     void addService(Object object) throws Exception;
 
     /**
+     * Has the given service already been added?
+     *
+     * @param object the service
+     * @return <tt>true</tt> if already added, <tt>false</tt> if
not.
+     */
+    boolean hasService(Object object);
+
+    /**
      * Adds a component to the context.
      *
      * @param componentName  the name the component is registered as

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Mon
Nov  2 10:58:29 2009
@@ -628,6 +628,13 @@
         startServices(object);
     }
 
+    public boolean hasService(Object object) {
+        if (object instanceof Service) {
+            return servicesToClose.contains(object);
+        }
+        return false;
+    }
+
     // Helper methods
     // -----------------------------------------------------------------------
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java Mon
Nov  2 10:58:29 2009
@@ -37,6 +37,7 @@
 import org.apache.camel.spi.InterceptStrategy;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.spi.RoutePolicy;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * The context used to activate new routing rules
@@ -147,8 +148,17 @@
 
             // and then optionally add route policy processor if a custom policy is set
             RoutePolicyProcessor routePolicyProcessor = null;
-            if (getRoutePolicy() != null) {
-                routePolicyProcessor = new RoutePolicyProcessor(unitOfWorkProcessor, getRoutePolicy());
+            RoutePolicy policy = getRoutePolicy();
+            if (policy != null) {
+                routePolicyProcessor = new RoutePolicyProcessor(unitOfWorkProcessor, policy);
+                // add it as service if we have not already done that (eg possible if two
routes have the same service)
+                if (!camelContext.hasService(policy)) {
+                    try {
+                        camelContext.addService(policy);
+                    } catch (Exception e) {
+                        throw ObjectHelper.wrapRuntimeCamelException(e);
+                    }
+                }
                 target = routePolicyProcessor;
             }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingRoutePolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingRoutePolicy.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingRoutePolicy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingRoutePolicy.java
Mon Nov  2 10:58:29 2009
@@ -35,8 +35,6 @@
  */
 public class ThrottlingRoutePolicy extends RoutePolicySupport {
 
-    // TODO: need to be JMX enabled as well
-
     public enum ThrottlingScope {
         Context, Route
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
Mon Nov  2 10:58:29 2009
@@ -34,6 +34,7 @@
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.impl.EventDrivenConsumerRoute;
 import org.apache.camel.impl.ScheduledPollConsumer;
+import org.apache.camel.impl.ThrottlingRoutePolicy;
 import org.apache.camel.management.mbean.ManagedBrowsableEndpoint;
 import org.apache.camel.management.mbean.ManagedCamelContext;
 import org.apache.camel.management.mbean.ManagedComponent;
@@ -49,6 +50,7 @@
 import org.apache.camel.management.mbean.ManagedSendProcessor;
 import org.apache.camel.management.mbean.ManagedService;
 import org.apache.camel.management.mbean.ManagedThrottler;
+import org.apache.camel.management.mbean.ManagedThrottlingRoutePolicy;
 import org.apache.camel.management.mbean.ManagedTracer;
 import org.apache.camel.model.AOPDefinition;
 import org.apache.camel.model.InterceptDefinition;
@@ -286,6 +288,11 @@
         } else if (service instanceof Processor) {
             // special for processors
             return getManagedObjectForProcessor(context, (Processor) service, route);
+        } else if (service instanceof ThrottlingRoutePolicy) {
+            answer = new ManagedThrottlingRoutePolicy(context, (ThrottlingRoutePolicy) service);
+        } else if (service != null) {
+            // fallback as generic service
+            answer = new ManagedService(context, service);
         }
 
         if (answer != null) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementNamingStrategy.java
Mon Nov  2 10:58:29 2009
@@ -28,6 +28,7 @@
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.Route;
+import org.apache.camel.Service;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.builder.ErrorHandlerBuilderRef;
 import org.apache.camel.model.ProcessorDefinition;
@@ -53,6 +54,7 @@
     public static final String TYPE_COMPONENT = "components";
     public static final String TYPE_TRACER = "tracer";
     public static final String TYPE_ERRORHANDLER = "errorhandlers";
+    public static final String TYPE_SERVICE = "services";
 
     protected String domainName;
     protected String hostName = "localhost";
@@ -113,7 +115,7 @@
             // create a name based on its instance
             buffer.append(KEY_NAME + "=")
                 .append(processor.getClass().getSimpleName())
-                .append("(").append(getIdentityHashCode(processor)).append(")");
+                .append("(").append(ObjectHelper.getIdentityHashCode(processor)).append(")");
         }
         return createObjectName(buffer);
     }
@@ -154,7 +156,7 @@
             // create a name based on its instance
             buffer.append(KEY_NAME + "=")
                 .append(builder.getClass().getSimpleName())
-                .append("(").append(getIdentityHashCode(builder)).append(")");
+                .append("(").append(ObjectHelper.getIdentityHashCode(builder)).append(")");
         }
 
         return createObjectName(buffer);
@@ -172,7 +174,7 @@
         }
         buffer.append(KEY_NAME + "=")
             .append(name)
-            .append("(").append(getIdentityHashCode(consumer)).append(")");
+            .append("(").append(ObjectHelper.getIdentityHashCode(consumer)).append(")");
         return createObjectName(buffer);
     }
 
@@ -188,7 +190,7 @@
         }
         buffer.append(KEY_NAME + "=")
             .append(name)
-            .append("(").append(getIdentityHashCode(producer)).append(")");
+            .append("(").append(ObjectHelper.getIdentityHashCode(producer)).append(")");
         return createObjectName(buffer);
     }
 
@@ -199,7 +201,7 @@
         buffer.append(KEY_TYPE + "=" + TYPE_TRACER + ",");
         buffer.append(KEY_NAME + "=")
             .append("Tracer")
-            .append("(").append(getIdentityHashCode(tracer)).append(")");
+            .append("(").append(ObjectHelper.getIdentityHashCode(tracer)).append(")");
         return createObjectName(buffer);
     }
 
@@ -215,6 +217,17 @@
         return createObjectName(buffer);
     }
 
+    public ObjectName getObjectNameForService(CamelContext context, Service service) throws
MalformedObjectNameException {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(domainName).append(":");
+        buffer.append(KEY_CONTEXT + "=").append(getContextId(context)).append(",");
+        buffer.append(KEY_TYPE + "=" + TYPE_SERVICE + ",");
+        buffer.append(KEY_NAME + "=")
+            .append(service.getClass().getSimpleName())
+            .append("(").append(ObjectHelper.getIdentityHashCode(service)).append(")");
+        return createObjectName(buffer);
+    }
+
     public String getDomainName() {
         return domainName;
     }
@@ -243,15 +256,11 @@
             String uri = ep.getEndpointKey();
             int pos = uri.indexOf('?');
             String id = (pos == -1) ? uri : uri.substring(0, pos);
-            id += "?id=" + getIdentityHashCode(ep);
+            id += "?id=" + ObjectHelper.getIdentityHashCode(ep);
             return id;
         }
     }
 
-    private static String getIdentityHashCode(Object object) {
-        return "0x" + Integer.toHexString(System.identityHashCode(object));
-    }
-
     /**
      * Factory method to create an ObjectName escaping any required characters
      */

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedManagementStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedManagementStrategy.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedManagementStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedManagementStrategy.java
Mon Nov  2 10:58:29 2009
@@ -27,6 +27,7 @@
 import org.apache.camel.management.mbean.ManagedProcessor;
 import org.apache.camel.management.mbean.ManagedProducer;
 import org.apache.camel.management.mbean.ManagedRoute;
+import org.apache.camel.management.mbean.ManagedService;
 import org.apache.camel.management.mbean.ManagedTracer;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.ManagementAgent;
@@ -79,48 +80,36 @@
         if (managedObject instanceof ManagedCamelContext) {
             ManagedCamelContext mcc = (ManagedCamelContext) managedObject;
             objectName = getManagementNamingStrategy().getObjectNameForCamelContext(mcc.getContext());
-        }
-
-        if (managedObject instanceof ManagedComponent) {
+        } else if (managedObject instanceof ManagedComponent) {
             ManagedComponent mc = (ManagedComponent) managedObject;
             objectName = getManagementNamingStrategy().getObjectNameForComponent(mc.getComponent(),
mc.getComponentName());
-        }
-
-        if (managedObject instanceof ManagedEndpoint) {
+        } else if (managedObject instanceof ManagedEndpoint) {
             ManagedEndpoint me = (ManagedEndpoint) managedObject;
             objectName = getManagementNamingStrategy().getObjectNameForEndpoint(me.getEndpoint());
         } else if (managedObject instanceof Endpoint) {
             objectName = getManagementNamingStrategy().getObjectNameForEndpoint((Endpoint)
managedObject);
-        }
-
-        if (managedObject instanceof ManagedRoute) {
+        } else if (managedObject instanceof ManagedRoute) {
             ManagedRoute mr = (ManagedRoute) managedObject;
             objectName = getManagementNamingStrategy().getObjectNameForRoute(mr.getRoute());
-        }
-
-        if (managedObject instanceof ManagedErrorHandler) {
+        } else if (managedObject instanceof ManagedErrorHandler) {
             ManagedErrorHandler meh = (ManagedErrorHandler) managedObject;
             objectName = getManagementNamingStrategy().getObjectNameForErrorHandler(meh.getRouteContext(),
meh.getErrorHandler(), meh.getErrorHandlerBuilder());
-        }
-
-        if (managedObject instanceof ManagedProcessor) {
+        } else if (managedObject instanceof ManagedProcessor) {
             ManagedProcessor mp = (ManagedProcessor) managedObject;
             objectName = getManagementNamingStrategy().getObjectNameForProcessor(mp.getContext(),
mp.getProcessor(), mp.getDefinition());
-        }
-
-        if (managedObject instanceof ManagedConsumer) {
+        } else if (managedObject instanceof ManagedConsumer) {
             ManagedConsumer ms = (ManagedConsumer) managedObject;
             objectName = getManagementNamingStrategy().getObjectNameForConsumer(ms.getContext(),
ms.getConsumer());
-        }
-
-        if (managedObject instanceof ManagedProducer) {
+        } else if (managedObject instanceof ManagedProducer) {
             ManagedProducer ms = (ManagedProducer) managedObject;
             objectName = getManagementNamingStrategy().getObjectNameForProducer(ms.getContext(),
ms.getProducer());
-        }
-
-        if (managedObject instanceof ManagedTracer) {
+        } else if (managedObject instanceof ManagedTracer) {
             ManagedTracer mt = (ManagedTracer) managedObject;
             objectName = getManagementNamingStrategy().getObjectNameForTracer(mt.getCamelContext(),
mt.getTracer());
+        } else if (managedObject instanceof ManagedService) {
+            // check for managed service should be last
+            ManagedService ms = (ManagedService) managedObject;
+            objectName = getManagementNamingStrategy().getObjectNameForService(ms.getContext(),
ms.getService());
         }
 
         return nameType.cast(objectName);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
Mon Nov  2 10:58:29 2009
@@ -21,6 +21,8 @@
 import org.apache.camel.ManagementStatisticsLevel;
 import org.apache.camel.Route;
 import org.apache.camel.ServiceStatus;
+import org.apache.camel.spi.RoutePolicy;
+import org.apache.camel.util.ObjectHelper;
 import org.springframework.jmx.export.annotation.ManagedAttribute;
 import org.springframework.jmx.export.annotation.ManagedOperation;
 import org.springframework.jmx.export.annotation.ManagedResource;
@@ -104,6 +106,18 @@
         route.getRouteContext().setTracing(tracing);
     }
 
+    @ManagedAttribute(description = "Route Policy")
+    public String getRoutePolicy() {
+        RoutePolicy policy = route.getRouteContext().getRoutePolicy();
+        if (policy != null) {
+            StringBuilder sb = new StringBuilder();
+            sb.append(policy.getClass().getSimpleName());
+            sb.append("(").append(ObjectHelper.getIdentityHashCode(policy)).append(")");
+            return sb.toString();
+        }
+        return null;
+    }
+
     @ManagedOperation(description = "Start Route")
     public void start() throws Exception {
         context.startRoute(getRouteId());

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrottlingRoutePolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrottlingRoutePolicy.java?rev=831859&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrottlingRoutePolicy.java
(added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrottlingRoutePolicy.java
Mon Nov  2 10:58:29 2009
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.management.mbean;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.impl.ThrottlingRoutePolicy;
+import org.springframework.jmx.export.annotation.ManagedAttribute;
+import org.springframework.jmx.export.annotation.ManagedResource;
+
+/**
+ * @version $Revision$
+ */
+@ManagedResource(description = "Managed ThrottlingRoutePolicy")
+public class ManagedThrottlingRoutePolicy extends ManagedService {
+
+    private final ThrottlingRoutePolicy policy;
+
+    public ManagedThrottlingRoutePolicy(CamelContext context, ThrottlingRoutePolicy policy)
{
+        super(context, policy);
+        this.policy = policy;
+    }
+
+    public ThrottlingRoutePolicy getPolicy() {
+        return policy;
+    }
+
+    @ManagedAttribute(description = "Maximum inflight exchanges")
+    public int getMaxInflightExchanges() {
+        return getPolicy().getMaxInflightExchanges();
+    }
+
+    @ManagedAttribute(description = "Maximum inflight exchanges")
+    public void setMaxInflightExchanges(int maxInflightExchanges) {
+        getPolicy().setMaxInflightExchanges(maxInflightExchanges);
+    }
+
+    @ManagedAttribute(description = "Resume percentage of maximum inflight exchanges")
+    public int getResumePercentOfMax() {
+        return getPolicy().getResumePercentOfMax();
+    }
+
+    @ManagedAttribute(description = "Resume percentage of maximum inflight exchanges")
+    public void setResumePercentOfMax(int resumePercentOfMax) {
+        getPolicy().setResumePercentOfMax(resumePercentOfMax);
+    }
+
+    @ManagedAttribute(description = "Scope")
+    public String getScope() {
+        return getPolicy().getScope().name();
+    }
+
+    @ManagedAttribute(description = "Scope")
+    public void setScope(String scope) {
+        getPolicy().setScope(ThrottlingRoutePolicy.ThrottlingScope.valueOf(scope));
+    }
+
+    @ManagedAttribute(description = "Logging Level")
+    public String getLoggingLevel() {
+        return getPolicy().getLoggingLevel().name();
+    }
+
+    @ManagedAttribute(description = "Logging Level")
+    public void setLoggingLevel(String loggingLevel) {
+        LoggingLevel level = LoggingLevel.valueOf(loggingLevel);
+        getPolicy().setLoggingLevel(level);
+        getPolicy().getLogger().setLevel(level);
+    }
+
+}

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrottlingRoutePolicy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThrottlingRoutePolicy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutePolicyProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutePolicyProcessor.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutePolicyProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutePolicyProcessor.java
Mon Nov  2 10:58:29 2009
@@ -44,23 +44,27 @@
 
     @Override
     protected void processNext(Exchange exchange) throws Exception {
-        // invoke begin
-        routePolicy.onExchangeBegin(route, exchange);
+        // check whether the policy is enabled
+        if (isRoutePolicyRunAllowed()) {
 
-        // add on completion that invokes the policy callback on complete
-        // as the Exchange can be routed async and thus we need the callback to
-        // invoke when the route is completed
-        exchange.addOnCompletion(new SynchronizationAdapter() {
-            @Override
-            public void onDone(Exchange exchange) {
-                // do not invoke it if Camel is stopping as we don't want
-                // the policy to start a consumer during Camel is stopping
-                if (isCamelStopping(exchange.getContext())) {
-                    return;
+            // invoke begin
+            routePolicy.onExchangeBegin(route, exchange);
+
+            // add on completion that invokes the policy callback on complete
+            // as the Exchange can be routed async and thus we need the callback to
+            // invoke when the route is completed
+            exchange.addOnCompletion(new SynchronizationAdapter() {
+                @Override
+                public void onDone(Exchange exchange) {
+                    // do not invoke it if Camel is stopping as we don't want
+                    // the policy to start a consumer during Camel is stopping
+                    if (isCamelStopping(exchange.getContext())) {
+                        return;
+                    }
+                    routePolicy.onExchangeDone(route, exchange);
                 }
-                routePolicy.onExchangeDone(route, exchange);
-            }
-        });
+            });
+        }
 
         if (processor != null) {
             processor.process(exchange);
@@ -79,4 +83,12 @@
         return false;
     }
 
+    private boolean isRoutePolicyRunAllowed() {
+        if (routePolicy instanceof ServiceSupport) {
+            ServiceSupport ss = (ServiceSupport) routePolicy;
+            return ss.isRunAllowed();
+        }
+        return true;
+    }
+
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementNamingStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementNamingStrategy.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementNamingStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementNamingStrategy.java
Mon Nov  2 10:58:29 2009
@@ -26,6 +26,7 @@
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.Route;
+import org.apache.camel.Service;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.model.ProcessorDefinition;
 
@@ -54,4 +55,6 @@
 
     ObjectName getObjectNameForTracer(CamelContext context, InterceptStrategy tracer) throws
MalformedObjectNameException;
 
+    ObjectName getObjectNameForService(CamelContext context, Service service) throws MalformedObjectNameException;
+
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Mon Nov 
2 10:58:29 2009
@@ -1133,6 +1133,10 @@
         return scanner;
     }
 
+    public static String getIdentityHashCode(Object object) {
+        return "0x" + Integer.toHexString(System.identityHashCode(object));
+    }
+
     private static class ExceptionIterator implements Iterator<Throwable> {
         private List<Throwable> tree = new ArrayList<Throwable>();
         private Iterator<Throwable> it;

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThrottlingRoutePolicyTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThrottlingRoutePolicyTest.xml?rev=831859&r1=831858&r2=831859&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThrottlingRoutePolicyTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThrottlingRoutePolicyTest.xml
Mon Nov  2 10:58:29 2009
@@ -30,7 +30,7 @@
         <!-- and we want a low water mark value of 20% of the max which means that
              the route will be resumed when hitting low to <= 2 current inflight exchanges
-->
         <property name="resumePercentOfMax" value="20"/>
-        <!-- and we want it to be scoped at this route: (can also be total scoped)
+        <!-- and we want it to be scoped at this route: (can also be context scoped)
              its default route scoped so we could omit this property -->
         <property name="scope" value="Route"/>
     </bean>



Mime
View raw message