You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/01/27 10:53:25 UTC
[1/2] camel git commit: First cut of mvn goal to generate/update
component readme.md file. Make the plugin update the existing adoc file to
keep the endpoint options up to date.
Repository: camel
Updated Branches:
refs/heads/master 126f8ffc5 -> c2614eee5
First cut of mvn goal to generate/update component readme.md file. Make the plugin update the existing adoc file to keep the endpoint options up to date.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bf4b8843
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bf4b8843
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bf4b8843
Branch: refs/heads/master
Commit: bf4b8843b4c95c69ced1e2bf2f932bb40a02d555
Parents: 126f8ff
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Jan 27 10:40:40 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jan 27 10:40:40 2016 +0100
----------------------------------------------------------------------
components/camel-ahc/src/main/docs/ahc.adoc | 54 +-----------------
.../camel/maven/packaging/PackageHelper.java | 10 ++++
.../maven/packaging/ReadmeComponentMojo.java | 58 +++++++++++++++++---
.../src/main/resources/endpoint-options.mvel | 11 ++--
4 files changed, 69 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/bf4b8843/components/camel-ahc/src/main/docs/ahc.adoc
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/main/docs/ahc.adoc b/components/camel-ahc/src/main/docs/ahc.adoc
index e5c1b14..2a37109 100644
--- a/components/camel-ahc/src/main/docs/ahc.adoc
+++ b/components/camel-ahc/src/main/docs/ahc.adoc
@@ -43,58 +43,8 @@ You can append query options to the URI in the following format,
AhcEndpoint Options
^^^^^^^^^^^^^^^^^^^
-[width="100%",cols="10%,10%,80%",options="header",]
-|=======================================================================
-|Name |Default Value |Description
-|`throwExceptionOnFailure` |`true` |Option to disable throwing the `AhcOperationFailedException` in case of
-failed responses from the remote server. This allows you to get all
-responses regardless of the HTTP status code.
-
-|`bridgeEndpoint` |`false` |If the option is true, then the Exchange.HTTP_URI header is ignored, and
-use the endpoint's URI for request. You may also set the
-*throwExcpetionOnFailure* to be false to let the AhcProducer send all
-the fault response back.
-
-|`transferException` |`false` |If enabled and an link:exchange.html[Exchange] failed processing on the
-consumer side, and if the caused `Exception` was send back serialized in
-the response as a `application/x-java-serialized-object` content type
-(for example using link:jetty.html[Jetty] or link:servlet.html[Servlet]
-Camel components). On the producer side the exception will be
-deserialized and thrown as is, instead of the
-`AhcOperationFailedException`. The caused exception is required to be
-serialized.
-
-|`client` |`null` |To use a custom `com.ning.http.client.AsyncHttpClient`.
-
-|`clientConfig` |`null` |To configure the `AsyncHttpClient` to use a custom
-`com.ning.http.client.AsyncHttpClientConfig` instance. This instance
-replaces any instance configured at the component level.
-
-|`clientConfig.x` |`null` |To configure additional properties of the
-`com.ning.http.client.AsyncHttpClientConfig` instance used by the
-endpoint. Note that configuration options set using this parameter will
-be merged with those set using the `clientConfig` parameter or the
-instance set at the component level with properties set using this
-parameter taking priority.
-
-|`clientConfig.realm.x` |`null` |*Camel 2.11:* To configure realm properties of the
-`com.ning.http.client.AsyncHttpClientConfig` The options which can be
-used are the options from `com.ning.http.client.Realm.RealmBuilder`. eg
-to set scheme, you can configure `"clientConfig.realm.scheme=DIGEST"`
-
-|`binding` |`null` |To use a custom `org.apache.camel.component.ahc.AhcBinding`.
-
-|`sslContextParameters` |`null` | *Camel 2.9:* Reference to a
-`org.apache.camel.util.jsse.SSLContextParameters` in the
-link:registry.html[Registry]. This reference overrides any configured
-SSLContextParameters at the component level. See link:ahc.html[Using
-the JSSE Configuration Utility]. Note that configuring this option will
-override any SSL/TLS configuration options provided through the
-clientConfig option at the endpoint or component level.
-
-|`bufferSize` |`4096` | *Camel 2.10.3:* The initial in-memory buffer size used when transferring
-data between Camel and AHC Client.
-|=======================================================================
+//// endpoint options: START
+//// endpoint options: END
[[AHC-AhcComponentOptions]]
AhcComponent Options
http://git-wip-us.apache.org/repos/asf/camel/blob/bf4b8843/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
index 02e00e4..c84768f 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
@@ -19,6 +19,7 @@ package org.apache.camel.maven.packaging;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -83,6 +84,15 @@ public final class PackageHelper {
}
}
+ public static void writeText(File file, String text) throws IOException {
+ FileOutputStream fos = new FileOutputStream(file, false);
+ try {
+ fos.write(text.getBytes());
+ } finally {
+ fos.close();
+ }
+ }
+
public static String after(String text, String after) {
if (!text.contains(after)) {
return null;
http://git-wip-us.apache.org/repos/asf/camel/blob/bf4b8843/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ReadmeComponentMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ReadmeComponentMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ReadmeComponentMojo.java
index 5953ee9..09a7811 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ReadmeComponentMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ReadmeComponentMojo.java
@@ -34,12 +34,12 @@ import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
-
import org.mvel2.templates.TemplateRuntime;
import org.sonatype.plexus.build.incremental.BuildContext;
import static org.apache.camel.maven.packaging.JSonSchemaHelper.getSafeValue;
import static org.apache.camel.maven.packaging.PackageHelper.loadText;
+import static org.apache.camel.maven.packaging.PackageHelper.writeText;
/**
* Generate or updates the component readme.md file in the project root directory.
@@ -58,13 +58,20 @@ public class ReadmeComponentMojo extends AbstractMojo {
protected MavenProject project;
/**
- * The output directory for generated readme file
+ * The project build directory
*
* @parameter default-value="${project.build.directory}"
*/
protected File buildDir;
/**
+ * The documentation directory
+ *
+ * @parameter default-value="${basedir}/src/main/docs"
+ */
+ protected File docDir;
+
+ /**
* build context to check changed files and mark them for refresh (used for
* m2e compatibility)
*
@@ -81,26 +88,63 @@ public class ReadmeComponentMojo extends AbstractMojo {
final Set<File> jsonFiles = new TreeSet<File>();
PackageHelper.findJsonFiles(buildDir, jsonFiles, new PackageHelper.CamelComponentsModelFilter());
- // only if there is components we should create/update the readme file
+ // only if there is components we should update the documentation files
if (!componentNames.isEmpty()) {
getLog().info("Found " + componentNames.size() + " components");
- File readmeFile = initReadMeFile();
for (String componentName : componentNames) {
String json = loadComponentJson(jsonFiles, componentName);
if (json != null) {
+
+ // file
+ File file = new File(docDir, componentName + ".adoc");
+
ComponentModel model = generateComponentModel(componentName, json);
String header = templateComponentHeader(model);
String options = templateComponentOptions(model);
String options2 = templateEndpointOptions(model);
- getLog().info(header);
- getLog().info(options);
- getLog().info(options2);
+
+// getLog().info(header);
+// getLog().info(options);
+// getLog().info(options2);
+
+ // update the endpoint options
+ updateEndpointOptions(file, options2);
}
}
}
}
+ private void updateEndpointOptions(File file, String changed) throws MojoExecutionException {
+ if (!file.exists()) {
+ return;
+ }
+
+ try {
+ String text = loadText(new FileInputStream(file));
+
+ String existing = StringHelper.between(text, "//// endpoint options: START", "//// endpoint options: END");
+ if (existing != null) {
+ if (existing.equals(changed)) {
+ getLog().info("No changes to file: " + file);
+ } else {
+ getLog().info("Updating file: " + file);
+ String before = StringHelper.before(text, "//// endpoint options: START");
+ String after = StringHelper.after(text, "//// endpoint options: END");
+ text = before + changed + after;
+ writeText(file, text);
+ }
+ } else {
+ getLog().warn("Cannot find markers in file " + file);
+ getLog().warn("Add the following markers");
+ getLog().warn("\t//// endpoint options: START");
+ getLog().warn("\t//// endpoint options: END");
+ }
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error reading file " + file + " Reason: " + e, e);
+ }
+ }
+
private String loadComponentJson(Set<File> jsonFiles, String componentName) {
try {
for (File file : jsonFiles) {
http://git-wip-us.apache.org/repos/asf/camel/blob/bf4b8843/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel b/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
index b7f10b3..51e6821 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
+++ b/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
@@ -1,8 +1,9 @@
-### Endpoint options
-
+//// endpoint options: START
The @{title} component supports @{endpointOptions.size()} endpoint options which are listed below:
+[width="100%",cols="10%,5%,5%,10%,5%,65%",options="header",]
+|=======================================================================
| Name | Group | Required | Default | Java Type | Description |
-| ---- | ----- | -------- | ------- | --------- | ----------- |
-@foreach{row : endpointOptions}| @{row.name} | @{row.group} | @{row.required} | @{row.defaultValue} | @{row.shortJavaType} | @{row.description} |
-@end{}
+@foreach{row : endpointOptions}| `@{row.name}` | `@{row.group}` | `@{row.required}` | `@{row.defaultValue}` | `@{row.shortJavaType}` | @{row.description} |
+@end{}|=======================================================================
+//// endpoint options: END
\ No newline at end of file
[2/2] camel git commit: First cut of mvn goal to generate/update
component readme.md file. Make the plugin update the existing adoc file to
keep the endpoint options up to date.
Posted by da...@apache.org.
First cut of mvn goal to generate/update component readme.md file. Make the plugin update the existing adoc file to keep the endpoint options up to date.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c2614eee
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c2614eee
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c2614eee
Branch: refs/heads/master
Commit: c2614eee53312a6d2038265f3c136be2902656c9
Parents: bf4b884
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Jan 27 10:53:15 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jan 27 10:53:15 2016 +0100
----------------------------------------------------------------------
components/camel-ahc/src/main/docs/ahc.adoc | 22 +++++++++++++++++++-
.../maven/packaging/ReadmeComponentMojo.java | 5 ++++-
.../src/main/resources/endpoint-options.mvel | 2 --
3 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/c2614eee/components/camel-ahc/src/main/docs/ahc.adoc
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/main/docs/ahc.adoc b/components/camel-ahc/src/main/docs/ahc.adoc
index 2a37109..1ed462a 100644
--- a/components/camel-ahc/src/main/docs/ahc.adoc
+++ b/components/camel-ahc/src/main/docs/ahc.adoc
@@ -44,7 +44,27 @@ AhcEndpoint Options
^^^^^^^^^^^^^^^^^^^
//// endpoint options: START
-//// endpoint options: END
+The AHC component supports 12 endpoint options which are listed below:
+
+[width="100%",cols="10%,5%,5%,10%,5%,65%",options="header",]
+|=======================================================================
+| Name | Group | Required | Default | Java Type | Description |
+| `httpUri` | `producer` | `true` | `` | `URI` | The URI to use such as http://hostname:port/path |
+| `binding` | `producer` | `` | `` | `AhcBinding` | To use a custom AhcBinding which allows to control how to bind between AHC and Camel. |
+| `bridgeEndpoint` | `producer` | `` | `false` | `boolean` | If the option is true then the Exchange.HTTP_URI header is ignored and use the endpoint's URI for request. You may also set the throwExceptionOnFailure to be false to let the AhcProducer send all the fault response back. |
+| `bufferSize` | `producer` | `` | `4096` | `int` | The initial in-memory buffer size used when transferring data between Camel and AHC Client. |
+| `headerFilterStrategy` | `producer` | `` | `` | `HeaderFilterStrategy` | To use a custom HeaderFilterStrategy to filter header to and from Camel message. |
+| `throwExceptionOnFailure` | `producer` | `` | `true` | `boolean` | Option to disable throwing the AhcOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code. |
+| `transferException` | `producer` | `` | `false` | `boolean` | If enabled and an Exchange failed processing on the consumer side and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type (for example using Jetty or Servlet Camel components). On the producer side the exception will be deserialized and thrown as is instead of the AhcOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk. |
+| `clientConfig` | `advanced` | `` | `` | `AsyncHttpClientConfig` | To configure the AsyncHttpClient to use a custom com.ning.http.client.AsyncHttpClientConfig instance. |
+| `clientConfigOptions` | `advanced` | `` | `` | `Object>` | To configure the AsyncHttpClientConfig using the key/values from the Map. |
+| `exchangePattern` | `advanced` | `` | `InOnly` | `ExchangePattern` | Sets the default exchange pattern when creating an exchange |
+| `synchronous` | `advanced` | `` | `false` | `boolean` | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). |
+| `sslContextParameters` | `security` | `` | `` | `SSLContextParameters` | Reference to a org.apache.camel.util.jsse.SSLContextParameters in the Registry. This reference overrides any configured SSLContextParameters at the component level. See Using the JSSE Configuration Utility. Note that configuring this option will override any SSL/TLS configuration options provided through the clientConfig option at the endpoint or component level. |
+|=======================================================================//// endpoint options: END
+
+
+
[[AHC-AhcComponentOptions]]
AhcComponent Options
http://git-wip-us.apache.org/repos/asf/camel/blob/c2614eee/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ReadmeComponentMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ReadmeComponentMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ReadmeComponentMojo.java
index 09a7811..78acfb0 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ReadmeComponentMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ReadmeComponentMojo.java
@@ -125,13 +125,16 @@ public class ReadmeComponentMojo extends AbstractMojo {
String existing = StringHelper.between(text, "//// endpoint options: START", "//// endpoint options: END");
if (existing != null) {
+ // remove leading line breaks etc
+ existing = existing.trim();
+ changed = changed.trim();
if (existing.equals(changed)) {
getLog().info("No changes to file: " + file);
} else {
getLog().info("Updating file: " + file);
String before = StringHelper.before(text, "//// endpoint options: START");
String after = StringHelper.after(text, "//// endpoint options: END");
- text = before + changed + after;
+ text = before + "//// endpoint options: START\n" + changed + "//// endpoint options: END\n" + after;
writeText(file, text);
}
} else {
http://git-wip-us.apache.org/repos/asf/camel/blob/c2614eee/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel b/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
index 51e6821..4cc4b9b 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
+++ b/tooling/maven/camel-package-maven-plugin/src/main/resources/endpoint-options.mvel
@@ -1,4 +1,3 @@
-//// endpoint options: START
The @{title} component supports @{endpointOptions.size()} endpoint options which are listed below:
[width="100%",cols="10%,5%,5%,10%,5%,65%",options="header",]
@@ -6,4 +5,3 @@ The @{title} component supports @{endpointOptions.size()} endpoint options which
| Name | Group | Required | Default | Java Type | Description |
@foreach{row : endpointOptions}| `@{row.name}` | `@{row.group}` | `@{row.required}` | `@{row.defaultValue}` | `@{row.shortJavaType}` | @{row.description} |
@end{}|=======================================================================
-//// endpoint options: END
\ No newline at end of file