You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/05/19 07:39:52 UTC
svn commit: r946037 - in /camel/trunk/components/camel-web/src/main:
java/org/apache/camel/web/model/Route.java
java/org/apache/camel/web/resources/RoutesResource.java
webapp/org/apache/camel/web/resources/RoutesResource/index.jsp
Author: davsclaus
Date: Wed May 19 05:39:52 2010
New Revision: 946037
URL: http://svn.apache.org/viewvc?rev=946037&view=rev
Log:
Restorted the start/stop buttons for the routes.
Added:
camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/Route.java (with props)
Modified:
camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RoutesResource.java
camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/RoutesResource/index.jsp
Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/Route.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/Route.java?rev=946037&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/Route.java (added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/Route.java Wed May 19 05:39:52 2010
@@ -0,0 +1,60 @@
+/**
+ * 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.web.model;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.model.DescriptionDefinition;
+import org.apache.camel.model.RouteDefinition;
+
+/**
+ * Represents a route.
+ * <p/>
+ * We need this model to link the RouteDefinition with a CamelContext
+ */
+public class Route {
+ private CamelContext camelContext;
+ private RouteDefinition route;
+
+ public Route() {
+ }
+
+ public Route(CamelContext camelContext, RouteDefinition route) {
+ this.camelContext = camelContext;
+ this.route = route;
+ }
+
+ public String getId() {
+ return route.getId();
+ }
+
+ public DescriptionDefinition getDescription() {
+ return route.getDescription();
+ }
+
+ public ServiceStatus getStatus() {
+ return route.getStatus(camelContext);
+ }
+
+ public boolean isStartable() {
+ return route.isStartable(camelContext);
+ }
+
+ public boolean isStoppable() {
+ return route.isStoppable(camelContext);
+ }
+}
Propchange: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/Route.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/Route.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RoutesResource.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RoutesResource.java?rev=946037&r1=946036&r2=946037&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RoutesResource.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RoutesResource.java Wed May 19 05:39:52 2010
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -47,6 +48,7 @@ import org.apache.camel.model.RouteDefin
import org.apache.camel.model.RoutesDefinition;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.view.RouteDotGenerator;
+import org.apache.camel.web.model.Route;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -97,7 +99,7 @@ public class RoutesResource extends Came
*/
@Path("{id}")
public RouteResource getRoute(@PathParam("id") String id) {
- List<RouteDefinition> list = getRoutes();
+ List<RouteDefinition> list = getRouteDefinitions().getRoutes();
for (RouteDefinition routeType : list) {
if (routeType.getId().equals(id)) {
return new RouteResource(this, routeType);
@@ -148,15 +150,21 @@ public class RoutesResource extends Came
return parseGroovy(body);
}
- error = "Not supproted language!";
+ error = "Not supported language!";
return Response.ok(new Viewable("edit", this)).build();
}
// Properties
// -------------------------------------------------------------------------
- public List<RouteDefinition> getRoutes() {
- return getRouteDefinitions().getRoutes();
+
+ public List<Route> getRoutes() {
+ List<Route> answer = new ArrayList<Route>();
+ for (RouteDefinition def : getRouteDefinitions().getRoutes()) {
+ Route route = new Route(getCamelContext(), def);
+ answer.add(route);
+ }
+ return answer;
}
public String getError() {
Modified: camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/RoutesResource/index.jsp
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/RoutesResource/index.jsp?rev=946037&r1=946036&r2=946037&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/RoutesResource/index.jsp (original)
+++ camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/RoutesResource/index.jsp Wed May 19 05:39:52 2010
@@ -10,6 +10,7 @@
<table>
<tr>
<th>Route</th>
+ <th colspan="2">Status</th>
</tr>
<ul>
<c:forEach var="i" items="${it.routes}">
@@ -17,6 +18,21 @@
<td>
<a href='<c:url value="/routes/${i.id}"/>'>${i.id}</a> ${i.description.text}
</td>
+ <td class="${i.status}">
+ ${i.status}
+ </td>
+ <td>
+ <form action='<c:url value="/routes/${i.id}/status"/>' method="POST" name="setStatus">
+ <c:if test="${i.startable}">
+ <input type="hidden" name="status" value="start">
+ <input type="submit" value="Start">
+ </c:if>
+ <c:if test="${i.stoppable}">
+ <input type="hidden" name="status" value="stop">
+ <input type="submit" value="Stop">
+ </c:if>
+ </form>
+ </td>
</tr>
</c:forEach>
</ul>