You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/09/07 15:29:41 UTC
svn commit: r573575 - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/builder/
camel-core/src/main/java/org/apache/camel/model/
camel-core/src/main/java/org/apache/camel/view/
camel-core/src/test/java/org/apache/camel/view/ componen...
Author: jstrachan
Date: Fri Sep 7 06:29:39 2007
New Revision: 573575
URL: http://svn.apache.org/viewvc?rev=573575&view=rev
Log:
improvements in the Visualisation plugin to render pipeline/multicast nicely along with grouping RouteBuilder instances into boxes & separate diagrams for CAMEL-137
Added:
activemq/camel/trunk/components/camel-ibatis/
activemq/camel/trunk/components/camel-ibatis/pom.xml (with props)
activemq/camel/trunk/examples/camel-example-docs/
activemq/camel/trunk/examples/camel-example-docs/README.txt
- copied, changed from r572881, activemq/camel/trunk/examples/camel-example-etl/README.txt
activemq/camel/trunk/examples/camel-example-docs/pom.xml
- copied, changed from r572881, activemq/camel/trunk/examples/camel-example-etl/pom.xml
activemq/camel/trunk/examples/camel-example-docs/src/
activemq/camel/trunk/examples/camel-example-docs/src/main/
activemq/camel/trunk/examples/camel-example-docs/src/main/java/
activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/
activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/
activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/
activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/
activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/
activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/ContentBasedRouteRoute.java (with props)
activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/MulticastRoute.java (with props)
activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/PipelineRoute.java (with props)
activemq/camel/trunk/examples/camel-example-docs/src/main/resources/
activemq/camel/trunk/examples/camel-example-docs/src/main/resources/META-INF/
activemq/camel/trunk/examples/camel-example-docs/src/main/resources/META-INF/LICENSE.txt
- copied unchanged from r572881, activemq/camel/trunk/examples/camel-example-etl/src/main/resources/META-INF/LICENSE.txt
activemq/camel/trunk/examples/camel-example-docs/src/main/resources/META-INF/NOTICE.txt
- copied unchanged from r572881, activemq/camel/trunk/examples/camel-example-etl/src/main/resources/META-INF/NOTICE.txt
activemq/camel/trunk/examples/camel-example-docs/src/main/resources/META-INF/spring/
activemq/camel/trunk/examples/camel-example-docs/src/main/resources/META-INF/spring/camel-context.xml (with props)
activemq/camel/trunk/examples/camel-example-docs/src/main/resources/log4j.properties
- copied unchanged from r572881, activemq/camel/trunk/examples/camel-example-etl/src/main/resources/log4j.properties
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/RouteDotGenerator.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/view/DotViewTest.java
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
activemq/camel/trunk/components/pom.xml
activemq/camel/trunk/examples/pom.xml
activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java
activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/EmbeddedMojo.java
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java?rev=573575&r1=573574&r2=573575&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java Fri Sep 7 06:29:39 2007
@@ -63,14 +63,18 @@
* Creates a new route from the given URI input
*/
public RouteType from(String uri) {
- return routeCollection.from(uri);
+ RouteType answer = routeCollection.from(uri);
+ configureRoute(answer);
+ return answer;
}
/**
* Creates a new route from the given endpoint
*/
public RouteType from(Endpoint endpoint) {
- return routeCollection.from(endpoint);
+ RouteType answer = routeCollection.from(endpoint);
+ configureRoute(answer);
+ return answer;
}
/**
@@ -165,7 +169,6 @@
throw new IllegalArgumentException("No CamelContext has been injected!");
}
routeCollection.setCamelContext(camelContext);
- //routeCollection.populateRoutes(routes);
camelContext.addRouteDefinitions(routeCollection.getRoutes());
}
@@ -174,5 +177,9 @@
*/
protected CamelContext createContainer() {
return new DefaultCamelContext();
+ }
+
+ protected void configureRoute(RouteType route) {
+ route.setGroup(getClass().getName());
}
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java?rev=573575&r1=573574&r2=573575&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java Fri Sep 7 06:29:39 2007
@@ -22,7 +22,7 @@
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
@@ -54,6 +54,8 @@
private List<FromType> inputs = new ArrayList<FromType>();
@XmlElementRef
private List<ProcessorType> outputs = new ArrayList<ProcessorType>();
+ @XmlAttribute
+ private String group;
@XmlTransient
private CamelContext camelContext;
@@ -148,6 +150,20 @@
public void setCamelContext(CamelContext camelContext) {
this.camelContext = camelContext;
+ }
+
+ /**
+ * The group that this route belongs to; could be the name of the RouteBuilder class
+ * or be explicitly configured in the XML.
+ *
+ * May be null.
+ */
+ public String getGroup() {
+ return group;
+ }
+
+ public void setGroup(String group) {
+ this.group = group;
}
// Implementation methods
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/RouteDotGenerator.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/RouteDotGenerator.java?rev=573575&r1=573574&r2=573575&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/RouteDotGenerator.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/RouteDotGenerator.java Fri Sep 7 06:29:39 2007
@@ -16,6 +16,16 @@
*/
package org.apache.camel.view;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.camel.CamelContext;
import org.apache.camel.model.*;
import org.apache.camel.model.language.ExpressionType;
@@ -25,15 +35,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ArrayList;
-
/**
* A <a href="http://www.graphviz.org/">DOT</a> file creator plugin which
* creates a DOT file showing the current routes
@@ -42,10 +43,12 @@
*/
public class RouteDotGenerator {
private static final transient Log LOG = LogFactory.getLog(RouteDotGenerator.class);
- private String file;
+ private String dir;
private String imagePrefix = "http://www.enterpriseintegrationpatterns.com/img/";
private Map<Object, NodeData> nodeMap = new HashMap<Object, NodeData>();
private boolean makeParentDirs = true;
+ private int clusterCounter;
+ private Map<String, List<RouteType>> routeGroupMap;
/**
* lets insert a space before each upper case letter after a lowercase
@@ -76,29 +79,53 @@
this("CamelRoutes.dot");
}
- public RouteDotGenerator(String file) {
- this.file = file;
+ public RouteDotGenerator(String dir) {
+ this.dir = dir;
}
- public String getFile() {
- return file;
+ public String getDir() {
+ return dir;
}
/**
- * Sets the destination file name to create the destination diagram
+ * Sets the destination directory in which to create the diagrams
*/
- public void setFile(String file) {
- this.file = file;
+ public void setDir(String dir) {
+ this.dir = dir;
}
public void drawRoutes(CamelContext context) throws IOException {
- File fileValue = new File(file);
+ File parent = new File(dir);
if (makeParentDirs) {
- fileValue.getParentFile().mkdirs();
+ parent.mkdirs();
}
- PrintWriter writer = new PrintWriter(new FileWriter(fileValue));
+ List<RouteType> routes = context.getRouteDefinitions();
+ routeGroupMap = createRouteGroupMap(routes);
+
+ // generate the global file
+ generateFile(parent, "routes.dot", routeGroupMap);
+
+ if (routeGroupMap.size() >= 1) {
+ Set<Map.Entry<String, List<RouteType>>> entries = routeGroupMap.entrySet();
+ for (Map.Entry<String, List<RouteType>> entry : entries) {
+
+ Map<String, List<RouteType>> map = new HashMap<String, List<RouteType>>();
+ String group = entry.getKey();
+ map.put(group, entry.getValue());
+
+ // generate the file containing just the routes in this group
+ generateFile(parent, group + ".dot", map);
+ }
+ }
+ }
+
+ private void generateFile(File parent, String fileName, Map<String, List<RouteType>> map) throws IOException {
+ nodeMap.clear();
+ clusterCounter = 0;
+
+ PrintWriter writer = new PrintWriter(new FileWriter(new File(parent, fileName)));
try {
- generateFile(writer, context);
+ generateFile(writer, map);
}
finally {
writer.close();
@@ -121,19 +148,36 @@
public List<ProcessorType> outputs;
}
- protected void generateFile(PrintWriter writer, CamelContext context) {
- writer.println("digraph \"CamelRoutes\" {");
+ protected void generateFile(PrintWriter writer, Map<String, List<RouteType>> map) {
+ writer.println("digraph CamelRoutes {");
writer.println();
writer.println("node [style = \"rounded,filled\", fillcolor = yellow, "
+ "fontname=\"Helvetica-Oblique\"];");
writer.println();
- printRoutes(writer, context.getRouteDefinitions());
+ printRoutes(writer, map);
writer.println("}");
}
- protected void printRoutes(PrintWriter writer, List<RouteType> routes) {
+ protected void printRoutes(PrintWriter writer, Map<String, List<RouteType>> map) {
+
+ Set<Map.Entry<String, List<RouteType>>> entries = map.entrySet();
+ for (Map.Entry<String, List<RouteType>> entry : entries) {
+ String group = entry.getKey();
+ printRoutes(writer, group, entry.getValue());
+ }
+ }
+
+ protected void printRoutes(PrintWriter writer, String group, List<RouteType> routes) {
+ if (group != null) {
+ writer.println("subgraph cluster_" + (clusterCounter++) + " {");
+ writer.println("label = \"" + group + "\";");
+ writer.println("color = grey;");
+ writer.println("style = \"dashed\";");
+ writer.println("URL = \"" + group + ".html\";");
+ writer.println();
+ }
for (RouteType route : routes) {
List<FromType> inputs = route.getInputs();
for (FromType input : inputs) {
@@ -141,6 +185,14 @@
}
writer.println();
}
+ if (group != null) {
+ writer.println("}");
+ writer.println();
+ }
+ }
+
+ protected String escapeNodeId(String text) {
+ return text.replace('.', '_').replace("$", "_");
}
protected void printRoute(PrintWriter writer, final RouteType route, FromType input) {
@@ -151,12 +203,22 @@
// TODO we should add a transactional client / event driven consumer / polling client
List<ProcessorType> outputs = route.getOutputs();
+ NodeData from = nodeData;
for (ProcessorType output : outputs) {
- printNode(writer, nodeData, output);
+ NodeData newData = printNode(writer, from, output);
+ from = newData;
}
}
protected NodeData printNode(PrintWriter writer, NodeData fromData, ProcessorType node) {
+ if (node instanceof MulticastType) {
+ // no need for a multicast node
+ List<ProcessorType> outputs = node.getOutputs();
+ for (ProcessorType output : outputs) {
+ printNode(writer, fromData, output);
+ }
+ return fromData;
+ }
NodeData toData = getNodeData(node);
printNode(writer, toData);
@@ -245,10 +307,13 @@
else if (node instanceof WhenType) {
data.image = imagePrefix + "MessageFilterIcon.gif";
data.nodeType = "When Filter";
+ data.url = "http://activemq.apache.org/camel/content-based-router.html";
}
else if (node instanceof OtherwiseType) {
data.nodeType = "Otherwise";
data.edgeLabel = "";
+ data.url = "http://activemq.apache.org/camel/content-based-router.html";
+ data.tooltop = "Otherwise";
}
else if (node instanceof ChoiceType) {
data.image = imagePrefix + "ContentBasedRouterIcon.gif";
@@ -364,5 +429,24 @@
nodeMap.put(key, answer);
}
return answer;
+ }
+
+
+
+ protected Map<String, List<RouteType>> createRouteGroupMap(List<RouteType> routes) {
+ Map<String, List<RouteType>> map = new HashMap<String, List<RouteType>>();
+ for (RouteType route : routes) {
+ String group = route.getGroup();
+ if (group == null) {
+ group = "Camel Routes";
+ }
+ List<RouteType> list = map.get(group);
+ if (list == null) {
+ list = new ArrayList<RouteType>();
+ map.put(group, list);
+ }
+ list.add(route);
+ }
+ return map;
}
}
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/view/DotViewTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/view/DotViewTest.java?rev=573575&r1=573574&r2=573575&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/view/DotViewTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/view/DotViewTest.java Fri Sep 7 06:29:39 2007
@@ -18,10 +18,8 @@
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.XPathBuilder;
import java.io.File;
-import static org.apache.camel.builder.xml.XPathBuilder.xpath;
/**
* @version $Revision: 1.1 $
@@ -32,17 +30,40 @@
public void testDotFile() throws Exception {
new File("target").mkdirs();
- generator.setFile("target/Example.dot");
+ generator.setDir("target/site/cameldoc");
generator.drawRoutes(context);
}
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ context.addRoutes(new MulticastRoute());
+ context.addRoutes(new PipelineRoute());
+ }
+
+ static class MulticastRoute extends RouteBuilder {
+ public void configure() throws Exception {
+ from("seda:multicast.in").
+ multicast().to("seda:multicast.out1", "seda:multicast.out2", "seda:multicast.out3");
+ }
+ }
+ static class PipelineRoute extends RouteBuilder {
+ public void configure() throws Exception {
+ from("seda:pipeline.in").
+ to("seda:pipeline.out1", "seda:pipeline.out2", "seda:pipeline.out3");
+ }
+ }
+
+/*
from("file:foo/xyz?noop=true").
choice().
when(xpath("/person/city = 'London'")).to("file:target/messages/uk").
otherwise().to("file:target/messages/others");
+*/
+
+/*
+
from("file:foo/bar?noop=true").
filter(header("foo").isEqualTo("bar")).
@@ -54,8 +75,6 @@
splitter(XPathBuilder.xpath("/invoice/lineItems")).
throttler(3).
to("mock:result");
- }
- };
- }
+*/
}
Added: activemq/camel/trunk/components/camel-ibatis/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ibatis/pom.xml?rev=573575&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-ibatis/pom.xml (added)
+++ activemq/camel/trunk/components/camel-ibatis/pom.xml Fri Sep 7 06:29:39 2007
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-ibatis</artifactId>
+ <name>Camel :: iBatis</name>
+ <description>Camel iBatis support</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ibatis</groupId>
+ <artifactId>ibatis-sqlmap</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
+
+
Propchange: activemq/camel/trunk/components/camel-ibatis/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java?rev=573575&r1=573574&r2=573575&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java Fri Sep 7 06:29:39 2007
@@ -48,7 +48,7 @@
private AtomicBoolean completed = new AtomicBoolean(false);
private long duration = -1;
private TimeUnit timeUnit = TimeUnit.MILLISECONDS;
- private String dotFileName;
+ private String dotOutputDir;
public Main() {
addOption(new Option("h", "help", "Displays the help screen") {
@@ -63,9 +63,9 @@
setApplicationContextUri(parameter);
}
});
- addOption(new ParameterOption("f", "file", "Sets the DOT file name which is generated to show a visual representation of the routes", "dot") {
+ addOption(new ParameterOption("o", "outdir", "Sets the DOT output directory where the visual representations of the routes are generated", "dot") {
protected void doProcess(String arg, String parameter, LinkedList<String> remainingArgs) {
- setDotFileName(parameter);
+ setDotOutputDir(parameter);
}
});
addOption(new ParameterOption("d", "duration", "Sets the time duration that the applicaiton will run for, by default in milliseconds. You can use '10s' for 10 seconds etc", "duration") {
@@ -264,16 +264,17 @@
this.timeUnit = timeUnit;
}
- public String getDotFileName() {
- return dotFileName;
+ public String getDotOutputDir() {
+ return dotOutputDir;
}
/**
- * Sets the file name of the DOT file generated to show the visual representation of the routes.
+ * Sets the output directory of the generated DOT Files
+ * to show the visual representation of the routes.
* A null value disables the dot file generation
*/
- public void setDotFileName(String dotFileName) {
- this.dotFileName = dotFileName;
+ public void setDotOutputDir(String dotOutputDir) {
+ this.dotOutputDir = dotOutputDir;
}
// Implementation methods
@@ -319,10 +320,10 @@
}
protected void postProcessContext() throws Exception {
- if (ObjectHelper.isNotNullAndNonEmpty(dotFileName)) {
- RouteDotGenerator generator = new RouteDotGenerator(dotFileName);
+ if (ObjectHelper.isNotNullAndNonEmpty(dotOutputDir)) {
+ RouteDotGenerator generator = new RouteDotGenerator(dotOutputDir);
CamelContext camelContext = SpringCamelContext.springCamelContext(applicationContext);
- LOG.info("Generating DOT file for routes: " + dotFileName + " for: " + camelContext);
+ LOG.info("Generating DOT file for routes: " + dotOutputDir + " for: " + camelContext);
generator.drawRoutes(camelContext);
}
}
Modified: activemq/camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/pom.xml?rev=573575&r1=573574&r2=573575&view=diff
==============================================================================
--- activemq/camel/trunk/components/pom.xml (original)
+++ activemq/camel/trunk/components/pom.xml Fri Sep 7 06:29:39 2007
@@ -41,6 +41,7 @@
<module>camel-ftp</module>
<module>camel-juel</module>
<module>camel-http</module>
+ <module>camel-ibatis</module>
<module>camel-irc</module>
<module>camel-jaxb</module>
<module>camel-jdbc</module>
Copied: activemq/camel/trunk/examples/camel-example-docs/README.txt (from r572881, activemq/camel/trunk/examples/camel-example-etl/README.txt)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-docs/README.txt?p2=activemq/camel/trunk/examples/camel-example-docs/README.txt&p1=activemq/camel/trunk/examples/camel-example-etl/README.txt&r1=572881&r2=573575&rev=573575&view=diff
==============================================================================
--- activemq/camel/trunk/examples/camel-example-etl/README.txt (original)
+++ activemq/camel/trunk/examples/camel-example-docs/README.txt Fri Sep 7 06:29:39 2007
@@ -1,14 +1,18 @@
-Extract Transform Load (ETL) Example
-====================================
+Documentation Example
+=====================
-This example shows how to use Camel as an ETL tool
- http://activemq.apache.org/camel/etl.html
+This example creates a bunch of routes to show how
+the Maven reporting tools can visualise routes
+ http://activemq.apache.org/camel/docs-example.html
-For a full description of this example please see
- http://activemq.apache.org/camel/etl-example.html
+This example also acts as an integration test case for the Visualisation
+ http://activemq.apache.org/camel/visualisation.html
-To run the example type
- mvn camel:run
+To generate the documentation type
+ mvn camel:dot
+
+The reports should be generated in
+ target/site/cameldoc/index.html
You can see the routing rules by looking at the java code in the src/main/java directory
and the Spring XML configuration lives in src/main/resources/META-INF/spring
Copied: activemq/camel/trunk/examples/camel-example-docs/pom.xml (from r572881, activemq/camel/trunk/examples/camel-example-etl/pom.xml)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-docs/pom.xml?p2=activemq/camel/trunk/examples/camel-example-docs/pom.xml&p1=activemq/camel/trunk/examples/camel-example-etl/pom.xml&r1=572881&r2=573575&rev=573575&view=diff
==============================================================================
--- activemq/camel/trunk/examples/camel-example-etl/pom.xml (original)
+++ activemq/camel/trunk/examples/camel-example-docs/pom.xml Fri Sep 7 06:29:39 2007
@@ -28,27 +28,16 @@
<version>1.1-SNAPSHOT</version>
</parent>
- <artifactId>camel-example-etl</artifactId>
- <name>Camel :: Example :: ETL</name>
- <description>An example showing how to use Camel as an Extract Transform and Load tool</description>
+ <artifactId>camel-example-docs</artifactId>
+ <name>Camel :: Example :: Docs</name>
+ <description>An example which demonstrates the use of the Maven camel:dot plugin for generating EIP documentation
+ </description>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jpa</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jaxb</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-juel</artifactId>
- </dependency>
<!-- lets use log4j -->
<dependency>
@@ -59,43 +48,9 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
-
- <!-- lets use hibernate by default -->
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate</artifactId>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jta_1.0.1B_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <version>1.2.1</version>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2</version>
- </dependency>
-
- <!-- testing -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
+
<build>
<plugins>
@@ -103,27 +58,6 @@
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
- </plugin>
-
- <!-- allows the example to be ran via 'mvn compile exec:java' -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <configuration>
- <mainClass>org.apache.camel.example.etl.Main</mainClass>
- <includePluginDependencies>false</includePluginDependencies>
- </configuration>
- </plugin>
-
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <childDelegation>false</childDelegation>
- <useFile>true</useFile>
- <excludes>
- <exclude>**/RunTest.*</exclude>
- </excludes>
- </configuration>
</plugin>
</plugins>
Added: activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/ContentBasedRouteRoute.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/ContentBasedRouteRoute.java?rev=573575&view=auto
==============================================================================
--- activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/ContentBasedRouteRoute.java (added)
+++ activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/ContentBasedRouteRoute.java Fri Sep 7 06:29:39 2007
@@ -0,0 +1,35 @@
+/**
+ *
+ * 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.example.docs;
+
+import org.apache.camel.builder.RouteBuilder;
+import static org.apache.camel.builder.xml.XPathBuilder.xpath;
+
+/**
+ * A simple content based router example
+ *
+ * @version $Revision: 1.1 $
+ */
+public class ContentBasedRouteRoute extends RouteBuilder {
+ public void configure() throws Exception {
+ from("seda:cbr.input").
+ choice().
+ when(xpath("/person/city = 'London'")).to("seda:cbr.output.a").
+ otherwise().to("seda:cbr.output.b");
+ }
+}
\ No newline at end of file
Propchange: activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/ContentBasedRouteRoute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/MulticastRoute.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/MulticastRoute.java?rev=573575&view=auto
==============================================================================
--- activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/MulticastRoute.java (added)
+++ activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/MulticastRoute.java Fri Sep 7 06:29:39 2007
@@ -0,0 +1,31 @@
+/**
+ *
+ * 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.example.docs;
+
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * A simple multicast example
+ *
+ * @version $Revision: 1.1 $
+ */
+public class MulticastRoute extends RouteBuilder {
+ public void configure() throws Exception {
+ from("seda:multicast.in").multicast().to("seda:multicast.out1", "seda:multicast.out2", "seda:multicast.out3");
+ }
+}
\ No newline at end of file
Propchange: activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/MulticastRoute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/PipelineRoute.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/PipelineRoute.java?rev=573575&view=auto
==============================================================================
--- activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/PipelineRoute.java (added)
+++ activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/PipelineRoute.java Fri Sep 7 06:29:39 2007
@@ -0,0 +1,31 @@
+/**
+ *
+ * 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.example.docs;
+
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * A simple pipilne example
+ *
+ * @version $Revision: 1.1 $
+ */
+public class PipelineRoute extends RouteBuilder {
+ public void configure() throws Exception {
+ from("seda:pipeline.in").to("seda:pipeline.out1", "seda:pipeline.out2", "seda:pipeline.out3");
+ }
+}
Propchange: activemq/camel/trunk/examples/camel-example-docs/src/main/java/org/apache/camel/example/docs/PipelineRoute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/examples/camel-example-docs/src/main/resources/META-INF/spring/camel-context.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-docs/src/main/resources/META-INF/spring/camel-context.xml?rev=573575&view=auto
==============================================================================
--- activemq/camel/trunk/examples/camel-example-docs/src/main/resources/META-INF/spring/camel-context.xml (added)
+++ activemq/camel/trunk/examples/camel-example-docs/src/main/resources/META-INF/spring/camel-context.xml Fri Sep 7 06:29:39 2007
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+
+ <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <package>org.apache.camel.example.docs</package>
+ </camelContext>
+
+</beans>
Propchange: activemq/camel/trunk/examples/camel-example-docs/src/main/resources/META-INF/spring/camel-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/pom.xml?rev=573575&r1=573574&r2=573575&view=diff
==============================================================================
--- activemq/camel/trunk/examples/pom.xml (original)
+++ activemq/camel/trunk/examples/pom.xml Fri Sep 7 06:29:39 2007
@@ -62,6 +62,7 @@
<module>camel-example-spring</module>
<module>camel-example-etl</module>
<module>camel-example-bam</module>
+ <module>camel-example-docs</module>
</modules>
<profiles>
Modified: activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java?rev=573575&r1=573574&r2=573575&view=diff
==============================================================================
--- activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java (original)
+++ activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java Fri Sep 7 06:29:39 2007
@@ -59,7 +59,7 @@
* Subdirectory for report.
*/
protected static final String SUBDIRECTORY = "cameldoc";
- private StringWriter htmlBuffer = new StringWriter();
+ private String indexHtmlContent;
/**
* Reference to Maven 2 Project.
*
@@ -129,13 +129,6 @@
*/
protected String duration;
/**
- * The DOT File name used to generate the DOT diagram of the route definitions
- *
- * @parameter expression="${project.build.directory}/site/cameldoc/routes.dot"
- * @readonly
- */
- protected String dotFile;
- /**
* Whether we should boot up camel with the META-INF/services/*.xml to generate the DOT file
*
* @parameter expression="true"
@@ -172,7 +165,7 @@
public void execute() throws MojoExecutionException {
this.execute(this.buildDirectory, Locale.getDefault());
try {
- writeIndexHtmlFile();
+ writeIndexHtmlFile("index.html", indexHtmlContent);
}
catch (IOException e) {
throw new MojoExecutionException("Failed: " + e, e);
@@ -188,10 +181,10 @@
Sink kitchenSink = getSink();
if (kitchenSink != null) {
- kitchenSink.rawText(htmlBuffer.toString());
+ kitchenSink.rawText(indexHtmlContent);
}
else {
- writeIndexHtmlFile();
+ writeIndexHtmlFile("index.html", indexHtmlContent);
}
}
catch (Exception e) {
@@ -229,11 +222,12 @@
}
}
try {
- PrintWriter out = new PrintWriter(htmlBuffer);
- printHtmlHeader(out);
-
for (int i = 0; i < files.size(); i++) {
File file = (File) ((List) files).get(i);
+
+ StringWriter buffer = new StringWriter();
+ PrintWriter out = new PrintWriter(buffer);
+ printHtmlHeader(out);
printHtmlFileHeader(out, file);
for (int j = 0; j < graphvizOutputTypes.length; j++) {
String format = graphvizOutputTypes[j];
@@ -245,13 +239,27 @@
}
}
printHtmlFileFooter(out, file);
- }
+ printHtmlFooter(out);
- printHtmlFooter(out);
+ String content = buffer.toString();
+ String name = file.getName();
+ if (name.equalsIgnoreCase("routes.dot") || i == 0) {
+ indexHtmlContent = content;
+ }
+ int idx = name.lastIndexOf(".");
+ if (idx >= 0) {
+ name = name.substring(0, idx);
+ name += ".html";
+ }
+ writeIndexHtmlFile(name, content);
+ }
}
catch (CommandLineException e) {
throw new MojoExecutionException("Failed: " + e, e);
}
+ catch (IOException e) {
+ throw new MojoExecutionException("Failed: " + e, e);
+ }
}
protected void runCamelEmbedded(File outputDir) throws DependencyResolutionRequiredException {
@@ -264,7 +272,7 @@
EmbeddedMojo mojo = new EmbeddedMojo();
mojo.setClasspathElements(list);
mojo.setDotEnabled(true);
- mojo.setDotFile(dotFile);
+ mojo.setDotOutputDir(resources.getAbsolutePath());
mojo.setDuration(duration);
mojo.setLog(getLog());
mojo.setOutputDirectory(outputDir);
@@ -278,10 +286,10 @@
}
}
- protected void writeIndexHtmlFile() throws IOException {
+ protected void writeIndexHtmlFile(String fileName, String content) throws IOException {
File dir = new File(outputDirectory, SUBDIRECTORY);
dir.mkdirs();
- File html = new File(dir, "index.html");
+ File html = new File(dir, fileName);
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(html));
@@ -290,7 +298,7 @@
out.println("</head>");
out.println("<body>");
out.println();
- out.write(htmlBuffer.toString());
+ out.write(content);
out.println("</body>");
out.println("</html>");
}
Modified: activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/EmbeddedMojo.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/EmbeddedMojo.java?rev=573575&r1=573574&r2=573575&view=diff
==============================================================================
--- activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/EmbeddedMojo.java (original)
+++ activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/EmbeddedMojo.java Fri Sep 7 06:29:39 2007
@@ -68,7 +68,7 @@
* @parameter expression="${project.build.directory}/site/cameldoc/routes.dot"
* @readonly
*/
- protected String dotFile;
+ protected String dotOutputDir;
/**
* Allows the DOT file generation to be disabled
*
@@ -138,12 +138,12 @@
this.dotEnabled = dotEnabled;
}
- public String getDotFile() {
- return dotFile;
+ public String getDotOutputDir() {
+ return dotOutputDir;
}
- public void setDotFile(String dotFile) {
- this.dotFile = dotFile;
+ public void setDotOutputDir(String dotOutputDir) {
+ this.dotOutputDir = dotOutputDir;
}
public String getDuration() {
@@ -174,7 +174,7 @@
protected String[] createArguments() {
if (dotEnabled) {
- return new String[]{"-duration", duration, "-file", dotFile};
+ return new String[]{"-duration", duration, "-outdir", dotOutputDir};
}
else {
return new String[]{"-duration", duration};