CAMEL-7263: Remove old and unused/deprecated dot code that has not been in use or maintained for many years.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b67b6296 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b67b6296 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b67b6296 Branch: refs/heads/master Commit: b67b629694d92fbae9e772f569d5ff8748e5cac8 Parents: 9f5e32d Author: Claus Ibsen <davscl...@apache.org> Authored: Sun Mar 22 16:28:15 2015 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun Mar 22 16:28:15 2015 +0100 ---------------------------------------------------------------------- .../java/org/apache/camel/impl/MainSupport.java | 1 - .../main/java/org/apache/camel/main/Main.java | 5 - .../java/org/apache/camel/main/MainSupport.java | 107 ---- examples/camel-example-docs/README.txt | 39 -- examples/camel-example-docs/pom.xml | 102 ---- .../src/main/resources/META-INF/LICENSE.txt | 203 ------- .../src/main/resources/META-INF/NOTICE.txt | 11 - .../resources/META-INF/spring/camel-context.xml | 44 -- .../src/main/resources/features.xml | 26 - .../src/main/resources/log4j.properties | 29 - .../camel/example/docs/IntegrationTest.java | 31 - examples/pom.xml | 1 - .../java/org/apache/camel/maven/DotMojo.java | 572 ------------------- .../org/apache/camel/maven/EmbeddedMojo.java | 67 --- .../java/org/apache/camel/maven/RunMojo.java | 33 -- .../resources/camel-maven-plugin.properties | 21 - .../org/apache/camel/guice/maven/DotMojo.java | 534 ----------------- .../apache/camel/guice/maven/EmbeddedMojo.java | 69 --- .../org/apache/camel/guice/maven/RunMojo.java | 33 -- .../resources/guice-maven-plugin.properties | 33 -- 20 files changed, 1961 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/camel-core/src/main/java/org/apache/camel/impl/MainSupport.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/MainSupport.java b/camel-core/src/main/java/org/apache/camel/impl/MainSupport.java index f779527..ec83351 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/MainSupport.java +++ b/camel-core/src/main/java/org/apache/camel/impl/MainSupport.java @@ -16,7 +16,6 @@ */ package org.apache.camel.impl; - /** * @deprecated * @see org.apache.camel.main.MainSupport http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/camel-core/src/main/java/org/apache/camel/main/Main.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/main/Main.java b/camel-core/src/main/java/org/apache/camel/main/Main.java index a7871cd..7a50785 100644 --- a/camel-core/src/main/java/org/apache/camel/main/Main.java +++ b/camel-core/src/main/java/org/apache/camel/main/Main.java @@ -18,7 +18,6 @@ package org.apache.camel.main; import java.util.HashMap; import java.util.Map; -import javax.xml.bind.JAXBException; import org.apache.camel.CamelContext; import org.apache.camel.ProducerTemplate; @@ -26,7 +25,6 @@ import org.apache.camel.impl.CompositeRegistry; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.impl.SimpleRegistry; import org.apache.camel.spi.Registry; -import org.apache.camel.view.ModelFileGenerator; /** * A command line tool for booting up a CamelContext @@ -164,7 +162,4 @@ public class Main extends MainSupport { return new DefaultCamelContext(); } - protected ModelFileGenerator createModelFileGenerator() throws JAXBException { - return null; - } } http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/camel-core/src/main/java/org/apache/camel/main/MainSupport.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/main/MainSupport.java b/camel-core/src/main/java/org/apache/camel/main/MainSupport.java index 4fb30fe..c328df8 100644 --- a/camel-core/src/main/java/org/apache/camel/main/MainSupport.java +++ b/camel-core/src/main/java/org/apache/camel/main/MainSupport.java @@ -16,7 +16,6 @@ */ package org.apache.camel.main; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; @@ -27,21 +26,16 @@ import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import javax.xml.bind.JAXBException; import org.apache.camel.CamelContext; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.impl.DefaultModelJAXBContextFactory; import org.apache.camel.model.ModelCamelContext; import org.apache.camel.model.RouteDefinition; import org.apache.camel.spi.ModelJAXBContextFactory; import org.apache.camel.support.ServiceSupport; -import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.ServiceHelper; -import org.apache.camel.view.ModelFileGenerator; -import org.apache.camel.view.RouteDotGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,14 +46,11 @@ import org.slf4j.LoggerFactory; */ public abstract class MainSupport extends ServiceSupport { protected static final Logger LOG = LoggerFactory.getLogger(MainSupport.class); - protected String dotOutputDir; protected final List<Option> options = new ArrayList<Option>(); protected final CountDownLatch latch = new CountDownLatch(1); protected final AtomicBoolean completed = new AtomicBoolean(false); protected long duration = -1; protected TimeUnit timeUnit = TimeUnit.MILLISECONDS; - protected String routesOutputFile; - protected boolean aggregateDot; protected boolean trace; protected List<RouteBuilder> routeBuilders = new ArrayList<RouteBuilder>(); protected String routeBuilderClasses; @@ -103,20 +94,6 @@ public abstract class MainSupport extends ServiceSupport { setRouteBuilderClasses(parameter); } }); - 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) { - setDotOutputDir(parameter); - } - }); - addOption(new ParameterOption("ad", "aggregate-dot", - "Aggregates all routes (in addition to individual route generation) into one context to create one monolithic DOT file for visual representations the entire system.", - "aggregate-dot") { - protected void doProcess(String arg, String parameter, LinkedList<String> remainingArgs) { - setAggregateDot("true".equals(parameter)); - } - }); addOption(new ParameterOption("d", "duration", "Sets the time duration that the application will run for, by default in milliseconds. You can use '10s' for 10 seconds etc", "duration") { @@ -134,11 +111,6 @@ public abstract class MainSupport extends ServiceSupport { enableTrace(); } }); - addOption(new ParameterOption("out", "output", "Output all routes to the specified XML file", "filename") { - protected void doProcess(String arg, String parameter, LinkedList<String> remainingArgs) { - setRoutesOutputFile(parameter); - } - }); } /** @@ -271,10 +243,6 @@ public abstract class MainSupport extends ServiceSupport { this.timeUnit = timeUnit; } - public String getDotOutputDir() { - return dotOutputDir; - } - public void setRouteBuilderClasses(String builders) { this.routeBuilderClasses = builders; } @@ -283,23 +251,6 @@ public abstract class MainSupport extends ServiceSupport { return routeBuilderClasses; } - /** - * 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 setDotOutputDir(String dotOutputDir) { - this.dotOutputDir = dotOutputDir; - } - - public void setAggregateDot(boolean aggregateDot) { - this.aggregateDot = aggregateDot; - } - - public boolean isAggregateDot() { - return aggregateDot; - } - public boolean isTrace() { return trace; } @@ -311,14 +262,6 @@ public abstract class MainSupport extends ServiceSupport { } } - public void setRoutesOutputFile(String routesOutputFile) { - this.routesOutputFile = routesOutputFile; - } - - public String getRoutesOutputFile() { - return routesOutputFile; - } - protected void doStop() throws Exception { LOG.info("Apache Camel " + getVersion() + " stopping"); // call completed to properly stop as we count down the waiting latch @@ -396,67 +339,17 @@ public abstract class MainSupport extends ServiceSupport { protected void postProcessContext() throws Exception { Map<String, CamelContext> map = getCamelContextMap(); Set<Map.Entry<String, CamelContext>> entries = map.entrySet(); - int size = entries.size(); for (Map.Entry<String, CamelContext> entry : entries) { - String name = entry.getKey(); CamelContext camelContext = entry.getValue(); camelContexts.add(camelContext); - generateDot(name, camelContext, size); postProcessCamelContext(camelContext); } - - if (isAggregateDot()) { - generateDot("aggregate", aggregateCamelContext(), 1); - } - - if (!"".equals(getRoutesOutputFile())) { - outputRoutesToFile(); - } - } - - protected void outputRoutesToFile() throws IOException, JAXBException { - if (ObjectHelper.isNotEmpty(getRoutesOutputFile())) { - LOG.info("Generating routes as XML in the file named: " + getRoutesOutputFile()); - ModelFileGenerator generator = createModelFileGenerator(); - generator.marshalRoutesUsingJaxb(getRoutesOutputFile(), getRouteDefinitions()); - } - } - - protected ModelFileGenerator createModelFileGenerator() throws JAXBException { - return new ModelFileGenerator(getModelJAXBContextFactory().newJAXBContext()); } public ModelJAXBContextFactory getModelJAXBContextFactory() { return new DefaultModelJAXBContextFactory(); } - protected void generateDot(String name, CamelContext camelContext, int size) throws IOException { - String outputDir = dotOutputDir; - if (ObjectHelper.isNotEmpty(outputDir)) { - if (size > 1) { - outputDir += "/" + name; - } - RouteDotGenerator generator = new RouteDotGenerator(outputDir); - LOG.info("Generating DOT file for routes: " + outputDir + " for: " + camelContext + " with name: " + name); - generator.drawRoutes(camelContext); - } - } - - /** - * Used for aggregate dot generation, generate a single camel context containing all of the available contexts. - */ - private CamelContext aggregateCamelContext() throws Exception { - if (camelContexts.size() == 1) { - return camelContexts.get(0); - } else { - ModelCamelContext answer = new DefaultCamelContext(); - for (CamelContext camelContext : camelContexts) { - answer.addRouteDefinitions(((ModelCamelContext)camelContext).getRouteDefinitions()); - } - return answer; - } - } - protected void loadRouteBuilders(CamelContext camelContext) throws Exception { if (routeBuilderClasses != null) { // get the list of route builder classes http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/examples/camel-example-docs/README.txt ---------------------------------------------------------------------- diff --git a/examples/camel-example-docs/README.txt b/examples/camel-example-docs/README.txt deleted file mode 100644 index 84078d3..0000000 --- a/examples/camel-example-docs/README.txt +++ /dev/null @@ -1,39 +0,0 @@ -Documentation Example -===================== - -This example creates a bunch of routes to show how the Maven reporting -tools can visualise routes - -This example also acts as an integration test case for the GraphViz -visualisation feature - http://camel.apache.org/visualisation.html - -You will need to compile this example first: - mvn compile - -NOTE before you run this example you MUST install GraphViz so that -the 'dot' executable is available on your path. -See the camel:dot documentation for more information - http://camel.apache.org/camel-dot-maven-goal.html - -To run the example using Maven and generate the documentation type - mvn camel:dot - -The reports should be generated in - target/site/cameldoc/index.html - -If the dot executable is in your path, .svg images will be generated for -any .dot files under - target/site/cameldoc - -You can see the routing rules by looking the Spring XML configuration file in -src/main/resources/META-INF/spring - -If you hit any problems please let us know on the Camel Forums - http://camel.apache.org/discussion-forums.html - -Please help us make Apache Camel better - we appreciate any feedback you -may have. Enjoy! - ------------------------- -The Camel riders! http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/examples/camel-example-docs/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-docs/pom.xml b/examples/camel-example-docs/pom.xml deleted file mode 100755 index c23d4ad..0000000 --- a/examples/camel-example-docs/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ -<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel</groupId> - <artifactId>examples</artifactId> - <version>2.16-SNAPSHOT</version> - </parent> - - <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> - - <!-- let's use log4j --> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> - - <!-- for testing --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>attach-artifacts</id> - <phase>package</phase> - <goals> - <goal>attach-artifact</goal> - </goals> - <configuration> - <artifacts> - <artifact> - <file>target/classes/features.xml</file> - <type>xml</type> - <classifier>features</classifier> - </artifact> - </artifacts> - </configuration> - </execution> - </executions> - </plugin> - - <!-- Allows the example to be run via 'mvn camel:run' --> - <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-maven-plugin</artifactId> - <version>${project.version}</version> - </plugin> - - </plugins> - </build> - - <reporting> - <plugins> - <!-- let's generate nice PNG / SVG diagrams from our routes --> - <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-maven-plugin</artifactId> - <version>${project.version}</version> - </plugin> - </plugins> - </reporting> -</project> http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/examples/camel-example-docs/src/main/resources/META-INF/LICENSE.txt ---------------------------------------------------------------------- diff --git a/examples/camel-example-docs/src/main/resources/META-INF/LICENSE.txt b/examples/camel-example-docs/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b127..0000000 --- a/examples/camel-example-docs/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/examples/camel-example-docs/src/main/resources/META-INF/NOTICE.txt ---------------------------------------------------------------------- diff --git a/examples/camel-example-docs/src/main/resources/META-INF/NOTICE.txt b/examples/camel-example-docs/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf..0000000 --- a/examples/camel-example-docs/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/examples/camel-example-docs/src/main/resources/META-INF/spring/camel-context.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-docs/src/main/resources/META-INF/spring/camel-context.xml b/examples/camel-example-docs/src/main/resources/META-INF/spring/camel-context.xml deleted file mode 100644 index 24490ce..0000000 --- a/examples/camel-example-docs/src/main/resources/META-INF/spring/camel-context.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?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.xsd - http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> - - <camelContext xmlns="http://camel.apache.org/schema/spring"> - - <route> - <from uri="seda:other.a"/> - <to uri="seda:other.b"/> - <to uri="seda:other.c"/> - </route> - - <route> - <from uri="seda:queue:order"/> - <filter> - <xpath>/person[@name='Test']</xpath> - <to uri="log:testOrder"/> - </filter> - <to uri="bean:processOrder"/> - </route> - - </camelContext> - -</beans> http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/examples/camel-example-docs/src/main/resources/features.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-docs/src/main/resources/features.xml b/examples/camel-example-docs/src/main/resources/features.xml deleted file mode 100644 index 361aab3..0000000 --- a/examples/camel-example-docs/src/main/resources/features.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?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. ---> -<features> - <repository>mvn:org.apache.camel.karaf/apache-camel/${project.version}/xml/features</repository> - - <feature name='camel-example-docs' version='${project.version}'> - <feature version="${project.version}">camel</feature> - <bundle>mvn:org.apache.camel/camel-example-docs/${project.version}</bundle> - </feature> - -</features> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/examples/camel-example-docs/src/main/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/examples/camel-example-docs/src/main/resources/log4j.properties b/examples/camel-example-docs/src/main/resources/log4j.properties deleted file mode 100644 index f86c7aa..0000000 --- a/examples/camel-example-docs/src/main/resources/log4j.properties +++ /dev/null @@ -1,29 +0,0 @@ -## ------------------------------------------------------------------------ -## 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. -## ------------------------------------------------------------------------ - -# -# The logging properties used -# -log4j.rootLogger=INFO, out - -# uncomment the next line to debug Camel -#log4j.logger.org.apache.camel=DEBUG - -# CONSOLE appender not used by default -log4j.appender.out=org.apache.log4j.ConsoleAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/examples/camel-example-docs/src/test/java/org/apache/camel/example/docs/IntegrationTest.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-docs/src/test/java/org/apache/camel/example/docs/IntegrationTest.java b/examples/camel-example-docs/src/test/java/org/apache/camel/example/docs/IntegrationTest.java deleted file mode 100644 index a9fabc2..0000000 --- a/examples/camel-example-docs/src/test/java/org/apache/camel/example/docs/IntegrationTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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 junit.framework.TestCase; -import org.apache.camel.spring.Main; - -/** - * @version - */ -public class IntegrationTest extends TestCase { - - public void testCamelRulesDeployCorrectlyInSpring() throws Exception { - // let's boot up the Spring application context for 2 seconds to check it works OK - Main.main("-duration", "2s", "-o", "target/site/cameldoc"); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/examples/pom.xml ---------------------------------------------------------------------- diff --git a/examples/pom.xml b/examples/pom.xml index c944eb5..7d02eea 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -43,7 +43,6 @@ <module>camel-example-cxf-proxy</module> <module>camel-example-cxf-tomcat</module> <module>camel-example-console</module> - <module>camel-example-docs</module> <module>camel-example-etl</module> <module>camel-example-ftp</module> <module>camel-example-gae</module> http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java deleted file mode 100644 index 61f04e7..0000000 --- a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/DotMojo.java +++ /dev/null @@ -1,572 +0,0 @@ -/** - * 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.maven; - -import java.io.BufferedReader; -import java.io.Closeable; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.ResourceBundle; -import java.util.Set; - -import org.apache.camel.util.IOHelper; - -import org.apache.maven.artifact.DependencyResolutionRequiredException; -import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.doxia.siterenderer.Renderer; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.project.MavenProject; -import org.apache.maven.reporting.AbstractMavenReport; -import org.apache.maven.reporting.MavenReportException; - -import org.codehaus.plexus.util.cli.CommandLineException; -import org.codehaus.plexus.util.cli.CommandLineUtils; -import org.codehaus.plexus.util.cli.Commandline; - -/** - * Runs Camel embedded with META-INF/services/*.xml spring files to try create - * DOT files for the routing rules, then converts the DOT files into another - * format such as PNG - * - * @version - * @goal dot - * @requiresDependencyResolution compile+runtime - * @phase prepare-package - * @execute phase="test-compile" - * @see <a href="http://www.graphviz.org/">GraphViz</a> - */ -public class DotMojo extends AbstractMavenReport { - public static final String[] DEFAULT_GRAPHVIZ_OUTPUT_TYPES = {"png", "svg", "cmapx"}; - /** - * Subdirectory for report. - */ - protected static final String SUBDIRECTORY = "cameldoc"; - // - // For running Camel embedded - // ------------------------------------------------------------------------- - // - /** - * The duration to run the application for which by default is in - * milliseconds. A value <= 0 will run forever. - * Adding a s indicates seconds - eg "5s" means 5 seconds. - * - * @parameter property="2s" - */ - protected String duration; - - /** - * Whether we should boot up camel with the META-INF/services/*.xml to - * generate the DOT file - * - * @parameter property="true" - */ - protected boolean runCamel; - - /** - * Should we try run the DOT executable on the generated .DOT file to - * generate images - * - * @parameter property="true" - */ - protected boolean useDot; - - /** - * The classpath based application context uri that spring wants to get. - * - * @parameter property="camel.applicationContextUri" - */ - protected String applicationContextUri; - - /** - * The filesystem based application context uri that spring wants to get. - * - * @parameter property="camel.fileApplicationContextUri" - */ - protected String fileApplicationContextUri; - - /** - * The main class to execute. - * - * @parameter property="camel.mainClass" - * default-value="org.apache.camel.spring.Main" - * @required - */ - private String mainClass; - - /** - * Reference to Maven 2 Project. - * - * @parameter property="project" - * @required - * @readonly - */ - private MavenProject project; - - /** - * Base output directory. - * - * @parameter property="project.build.directory" - * @required - */ - private File buildDirectory; - - /** - * Base output directory for reports. - * - * @parameter default-value="${project.build.directory}/site/cameldoc" - * @required - */ - private File outputDirectory; - - - /** - * In the case of multiple camel contexts, setting aggregate == true will - * aggregate all into a monolithic context, otherwise they will be processed - * independently. - * - * @parameter - */ - private String aggregate; - - /** - * GraphViz executable location; visualization (images) will be generated - * only if you install this program and set this property to the executable - * dot (dot.exe on Win). - * - * @parameter property="dot" - */ - private String executable; - - /** - * Graphviz output types. Default is png. Possible values: png, jpg, gif, - * svg. - * - * @required - */ - private String graphvizOutputType; - - /** - * Graphviz output types. Possible values: png, jpg, gif, svg. - * - * @parameter - */ - private String[] graphvizOutputTypes; - - /** - * Doxia SiteRender. - * - * @component - */ - private Renderer renderer; - - private String indexHtmlContent; - - /** - * @param locale report locale. - * @return report description. - * @see org.apache.maven.reporting.MavenReport#getDescription(Locale) - */ - public String getDescription(final Locale locale) { - return getBundle(locale).getString("report.dot.description"); - } - - /** - * @see org.apache.maven.reporting.MavenReport#getName(Locale) - */ - public String getName(final Locale locale) { - return getBundle(locale).getString("report.dot.name"); - } - - public String getOutputName() { - return SUBDIRECTORY + "/index"; - } - - public String getAggregate() { - return aggregate; - } - - public void setAggregate(String aggregate) { - this.aggregate = aggregate; - } - - public boolean isUseDot() { - return useDot; - } - - public void setUseDot(boolean useDot) { - this.useDot = useDot; - } - - public void execute() throws MojoExecutionException { - this.execute(this.buildDirectory, Locale.getDefault()); - try { - writeIndexHtmlFile(outputDirectory, "index.html", indexHtmlContent); - } catch (IOException e) { - throw new MojoExecutionException("Failed: " + e, e); - } - } - - protected void executeReport(final Locale locale) throws MavenReportException { - try { - this.execute(this.outputDirectory, locale); - - Sink kitchenSink = getSink(); - if (kitchenSink != null) { - kitchenSink.rawText(indexHtmlContent); - } else { - writeIndexHtmlFile(outputDirectory, "index.html", indexHtmlContent); - } - } catch (Exception e) { - final MavenReportException ex = new MavenReportException(e.getMessage()); - ex.initCause(e.getCause()); - throw ex; - } - } - - /** - * Executes DOT generator. - * - * @param outputDir report output directory. - * @param locale report locale. - * @throws MojoExecutionException if there were any execution errors. - */ - protected void execute(final File outputDir, final Locale locale) throws MojoExecutionException { - - try { - runCamelEmbedded(outputDir); - } catch (DependencyResolutionRequiredException e) { - throw new MojoExecutionException("Failed: " + e, e); - } - outputDir.mkdirs(); - - List<File> files = new ArrayList<File>(); - appendFiles(files, outputDirectory); - - if (graphvizOutputTypes == null) { - if (graphvizOutputType == null) { - graphvizOutputTypes = DEFAULT_GRAPHVIZ_OUTPUT_TYPES; - } else { - graphvizOutputTypes = new String[] {graphvizOutputType}; - } - } - try { - Set<String> contextNames = new HashSet<String>(); - for (File file : files) { - String contextName = file.getParentFile().getName(); - contextNames.add(contextName); - } - - boolean multipleCamelContexts = contextNames.size() > 1; - int size = files.size(); - for (int i = 0; i < size; i++) { - File file = files.get(i); - String contextName = null; - if (multipleCamelContexts) { - contextName = file.getParentFile().getName(); - } - - getLog().info("Generating contextName: " + contextName + " file: " + file + ""); - - generate(i, file, contextName); - } - - if (multipleCamelContexts) { - // lets generate an index page which lists each indiviual - // CamelContext file - StringWriter buffer = new StringWriter(); - PrintWriter out = new PrintWriter(buffer); - - out.println("<h1>Camel Contexts</h1>"); - out.println(); - - out.println("<ul>"); - for (String contextName : contextNames) { - out.print(" <li><a href='"); - out.print(contextName); - out.print("/routes.html'>"); - out.print(contextName); - out.println("</a></li>"); - } - out.println("</ul>"); - indexHtmlContent = buffer.toString(); - } - } catch (CommandLineException e) { - throw new MojoExecutionException("Failed: " + e, e); - } catch (IOException e) { - throw new MojoExecutionException("Failed: " + e, e); - } - } - - private void generate(int index, File file, String contextName) throws CommandLineException, - MojoExecutionException, IOException { - - StringWriter buffer = new StringWriter(); - PrintWriter out = new PrintWriter(buffer); - printHtmlHeader(out, contextName); - printHtmlFileHeader(out, file); - for (String format : graphvizOutputTypes) { - String generated = convertFile(file, format); - - if (format.equals("cmapx") && generated != null) { - // lets include the generated file inside the html - addFileToBuffer(out, new File(generated)); - } - } - printHtmlFileFooter(out, file); - printHtmlFooter(out); - - String content = buffer.toString(); - String name = file.getName(); - if (name.equalsIgnoreCase("routes.dot") || index == 0) { - indexHtmlContent = content; - } - int idx = name.lastIndexOf("."); - if (idx >= 0) { - name = name.substring(0, idx); - name += ".html"; - } - writeIndexHtmlFile(file.getParentFile(), name, content); - } - - protected void runCamelEmbedded(File outputDir) throws DependencyResolutionRequiredException { - if (runCamel) { - // default path, but can be overridden by configuration - if (applicationContextUri != null) { - getLog().info("Running Camel embedded to load Spring XML files from classpath: " + applicationContextUri); - } else if (fileApplicationContextUri != null) { - getLog().info("Running Camel embedded to load Spring XML files from file path: " + fileApplicationContextUri); - } else { - getLog().info("Running Camel embedded to load Spring XML files from default path: META-INF/spring/*.xml"); - } - - List<?> list = project.getTestClasspathElements(); - getLog().debug("Using classpath: " + list); - - EmbeddedMojo mojo = new EmbeddedMojo(); - mojo.setClasspathElements(list); - mojo.setDotEnabled(true); - mojo.setMainClass(mainClass); - if ("true".equals(getAggregate())) { - mojo.setDotAggregationEnabled(true); - } - mojo.setOutputDirectory(outputDirectory.getAbsolutePath()); - mojo.setDuration(duration); - mojo.setLog(getLog()); - mojo.setPluginContext(getPluginContext()); - mojo.setApplicationContextUri(applicationContextUri); - mojo.setFileApplicationContextUri(fileApplicationContextUri); - try { - mojo.executeWithoutWrapping(); - } catch (Exception e) { - getLog().error("Failed to run Camel embedded: " + e, e); - } - } - } - - protected void writeIndexHtmlFile(File dir, String fileName, String content) throws IOException { - // File dir = outputDirectory; - dir.mkdirs(); - File html = new File(dir, fileName); - PrintWriter out = null; - try { - out = new PrintWriter(new FileWriter(html)); - out.println("<html>"); - out.println("<head>"); - out.println("</head>"); - out.println("<body>"); - out.println(); - if (content == null) { - out.write("<p>No EIP diagrams available</p>"); - } else { - out.write(content); - } - out.println("</body>"); - out.println("</html>"); - } finally { - String description = "Failed to close html output file"; - close(out, description); - } - } - - protected void printHtmlHeader(PrintWriter out, String contextName) { - if (contextName != null) { - out.println("<h1>EIP Patterns for CamelContext: " + contextName + "</h1>"); - } else { - out.println("<h1>Camel EIP Patterns</h1>"); - } - out.println(); - } - - protected void printHtmlFileHeader(PrintWriter out, File file) { - out.println("<p>"); - out.println(" <img src='" + removeFileExtension(file.getName()) + ".png' usemap='#CamelRoutes'>"); - } - - protected void printHtmlFileFooter(PrintWriter out, File file) { - out.println(" </img>"); - out.println("</p>"); - out.println(); - } - - protected void printHtmlFooter(PrintWriter out) { - out.println(); - } - - protected void close(Closeable closeable, String description) { - if (closeable != null) { - try { - closeable.close(); - } catch (IOException e) { - getLog().warn(description + ": " + e); - } - } - } - - protected String convertFile(File file, String format) throws CommandLineException { - Log log = getLog(); - if (!useDot) { - log.info("DOT generation disabled."); - return null; - } else { - if (dotHelpExitCode() != 0) { - log.info("'dot -?' execution failed so DOT generation disabled."); - return null; - } - } - if (this.executable == null || this.executable.length() == 0) { - log.warn("Parameter <executable/> was not set in the pom.xml. Skipping conversion."); - return null; - } - - String generatedFileName = removeFileExtension(file.getAbsolutePath()) + "." + format; - Commandline cl = new Commandline(); - cl.setExecutable(executable); - cl.createArg().setValue("-T" + format); - cl.createArg().setValue("-o"); - cl.createArg().setValue(generatedFileName); - cl.createArg().setValue(file.getAbsolutePath()); - - log.debug("executing: " + cl.toString()); - - CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); - CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - - CommandLineUtils.executeCommandLine(cl, stdout, stderr); - - String output = stdout.getOutput(); - if (output.length() > 0) { - log.debug(output); - } - String errOutput = stderr.getOutput(); - if (errOutput.length() > 0) { - log.warn(errOutput); - } - return generatedFileName; - } - - private int dotHelpExitCode() throws CommandLineException { - Commandline cl = new Commandline(); - cl.setExecutable(executable); - cl.createArg().setValue("-?"); - - CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); - CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - - return CommandLineUtils.executeCommandLine(cl, stdout, stderr); - } - - protected String removeFileExtension(String name) { - int idx = name.lastIndexOf("."); - if (idx > 0) { - return name.substring(0, idx); - } else { - return name; - } - } - - private void appendFiles(List<File> output, File file) { - if (file.isDirectory()) { - appendDirectory(output, file); - } else { - if (isValid(file)) { - output.add(file); - } - } - } - - private void appendDirectory(List<File> output, File dir) { - File[] files = dir.listFiles(); - for (File file : files) { - appendFiles(output, file); - } - } - - private boolean isValid(File file) { - String name = file.getName().toLowerCase(); - return name.endsWith(".dot"); - } - - private void addFileToBuffer(PrintWriter out, File file) throws MojoExecutionException { - BufferedReader reader = null; - try { - reader = IOHelper.buffered(new FileReader(file)); - while (true) { - String line = reader.readLine(); - if (line == null) { - break; - } else { - out.println(line); - } - } - } catch (IOException e) { - throw new MojoExecutionException("Failed: " + e, e); - } finally { - close(reader, "cmapx file"); - } - } - - /** - * Gets resource bundle for given locale. - * - * @param locale locale - * @return resource bundle - */ - protected ResourceBundle getBundle(final Locale locale) { - return ResourceBundle.getBundle("camel-maven-plugin", locale, this.getClass().getClassLoader()); - } - - protected Renderer getSiteRenderer() { - return this.renderer; - } - - protected String getOutputDirectory() { - return this.outputDirectory.getAbsolutePath(); - } - - protected MavenProject getProject() { - return this.project; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/EmbeddedMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/EmbeddedMojo.java b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/EmbeddedMojo.java index d2ab154..e804cd1 100644 --- a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/EmbeddedMojo.java +++ b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/EmbeddedMojo.java @@ -52,30 +52,6 @@ public class EmbeddedMojo extends AbstractExecMojo { protected String duration; /** - * The DOT File name used to generate the DOT diagram of the route definitions - * - * @parameter default-value="${project.build.directory}/site/cameldoc/routes.dot" - * @readonly - */ - protected String outputDirectory; - - /** - * Allows the DOT file generation to be disabled - * - * @parameter property="true" - * @readonly - */ - protected boolean dotEnabled; - - /** - * Allows the routes from multiple contexts to be aggregated into one DOT file (in addition to the individual files) - * - * @parameter property="false" - * @readonly - */ - protected boolean dotAggregationEnabled; - - /** * The classpath based application context uri that spring wants to get. * * @parameter property="camel.applicationContextUri" @@ -133,24 +109,6 @@ public class EmbeddedMojo extends AbstractExecMojo { // Properties //------------------------------------------------------------------------- - /** - * Getter for property output directory. - * - * @return The value of output directory. - */ - public String getOutputDirectory() { - return outputDirectory; - } - - /** - * Setter for the output directory. - * - * @param inOutputDirectory The value of output directory. - */ - public void setOutputDirectory(String inOutputDirectory) { - this.outputDirectory = inOutputDirectory; - } - public List<?> getClasspathElements() { return classpathElements; } @@ -159,14 +117,6 @@ public class EmbeddedMojo extends AbstractExecMojo { this.classpathElements = classpathElements; } - public boolean isDotEnabled() { - return dotEnabled; - } - - public void setDotEnabled(boolean dotEnabled) { - this.dotEnabled = dotEnabled; - } - public String getDuration() { return duration; } @@ -175,14 +125,6 @@ public class EmbeddedMojo extends AbstractExecMojo { this.duration = duration; } - public boolean isDotAggregationEnabled() { - return dotAggregationEnabled; - } - - public void setDotAggregationEnabled(boolean dotAggregationEnabled) { - this.dotAggregationEnabled = dotAggregationEnabled; - } - public String getApplicationContextUri() { return applicationContextUri; } @@ -230,15 +172,6 @@ public class EmbeddedMojo extends AbstractExecMojo { protected String[] createArguments() { List<String> args = new ArrayList<String>(5); - if (isDotEnabled()) { - args.add("-outdir"); - args.add(getOutputDirectory()); - } - - if (isDotAggregationEnabled()) { - args.add("-aggregate-dot"); - args.add("true"); - } if (applicationContextUri != null) { args.add("-applicationContext"); http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java index 88ce8e3..fba33ec 100644 --- a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java +++ b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java @@ -92,23 +92,6 @@ public class RunMojo extends AbstractExecMojo { protected String duration; /** - * The DOT output directory name used to generate the DOT diagram of the - * route definitions - * - * @parameter default-value="${project.build.directory}/site/cameldoc" - * @readonly - */ - protected String dotDir; - - /** - * Allows the DOT file generation to be enabled - * - * @parameter property="camel.usdDot" - * default-value="false" - */ - protected boolean useDot; - - /** * Whether to log the classpath when starting * * @parameter property="camel.logClasspath" @@ -182,13 +165,6 @@ public class RunMojo extends AbstractExecMojo { private boolean trace; /** - * Output all routes to the specified XML file - * - * @parameter property="camel.routesOutputFile" - */ - private String routesOutputFile; - - /** * The main class to execute. * * @parameter property="camel.mainClass" @@ -390,19 +366,10 @@ public class RunMojo extends AbstractExecMojo { // lets create the command line arguments to pass in... List<String> args = new ArrayList<String>(); - if (dotDir != null && useDot) { - args.add("-o"); - args.add(dotDir); - } if (trace) { args.add("-t"); } - if (routesOutputFile != null) { - args.add("-output"); - args.add(routesOutputFile); - } - if (applicationContextUri != null) { args.add("-ac"); args.add(applicationContextUri); http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/tooling/maven/camel-maven-plugin/src/main/resources/camel-maven-plugin.properties ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-maven-plugin/src/main/resources/camel-maven-plugin.properties b/tooling/maven/camel-maven-plugin/src/main/resources/camel-maven-plugin.properties deleted file mode 100644 index 50b70b0..0000000 --- a/tooling/maven/camel-maven-plugin/src/main/resources/camel-maven-plugin.properties +++ /dev/null @@ -1,21 +0,0 @@ -# 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. - -report.dot.name = Camel EIP Diagram -report.dot.description = This report generates a graphical diagram of all the Enterprise Integration Patterns in this project -report.dot.header=Dot Report - http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/DotMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/DotMojo.java b/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/DotMojo.java deleted file mode 100644 index 8d03213..0000000 --- a/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/DotMojo.java +++ /dev/null @@ -1,534 +0,0 @@ -/** - * 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.guice.maven; - -import java.io.BufferedReader; -import java.io.Closeable; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.ResourceBundle; -import java.util.Set; - -import org.apache.camel.util.IOHelper; - -import org.apache.maven.artifact.DependencyResolutionRequiredException; -import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.doxia.siterenderer.Renderer; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.project.MavenProject; -import org.apache.maven.reporting.AbstractMavenReport; -import org.apache.maven.reporting.MavenReportException; - -import org.codehaus.plexus.util.cli.CommandLineException; -import org.codehaus.plexus.util.cli.CommandLineUtils; -import org.codehaus.plexus.util.cli.Commandline; - -/** - * Runs a Camel using the - * <code>jndi.properties</code> file on the classpath to - * way to <a href="http://camel.apache.org/guice.html">bootstrap via Guice</a> - * then the DOT files are created, then they are converted from DOT files to another format such as PNG - * - * @version - * @goal dot - * @requiresDependencyResolution runtime - * @phase prepare-package - * @execute phase="test-compile" - * @see <a href="http://www.graphviz.org/">GraphViz</a> - */ -public class DotMojo extends AbstractMavenReport { - public static final String[] DEFAULT_GRAPHVIZ_OUTPUT_TYPES = {"png", "svg", "cmapx"}; - /** - * Subdirectory for report. - */ - protected static final String SUBDIRECTORY = "cameldoc"; - // - // For running Camel embedded - // ------------------------------------------------------------------------- - // - /** - * The duration to run the application for which by default is in - * milliseconds. A value <= 0 will run forever. - * Adding a s indicates seconds - eg "5s" means 5 seconds. - * - * @parameter property="2s" - */ - protected String duration; - - /** - * Whether we should boot up camel with the jndi.properties file to - * generate the DOT file - * - * @parameter property="true" - */ - protected boolean runCamel; - - /** - * Should we try run the DOT executable on the generated .DOT file to - * generate images - * - * @parameter property="true" - */ - protected boolean useDot; - - /** - * The main class to execute. - * - * @parameter property="camel.mainClass" - * default-value="org.apache.camel.guice.Main" - * @required - */ - private String mainClass; - - /** - * Reference to Maven 2 Project. - * - * @parameter property="project" - * @required - * @readonly - */ - private MavenProject project; - - /** - * Base output directory. - * - * @parameter property="project.build.directory" - * @required - */ - private File buildDirectory; - - /** - * Base output directory for reports. - * - * @parameter default-value="${project.build.directory}/site/cameldoc" - * @required - */ - private File outputDirectory; - - - /** - * In the case of multiple camel contexts, setting aggregate == true will - * aggregate all into a monolithic context, otherwise they will be processed - * independently. - * - * @parameter - */ - private String aggregate; - - /** - * GraphViz executable location; visualization (images) will be generated - * only if you install this program and set this property to the executable - * dot (dot.exe on Win). - * - * @parameter property="dot" - */ - private String executable; - - /** - * Graphviz output types. Default is png. Possible values: png, jpg, gif, - * svg. - * - * @required - */ - private String graphvizOutputType; - - /** - * Graphviz output types. Possible values: png, jpg, gif, svg. - * - * @parameter - */ - private String[] graphvizOutputTypes; - - /** - * Doxia SiteRender. - * - * @component - */ - private Renderer renderer; - - private String indexHtmlContent; - - /** - * @param locale report locale. - * @return report description. - * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale) - */ - public String getDescription(final Locale locale) { - return getBundle(locale).getString("report.dot.description"); - } - - /** - * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale) - */ - public String getName(final Locale locale) { - return getBundle(locale).getString("report.dot.name"); - } - - public String getOutputName() { - return SUBDIRECTORY + "/index"; - } - - public String getAggregate() { - return aggregate; - } - - public void setAggregate(String aggregate) { - this.aggregate = aggregate; - } - - public boolean isUseDot() { - return useDot; - } - - public void setUseDot(boolean useDot) { - this.useDot = useDot; - } - - public void execute() throws MojoExecutionException { - this.execute(this.buildDirectory, Locale.getDefault()); - try { - writeIndexHtmlFile(outputDirectory, "index.html", indexHtmlContent); - } catch (IOException e) { - throw new MojoExecutionException("Failed: " + e, e); - } - } - - protected void executeReport(final Locale locale) throws MavenReportException { - try { - this.execute(this.outputDirectory, locale); - - Sink kitchenSink = getSink(); - if (kitchenSink != null) { - kitchenSink.rawText(indexHtmlContent); - } else { - writeIndexHtmlFile(outputDirectory, "index.html", indexHtmlContent); - } - } catch (Exception e) { - final MavenReportException ex = new MavenReportException(e.getMessage()); - ex.initCause(e.getCause()); - throw ex; - } - } - - /** - * Executes DOT generator. - * - * @param outputDir report output directory. - * @param locale report locale. - * @throws org.apache.maven.plugin.MojoExecutionException if there were any execution errors. - */ - protected void execute(final File outputDir, final Locale locale) throws MojoExecutionException { - - try { - runCamelEmbedded(outputDir); - } catch (DependencyResolutionRequiredException e) { - throw new MojoExecutionException("Failed: " + e, e); - } - outputDir.mkdirs(); - - List<File> files = new ArrayList<File>(); - appendFiles(files, outputDirectory); - - if (graphvizOutputTypes == null) { - if (graphvizOutputType == null) { - graphvizOutputTypes = DEFAULT_GRAPHVIZ_OUTPUT_TYPES; - } else { - graphvizOutputTypes = new String[] {graphvizOutputType}; - } - } - try { - Set<String> contextNames = new HashSet<String>(); - for (File file : files) { - String contextName = file.getParentFile().getName(); - contextNames.add(contextName); - } - - boolean multipleCamelContexts = contextNames.size() > 1; - int size = files.size(); - for (int i = 0; i < size; i++) { - File file = files.get(i); - String contextName = null; - if (multipleCamelContexts) { - contextName = file.getParentFile().getName(); - } - - getLog().info("Generating contextName: " + contextName + " file: " + file + ""); - - generate(i, file, contextName); - } - - if (multipleCamelContexts) { - // lets generate an index page which lists each indiviual - // CamelContext file - StringWriter buffer = new StringWriter(); - PrintWriter out = new PrintWriter(buffer); - - out.println("<h1>Camel Contexts</h1>"); - out.println(); - - out.println("<ul>"); - for (String contextName : contextNames) { - out.print(" <li><a href='"); - out.print(contextName); - out.print("/routes.html'>"); - out.print(contextName); - out.println("</a></li>"); - } - out.println("</ul>"); - indexHtmlContent = buffer.toString(); - } - } catch (CommandLineException e) { - throw new MojoExecutionException("Failed: " + e, e); - } catch (IOException e) { - throw new MojoExecutionException("Failed: " + e, e); - } - } - - private void generate(int index, File file, String contextName) throws CommandLineException, - MojoExecutionException, IOException { - - StringWriter buffer = new StringWriter(); - PrintWriter out = new PrintWriter(buffer); - printHtmlHeader(out, contextName); - printHtmlFileHeader(out, file); - for (String format : graphvizOutputTypes) { - String generated = convertFile(file, format); - - if (format.equals("cmapx") && generated != null) { - // lets include the generated file inside the html - addFileToBuffer(out, new File(generated)); - } - } - printHtmlFileFooter(out, file); - printHtmlFooter(out); - - String content = buffer.toString(); - String name = file.getName(); - if (name.equalsIgnoreCase("routes.dot") || index == 0) { - indexHtmlContent = content; - } - int idx = name.lastIndexOf("."); - if (idx >= 0) { - name = name.substring(0, idx); - name += ".html"; - } - writeIndexHtmlFile(file.getParentFile(), name, content); - } - - protected void runCamelEmbedded(File outputDir) throws DependencyResolutionRequiredException { - if (runCamel) { - getLog().info("Running Camel embedded to load jndi.properties file from the classpath"); - - List<?> list = project.getTestClasspathElements(); - getLog().debug("Using classpath: " + list); - - EmbeddedMojo mojo = new EmbeddedMojo(); - mojo.setClasspathElements(list); - mojo.setDotEnabled(true); - mojo.setMainClass(mainClass); - if ("true".equals(getAggregate())) { - mojo.setDotAggregationEnabled(true); - } - mojo.setOutputDirectory(outputDirectory.getAbsolutePath()); - mojo.setDuration(duration); - mojo.setLog(getLog()); - mojo.setPluginContext(getPluginContext()); - try { - mojo.executeWithoutWrapping(); - } catch (Exception e) { - getLog().error("Failed to run Camel embedded: " + e, e); - } - } - } - - protected void writeIndexHtmlFile(File dir, String fileName, String content) throws IOException { - // File dir = outputDirectory; - dir.mkdirs(); - File html = new File(dir, fileName); - PrintWriter out = null; - try { - out = new PrintWriter(new FileWriter(html)); - out.println("<html>"); - out.println("<head>"); - out.println("</head>"); - out.println("<body>"); - out.println(); - if (content == null) { - out.write("<p>No EIP diagrams available</p>"); - } else { - out.write(content); - } - out.println("</body>"); - out.println("</html>"); - } finally { - String description = "Failed to close html output file"; - close(out, description); - } - } - - protected void printHtmlHeader(PrintWriter out, String contextName) { - if (contextName != null) { - out.println("<h1>EIP Patterns for CamelContext: " + contextName + "</h1>"); - } else { - out.println("<h1>Camel EIP Patterns</h1>"); - } - out.println(); - } - - protected void printHtmlFileHeader(PrintWriter out, File file) { - out.println("<p>"); - out.println(" <img src='" + removeFileExtension(file.getName()) + ".png' usemap='#CamelRoutes'>"); - } - - protected void printHtmlFileFooter(PrintWriter out, File file) { - out.println(" </img>"); - out.println("</p>"); - out.println(); - } - - protected void printHtmlFooter(PrintWriter out) { - out.println(); - } - - protected void close(Closeable closeable, String description) { - if (closeable != null) { - try { - closeable.close(); - } catch (IOException e) { - getLog().warn(description + ": " + e); - } - } - } - - protected String convertFile(File file, String format) throws CommandLineException { - Log log = getLog(); - if (!useDot) { - log.info("DOT generation disabled"); - return null; - } - if (this.executable == null || this.executable.length() == 0) { - log.warn("Parameter <executable/> was not set in the pom.xml. Skipping conversion."); - return null; - } - - String generatedFileName = removeFileExtension(file.getAbsolutePath()) + "." + format; - Commandline cl = new Commandline(); - cl.setExecutable(executable); - cl.createArg().setValue("-T" + format); - cl.createArg().setValue("-o"); - cl.createArg().setValue(generatedFileName); - cl.createArg().setValue(file.getAbsolutePath()); - - log.debug("executing: " + cl.toString()); - - CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); - CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - - CommandLineUtils.executeCommandLine(cl, stdout, stderr); - - String output = stdout.getOutput(); - if (output.length() > 0) { - log.debug(output); - } - String errOutput = stderr.getOutput(); - if (errOutput.length() > 0) { - log.warn(errOutput); - } - return generatedFileName; - } - - protected String removeFileExtension(String name) { - int idx = name.lastIndexOf("."); - if (idx > 0) { - return name.substring(0, idx); - } else { - return name; - } - } - - private void appendFiles(List<File> output, File file) { - if (file.isDirectory()) { - appendDirectory(output, file); - } else { - if (isValid(file)) { - output.add(file); - } - } - } - - private void appendDirectory(List<File> output, File dir) { - File[] files = dir.listFiles(); - for (File file : files) { - appendFiles(output, file); - } - } - - private boolean isValid(File file) { - String name = file.getName().toLowerCase(); - return name.endsWith(".dot"); - } - - private void addFileToBuffer(PrintWriter out, File file) throws MojoExecutionException { - BufferedReader reader = null; - try { - reader = IOHelper.buffered(new FileReader(file)); - while (true) { - String line = reader.readLine(); - if (line == null) { - break; - } else { - out.println(line); - } - } - } catch (IOException e) { - throw new MojoExecutionException("Failed: " + e, e); - } finally { - close(reader, "cmapx file"); - } - } - - /** - * Gets resource bundle for given locale. - * - * @param locale locale - * @return resource bundle - */ - protected ResourceBundle getBundle(final Locale locale) { - return ResourceBundle.getBundle("camel-maven-plugin", locale, this.getClass().getClassLoader()); - } - - protected Renderer getSiteRenderer() { - return this.renderer; - } - - protected String getOutputDirectory() { - return this.outputDirectory.getAbsolutePath(); - } - - protected MavenProject getProject() { - return this.project; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/b67b6296/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/EmbeddedMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/EmbeddedMojo.java b/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/EmbeddedMojo.java index 68a7c5a..25315c0 100644 --- a/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/EmbeddedMojo.java +++ b/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/EmbeddedMojo.java @@ -51,30 +51,6 @@ public class EmbeddedMojo extends AbstractExecMojo { protected String duration; /** - * The DOT File name used to generate the DOT diagram of the route definitions - * - * @parameter default-value="${project.build.directory}/site/cameldoc/routes.dot" - * @readonly - */ - protected String outputDirectory; - - /** - * Allows the DOT file generation to be disabled - * - * @parameter property="true" - * @readonly - */ - protected boolean dotEnabled; - - /** - * Allows the routes from multiple contexts to be aggregated into one DOT file (in addition to the individual files) - * - * @parameter property="false" - * @readonly - */ - protected boolean dotAggregationEnabled; - - /** * Allows to provide a custom properties file on the classpath to initialize * a {@link javax.naming.InitialContext} object with. This corresponds to * the {@link org.apache.camel.guice.Main#setJndiProperties(String)} API @@ -128,24 +104,6 @@ public class EmbeddedMojo extends AbstractExecMojo { // Properties //------------------------------------------------------------------------- - /** - * Getter for property output directory. - * - * @return The value of output directory. - */ - public String getOutputDirectory() { - return outputDirectory; - } - - /** - * Setter for the output directory. - * - * @param inOutputDirectory The value of output directory. - */ - public void setOutputDirectory(String inOutputDirectory) { - this.outputDirectory = inOutputDirectory; - } - public List<?> getClasspathElements() { return classpathElements; } @@ -154,14 +112,6 @@ public class EmbeddedMojo extends AbstractExecMojo { this.classpathElements = classpathElements; } - public boolean isDotEnabled() { - return dotEnabled; - } - - public void setDotEnabled(boolean dotEnabled) { - this.dotEnabled = dotEnabled; - } - public String getDuration() { return duration; } @@ -170,14 +120,6 @@ public class EmbeddedMojo extends AbstractExecMojo { this.duration = duration; } - public boolean isDotAggregationEnabled() { - return dotAggregationEnabled; - } - - public void setDotAggregationEnabled(boolean dotAggregationEnabled) { - this.dotAggregationEnabled = dotAggregationEnabled; - } - public String getMainClass() { return mainClass; } @@ -215,18 +157,7 @@ public class EmbeddedMojo extends AbstractExecMojo { } protected String[] createArguments() { - List<String> args = new ArrayList<String>(5); - if (isDotEnabled()) { - args.add("-outdir"); - args.add(getOutputDirectory()); - } - - if (isDotAggregationEnabled()) { - args.add("-aggregate-dot"); - args.add("true"); - } - args.add("-duration"); args.add(getDuration());