Author: cschneider
Date: Mon Feb 18 16:42:58 2013
New Revision: 1447385

URL: http://svn.apache.org/r1447385
Log:
CAMEL-5968 Consolidate route commands using actract command, solve 
classnotfound exception with websphere jms

Added:
    
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/AbstractRouteCommand.java
      - copied unchanged from r1436431, 
camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/AbstractRouteCommand.java
Modified:
    
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteResume.java
    
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteStart.java
    
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteStop.java
    
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteSuspend.java

Modified: 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteResume.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteResume.java?rev=1447385&r1=1447384&r2=1447385&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteResume.java
 (original)
+++ 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteResume.java
 Mon Feb 18 16:42:58 2013
@@ -16,44 +16,20 @@
  */
 package org.apache.camel.karaf.commands;
 
-import java.util.List;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.Route;
-import org.apache.camel.karaf.commands.internal.RegexUtil;
-import org.apache.felix.gogo.commands.Argument;
 import org.apache.felix.gogo.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
 
 /**
  * Command to resume a route.
  */
 @Command(scope = "camel", name = "route-resume", description = "Resume a Camel 
route or a group of routes.")
-public class RouteResume extends OsgiCommandSupport {
-
-    @Argument(index = 0, name = "route", description = "The Camel route ID or 
a wildcard expression.", required = true, multiValued = false)
-    String route;
-
-    @Argument(index = 1, name = "context", description = "The Camel context 
name.", required = false, multiValued = false)
-    String context;
-
-    private CamelController camelController;
-
-    public void setCamelController(CamelController camelController) {
-        this.camelController = camelController;
-    }
+public class RouteResume extends AbstractRouteCommand {
 
-    public Object doExecute() throws Exception {
-        List<Route> camelRoutes = camelController.getRoutes(context, 
RegexUtil.wildcardAsRegex(route));
-        if (camelRoutes == null) {
-            System.err.println("Camel routes using  " + route + " not found.");
-            return null;
-        }
-        for (Route camelRoute : camelRoutes) {
-            CamelContext camelContext = 
camelRoute.getRouteContext().getCamelContext();
-            camelContext.resumeRoute(camelRoute.getId());
-        }
-        return null;
-    }
+       @Override
+       public void executeOnRoute(CamelContext camelContext, Route camelRoute)
+                       throws Exception {
+               camelContext.resumeRoute(camelRoute.getId());
+       }
 
 }

Modified: 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteStart.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteStart.java?rev=1447385&r1=1447384&r2=1447385&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteStart.java
 (original)
+++ 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteStart.java
 Mon Feb 18 16:42:58 2013
@@ -16,45 +16,19 @@
  */
 package org.apache.camel.karaf.commands;
 
-import java.util.List;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.Route;
-import org.apache.camel.karaf.commands.internal.RegexUtil;
-import org.apache.felix.gogo.commands.Argument;
 import org.apache.felix.gogo.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
 
 /**
  * Command to start a route.
  */
 @Command(scope = "camel", name = "route-start", description = "Start a Camel 
route or a group of routes")
-public class RouteStart extends OsgiCommandSupport {
-
-    @Argument(index = 0, name = "route", description = "The Camel route ID or 
a wildcard expression", required = true, multiValued = false)
-    String route;
-
-    @Argument(index = 1, name = "context", description = "The Camel context 
name.", required = false, multiValued = false)
-    String context;
-
-    private CamelController camelController;
-
-    public void setCamelController(CamelController camelController) {
-        this.camelController = camelController;
-    }
-
-    public Object doExecute() throws Exception {
-        List<Route> camelRoutes = camelController.getRoutes(context, 
RegexUtil.wildcardAsRegex(route));
-        if (camelRoutes == null || camelRoutes.isEmpty()) {
-            System.err.println("Camel routes using " + route + " not found.");
-            return null;
-        }
-        for (Route camelRoute : camelRoutes) {
-            CamelContext camelContext = 
camelRoute.getRouteContext().getCamelContext();
-            camelContext.startRoute(camelRoute.getId());
-        }
+public class RouteStart extends AbstractRouteCommand {
 
-        return null;
-    }
+       @Override
+       public void executeOnRoute(CamelContext camelContext, Route camelRoute) 
throws Exception {
+               camelContext.startRoute(camelRoute.getId());
+       }
 
 }

Modified: 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteStop.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteStop.java?rev=1447385&r1=1447384&r2=1447385&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteStop.java
 (original)
+++ 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteStop.java
 Mon Feb 18 16:42:58 2013
@@ -16,45 +16,19 @@
  */
 package org.apache.camel.karaf.commands;
 
-import java.util.List;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.Route;
-import org.apache.camel.karaf.commands.internal.RegexUtil;
-import org.apache.felix.gogo.commands.Argument;
 import org.apache.felix.gogo.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
 
 /**
  * Command to stop a route.
  */
 @Command(scope = "camel", name = " route-stop", description = "Stop a Camel 
route or a group of routes.")
-public class RouteStop extends OsgiCommandSupport {
-
-    @Argument(index = 0, name = "route", description = "The Camel route ID or 
a wildcard expression.", required = true, multiValued = false)
-    String route;
-
-    @Argument(index = 1, name = "context", description = "The Camel context 
name.", required = false, multiValued = false)
-    String context;
-
-    private CamelController camelController;
-
-    public void setCamelController(CamelController camelController) {
-        this.camelController = camelController;
-    }
-
-    public Object doExecute() throws Exception {
-        List<Route> camelRoutes = camelController.getRoutes(context, 
RegexUtil.wildcardAsRegex(route));
-        if (camelRoutes == null || camelRoutes.isEmpty()) {
-            System.err.println("Camel routes using " + route + " not found.");
-            return null;
-        }
-        for (Route camelRoute : camelRoutes) {
-            CamelContext camelContext = 
camelRoute.getRouteContext().getCamelContext();
-            camelContext.stopRoute(camelRoute.getId());
-        }
+public class RouteStop extends AbstractRouteCommand {
 
-        return null;
-    }
+       @Override
+       public void executeOnRoute(CamelContext camelContext, Route camelRoute) 
throws Exception {
+       camelContext.stopRoute(camelRoute.getId());
+       }
 
 }

Modified: 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteSuspend.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteSuspend.java?rev=1447385&r1=1447384&r2=1447385&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteSuspend.java
 (original)
+++ 
camel/branches/camel-2.10.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteSuspend.java
 Mon Feb 18 16:42:58 2013
@@ -16,45 +16,19 @@
  */
 package org.apache.camel.karaf.commands;
 
-import java.util.List;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.Route;
-import org.apache.camel.karaf.commands.internal.RegexUtil;
-import org.apache.felix.gogo.commands.Argument;
 import org.apache.felix.gogo.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
 
 /**
  * Command to suspend a route.
  */
 @Command(scope = "camel", name = " route-suspend", description = "Suspend a 
Camel route or a group of routes.")
-public class RouteSuspend extends OsgiCommandSupport {
-
-    @Argument(index = 0, name = "route", description = "The Camel route ID or 
a wildcard expression.", required = true, multiValued = false)
-    String route;
-
-    @Argument(index = 1, name = "context", description = "The Camel context 
name.", required = false, multiValued = false)
-    String context;
-
-    private CamelController camelController;
-
-    public void setCamelController(CamelController camelController) {
-        this.camelController = camelController;
-    }
-
-    public Object doExecute() throws Exception {
-        List<Route> camelRoutes = camelController.getRoutes(context, 
RegexUtil.wildcardAsRegex(route));
-        if (camelRoutes == null || camelRoutes.isEmpty()) {
-            System.err.println("Camel routes using " + route + " not found.");
-            return null;
-        }
-        for (Route camelRoute : camelRoutes) {
-            CamelContext camelContext = 
camelRoute.getRouteContext().getCamelContext();
-            camelContext.suspendRoute(camelRoute.getId());
-        }
+public class RouteSuspend extends AbstractRouteCommand {
 
-        return null;
-    }
+       @Override
+       public void executeOnRoute(CamelContext camelContext, Route camelRoute) 
throws Exception {
+               camelContext.suspendRoute(camelRoute.getId());
+       }
 
 }


Reply via email to