camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r745790 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/view/ components/camel-web/src/main/java/org/apache/camel/web/resources/ components/camel-web/src/main/java/org/apache/camel/web/util/
Date Thu, 19 Feb 2009 09:38:52 GMT
Author: jstrachan
Date: Thu Feb 19 09:38:51 2009
New Revision: 745790

URL: http://svn.apache.org/viewvc?rev=745790&view=rev
Log:
added GraphViz DOT support for CAMEL-1355 so you can ask for /routes.dot or use Accept text/vnd.graphiz
on /routes

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/Constants.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RoutesResource.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java?rev=745790&r1=745789&r2=745790&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java
Thu Feb 19 09:38:51 2009
@@ -20,6 +20,7 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -69,6 +70,17 @@
         this.dir = dir;
     }
 
+    public String getRoutesText(CamelContext context) throws IOException {
+        List<RouteType> routes = context.getRouteDefinitions();
+        routeGroupMap = createRouteGroupMap(routes);
+
+        StringWriter buffer = new StringWriter();
+        PrintWriter writer = new PrintWriter(buffer);
+        generateFile(writer, routeGroupMap);
+        writer.close();
+        return buffer.toString();
+    }
+
     public void drawRoutes(CamelContext context) throws IOException {
         File parent = new File(dir);
         if (makeParentDirs) {

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/Constants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/Constants.java?rev=745790&r1=745789&r2=745790&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/Constants.java
(original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/Constants.java
Thu Feb 19 09:38:51 2009
@@ -24,4 +24,6 @@
     public static final String HTML_MIME_TYPES = "text/html;qs=5";
 
     public static final String DATA_MIME_TYPES = "text/xml,application/xml,application/json";
+
+    public static final String DOT_MIMETYPE = "text/vnd.graphviz";
 }

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=745790&r1=745789&r2=745790&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
Thu Feb 19 09:38:51 2009
@@ -18,6 +18,7 @@
 package org.apache.camel.web.resources;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.view.RouteDotGenerator;
 import org.apache.camel.model.RouteType;
 import org.apache.camel.model.RoutesType;
 
@@ -27,6 +28,7 @@
 import javax.ws.rs.PathParam;
 import javax.ws.rs.core.MediaType;
 import java.util.List;
+import java.io.IOException;
 
 /**
  * @version $Revision: 1.1 $
@@ -54,6 +56,13 @@
         return answer;
     }
 
+    @GET
+    @Produces(Constants.DOT_MIMETYPE)
+    public String getDot() throws IOException {
+        RouteDotGenerator generator = new RouteDotGenerator("/tmp/camel");
+        return generator.getRoutesText(getCamelContext());
+    }
+
     /**
       * Looks up an individual route
       */

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java?rev=745790&r1=745789&r2=745790&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java
(original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java
Thu Feb 19 09:38:51 2009
@@ -22,6 +22,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.camel.web.resources.Constants;
+
 /**
  * @version $Revision$
  */
@@ -35,6 +37,7 @@
         m.put("html", MediaType.TEXT_HTML_TYPE);
         m.put("xml", MediaType.APPLICATION_XML_TYPE);
         m.put("json", MediaType.APPLICATION_JSON_TYPE);
+        m.put("dot", MediaType.valueOf(Constants.DOT_MIMETYPE));
         return m;
     }
 }
\ No newline at end of file



Mime
View raw message