This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch CAMEL-13870
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/CAMEL-13870 by this push:
new 58f5416 CAMEL-13870: Fast property configuration of Camel endpoints.
Work in progress.
58f5416 is described below
commit 58f5416e2e29a4748992d1cbeaa57bf71830a25d
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Aug 21 22:17:41 2019 +0200
CAMEL-13870: Fast property configuration of Camel endpoints. Work in
progress.
---
.../camel/component/activemq/ActiveMQEndpoint.java | 2 +-
.../apache/camel/component/amqp/AMQPEndpoint.java | 3 +--
.../camel-ftp/src/main/docs/ftp-component.adoc | 2 +-
.../camel-ftp/src/main/docs/ftps-component.adoc | 2 +-
.../camel-ftp/src/main/docs/sftp-component.adoc | 2 +-
.../docs/google-calendar-stream-component.adoc | 2 +-
.../main/docs/google-mail-stream-component.adoc | 2 +-
.../main/docs/google-sheets-stream-component.adoc | 2 +-
.../endpoint/dsl/FtpEndpointBuilderFactory.java | 20 +--------------
.../endpoint/dsl/FtpsEndpointBuilderFactory.java | 20 +--------------
.../endpoint/dsl/SftpEndpointBuilderFactory.java | 20 +--------------
.../camel/tools/apt/AnnotationProcessorHelper.java | 1 +
.../tools/apt/EndpointAnnotationProcessor.java | 13 +++++++++-
.../apt/EndpointPropertyConfigurerGenerator.java | 30 ++++++++++++++++++++++
14 files changed, 54 insertions(+), 67 deletions(-)
diff --git
a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java
b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java
index 32a61f0..29f9dab 100644
---
a/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java
+++
b/components/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQEndpoint.java
@@ -24,7 +24,7 @@ import org.apache.camel.spi.UriEndpoint;
* Apache ActiveMQ. This component extends the Camel JMS component.
*/
@UriEndpoint(firstVersion = "1.0.0", extendsScheme = "jms", scheme =
"activemq", title = "ActiveMQ", syntax =
"activemq:destinationType:destinationName",
- label = "messaging", generateConfigurer = false)
+ label = "messaging")
public class ActiveMQEndpoint extends JmsEndpoint {
// needed for component documentation
diff --git
a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPEndpoint.java
b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPEndpoint.java
index 210956c..cd69c48 100644
---
a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPEndpoint.java
+++
b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPEndpoint.java
@@ -17,7 +17,6 @@
package org.apache.camel.component.amqp;
import org.apache.camel.AsyncEndpoint;
-import org.apache.camel.component.jms.JmsConsumer;
import org.apache.camel.component.jms.JmsEndpoint;
import org.apache.camel.spi.UriEndpoint;
@@ -28,7 +27,7 @@ import org.apache.camel.spi.UriEndpoint;
* performing the AMQP connectivity.
*/
@UriEndpoint(firstVersion = "1.2.0", scheme = "amqp", extendsScheme = "jms",
title = "AMQP",
- syntax = "amqp:destinationType:destinationName", label = "messaging",
generateConfigurer = false)
+ syntax = "amqp:destinationType:destinationName", label = "messaging")
public class AMQPEndpoint extends JmsEndpoint implements AsyncEndpoint {
}
diff --git a/components/camel-ftp/src/main/docs/ftp-component.adoc
b/components/camel-ftp/src/main/docs/ftp-component.adoc
index 93cf17b..6bde732 100644
--- a/components/camel-ftp/src/main/docs/ftp-component.adoc
+++ b/components/camel-ftp/src/main/docs/ftp-component.adoc
@@ -206,7 +206,7 @@ with the following path and query parameters:
| *initialDelay* (scheduler) | Milliseconds before the first poll starts. You
can also specify time values using units, such as 60s (60 seconds), 5m30s (5
minutes and 30 seconds), and 1h (1 hour). | 1000 | long
| *runLoggingLevel* (scheduler) | The consumer logs a start/complete log line
when it polls. This option allows you to configure the logging level for that.
| TRACE | LoggingLevel
| *scheduledExecutorService* (scheduler) | Allows for configuring a
custom/shared thread pool to use for the consumer. By default each consumer has
its own single threaded thread pool. | | ScheduledExecutor Service
-| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | ScheduledPollConsumer Scheduler
+| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | String
| *schedulerProperties* (scheduler) | To configure additional properties when
using a custom scheduler or any of the Quartz, Spring based scheduler. | | Map
| *startScheduler* (scheduler) | Whether the scheduler should be auto started.
| true | boolean
| *timeUnit* (scheduler) | Time unit for initialDelay and delay options. |
MILLISECONDS | TimeUnit
diff --git a/components/camel-ftp/src/main/docs/ftps-component.adoc
b/components/camel-ftp/src/main/docs/ftps-component.adoc
index 7f65dee..d1ab94b 100644
--- a/components/camel-ftp/src/main/docs/ftps-component.adoc
+++ b/components/camel-ftp/src/main/docs/ftps-component.adoc
@@ -165,7 +165,7 @@ with the following path and query parameters:
| *initialDelay* (scheduler) | Milliseconds before the first poll starts. You
can also specify time values using units, such as 60s (60 seconds), 5m30s (5
minutes and 30 seconds), and 1h (1 hour). | 1000 | long
| *runLoggingLevel* (scheduler) | The consumer logs a start/complete log line
when it polls. This option allows you to configure the logging level for that.
| TRACE | LoggingLevel
| *scheduledExecutorService* (scheduler) | Allows for configuring a
custom/shared thread pool to use for the consumer. By default each consumer has
its own single threaded thread pool. | | ScheduledExecutor Service
-| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | ScheduledPollConsumer Scheduler
+| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | String
| *schedulerProperties* (scheduler) | To configure additional properties when
using a custom scheduler or any of the Quartz, Spring based scheduler. | | Map
| *startScheduler* (scheduler) | Whether the scheduler should be auto started.
| true | boolean
| *timeUnit* (scheduler) | Time unit for initialDelay and delay options. |
MILLISECONDS | TimeUnit
diff --git a/components/camel-ftp/src/main/docs/sftp-component.adoc
b/components/camel-ftp/src/main/docs/sftp-component.adoc
index 048b5fd..4594b34 100644
--- a/components/camel-ftp/src/main/docs/sftp-component.adoc
+++ b/components/camel-ftp/src/main/docs/sftp-component.adoc
@@ -161,7 +161,7 @@ with the following path and query parameters:
| *initialDelay* (scheduler) | Milliseconds before the first poll starts. You
can also specify time values using units, such as 60s (60 seconds), 5m30s (5
minutes and 30 seconds), and 1h (1 hour). | 1000 | long
| *runLoggingLevel* (scheduler) | The consumer logs a start/complete log line
when it polls. This option allows you to configure the logging level for that.
| TRACE | LoggingLevel
| *scheduledExecutorService* (scheduler) | Allows for configuring a
custom/shared thread pool to use for the consumer. By default each consumer has
its own single threaded thread pool. | | ScheduledExecutor Service
-| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | ScheduledPollConsumer Scheduler
+| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | String
| *schedulerProperties* (scheduler) | To configure additional properties when
using a custom scheduler or any of the Quartz, Spring based scheduler. | | Map
| *startScheduler* (scheduler) | Whether the scheduler should be auto started.
| true | boolean
| *timeUnit* (scheduler) | Time unit for initialDelay and delay options. |
MILLISECONDS | TimeUnit
diff --git
a/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc
b/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc
index 68d5914..9054ea2 100644
---
a/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc
+++
b/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc
@@ -111,7 +111,7 @@ with the following path and query parameters:
| *initialDelay* (scheduler) | Milliseconds before the first poll starts. You
can also specify time values using units, such as 60s (60 seconds), 5m30s (5
minutes and 30 seconds), and 1h (1 hour). | 1000 | long
| *runLoggingLevel* (scheduler) | The consumer logs a start/complete log line
when it polls. This option allows you to configure the logging level for that.
| TRACE | LoggingLevel
| *scheduledExecutorService* (scheduler) | Allows for configuring a
custom/shared thread pool to use for the consumer. By default each consumer has
its own single threaded thread pool. | | ScheduledExecutor Service
-| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | ScheduledPollConsumer Scheduler
+| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | String
| *schedulerProperties* (scheduler) | To configure additional properties when
using a custom scheduler or any of the Quartz, Spring based scheduler. | | Map
| *startScheduler* (scheduler) | Whether the scheduler should be auto started.
| true | boolean
| *timeUnit* (scheduler) | Time unit for initialDelay and delay options. |
MILLISECONDS | TimeUnit
diff --git
a/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc
b/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc
index b40b8fd..9f7554b 100644
---
a/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc
+++
b/components/camel-google-mail/src/main/docs/google-mail-stream-component.adoc
@@ -107,7 +107,7 @@ with the following path and query parameters:
| *initialDelay* (scheduler) | Milliseconds before the first poll starts. You
can also specify time values using units, such as 60s (60 seconds), 5m30s (5
minutes and 30 seconds), and 1h (1 hour). | 1000 | long
| *runLoggingLevel* (scheduler) | The consumer logs a start/complete log line
when it polls. This option allows you to configure the logging level for that.
| TRACE | LoggingLevel
| *scheduledExecutorService* (scheduler) | Allows for configuring a
custom/shared thread pool to use for the consumer. By default each consumer has
its own single threaded thread pool. | | ScheduledExecutor Service
-| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | ScheduledPollConsumer Scheduler
+| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | String
| *schedulerProperties* (scheduler) | To configure additional properties when
using a custom scheduler or any of the Quartz, Spring based scheduler. | | Map
| *startScheduler* (scheduler) | Whether the scheduler should be auto started.
| true | boolean
| *timeUnit* (scheduler) | Time unit for initialDelay and delay options. |
MILLISECONDS | TimeUnit
diff --git
a/components/camel-google-sheets/src/main/docs/google-sheets-stream-component.adoc
b/components/camel-google-sheets/src/main/docs/google-sheets-stream-component.adoc
index 9693dcc..6c1ded1 100644
---
a/components/camel-google-sheets/src/main/docs/google-sheets-stream-component.adoc
+++
b/components/camel-google-sheets/src/main/docs/google-sheets-stream-component.adoc
@@ -113,7 +113,7 @@ with the following path and query parameters:
| *initialDelay* (scheduler) | Milliseconds before the first poll starts. You
can also specify time values using units, such as 60s (60 seconds), 5m30s (5
minutes and 30 seconds), and 1h (1 hour). | 1000 | long
| *runLoggingLevel* (scheduler) | The consumer logs a start/complete log line
when it polls. This option allows you to configure the logging level for that.
| TRACE | LoggingLevel
| *scheduledExecutorService* (scheduler) | Allows for configuring a
custom/shared thread pool to use for the consumer. By default each consumer has
its own single threaded thread pool. | | ScheduledExecutor Service
-| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | ScheduledPollConsumer Scheduler
+| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring
or camel-quartz component | none | String
| *schedulerProperties* (scheduler) | To configure additional properties when
using a custom scheduler or any of the Quartz, Spring based scheduler. | | Map
| *startScheduler* (scheduler) | Whether the scheduler should be auto started.
| true | boolean
| *timeUnit* (scheduler) | Time unit for initialDelay and delay options. |
MILLISECONDS | TimeUnit
diff --git
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/FtpEndpointBuilderFactory.java
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/FtpEndpointBuilderFactory.java
index c89c932..ab03dc5 100644
---
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/FtpEndpointBuilderFactory.java
+++
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/FtpEndpointBuilderFactory.java
@@ -32,7 +32,6 @@ import
org.apache.camel.builder.endpoint.AbstractEndpointBuilder;
import org.apache.camel.spi.ExceptionHandler;
import org.apache.camel.spi.IdempotentRepository;
import org.apache.camel.spi.PollingConsumerPollStrategy;
-import org.apache.camel.spi.ScheduledPollConsumerScheduler;
/**
* The ftp component is used for uploading or downloading files from FTP
@@ -1639,24 +1638,7 @@ public interface FtpEndpointBuilderFactory {
* To use a cron scheduler from either camel-spring or camel-quartz
* component.
*
- * The option is a:
- * <code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code>
- * type.
- *
- * Group: scheduler
- */
- default FtpEndpointConsumerBuilder scheduler(
- ScheduledPollConsumerScheduler scheduler) {
- setProperty("scheduler", scheduler);
- return this;
- }
- /**
- * To use a cron scheduler from either camel-spring or camel-quartz
- * component.
- *
- * The option will be converted to a
- * <code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code>
- * type.
+ * The option is a: <code>java.lang.String</code> type.
*
* Group: scheduler
*/
diff --git
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/FtpsEndpointBuilderFactory.java
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/FtpsEndpointBuilderFactory.java
index 5558b87..5d903df 100644
---
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/FtpsEndpointBuilderFactory.java
+++
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/FtpsEndpointBuilderFactory.java
@@ -32,7 +32,6 @@ import
org.apache.camel.builder.endpoint.AbstractEndpointBuilder;
import org.apache.camel.spi.ExceptionHandler;
import org.apache.camel.spi.IdempotentRepository;
import org.apache.camel.spi.PollingConsumerPollStrategy;
-import org.apache.camel.spi.ScheduledPollConsumerScheduler;
/**
* The ftps (FTP secure SSL/TLS) component is used for uploading or downloading
@@ -1641,24 +1640,7 @@ public interface FtpsEndpointBuilderFactory {
* To use a cron scheduler from either camel-spring or camel-quartz
* component.
*
- * The option is a:
- * <code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code>
- * type.
- *
- * Group: scheduler
- */
- default FtpsEndpointConsumerBuilder scheduler(
- ScheduledPollConsumerScheduler scheduler) {
- setProperty("scheduler", scheduler);
- return this;
- }
- /**
- * To use a cron scheduler from either camel-spring or camel-quartz
- * component.
- *
- * The option will be converted to a
- * <code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code>
- * type.
+ * The option is a: <code>java.lang.String</code> type.
*
* Group: scheduler
*/
diff --git
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SftpEndpointBuilderFactory.java
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SftpEndpointBuilderFactory.java
index eb6be50..aa7389b 100644
---
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SftpEndpointBuilderFactory.java
+++
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SftpEndpointBuilderFactory.java
@@ -33,7 +33,6 @@ import
org.apache.camel.builder.endpoint.AbstractEndpointBuilder;
import org.apache.camel.spi.ExceptionHandler;
import org.apache.camel.spi.IdempotentRepository;
import org.apache.camel.spi.PollingConsumerPollStrategy;
-import org.apache.camel.spi.ScheduledPollConsumerScheduler;
/**
* The sftp (FTP over SSH) component is used for uploading or downloading files
@@ -1643,24 +1642,7 @@ public interface SftpEndpointBuilderFactory {
* To use a cron scheduler from either camel-spring or camel-quartz
* component.
*
- * The option is a:
- * <code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code>
- * type.
- *
- * Group: scheduler
- */
- default SftpEndpointConsumerBuilder scheduler(
- ScheduledPollConsumerScheduler scheduler) {
- setProperty("scheduler", scheduler);
- return this;
- }
- /**
- * To use a cron scheduler from either camel-spring or camel-quartz
- * component.
- *
- * The option will be converted to a
- * <code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code>
- * type.
+ * The option is a: <code>java.lang.String</code> type.
*
* Group: scheduler
*/
diff --git
a/tooling/apt/src/main/java/org/apache/camel/tools/apt/AnnotationProcessorHelper.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/AnnotationProcessorHelper.java
index ea63522..4b824ad 100644
---
a/tooling/apt/src/main/java/org/apache/camel/tools/apt/AnnotationProcessorHelper.java
+++
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/AnnotationProcessorHelper.java
@@ -325,6 +325,7 @@ public final class AnnotationProcessorHelper {
try {
Filer filer = processingEnv.getFiler();
FileObject resource =
filer.createResource(StandardLocation.CLASS_OUTPUT, packageName, fileName);
+ log(processingEnv, "Writing file: " + packageName + "/" +
fileName);
try (Writer w = resource.openWriter(); PrintWriter writer = new
PrintWriter(w)) {
handler.accept(writer);
}
diff --git
a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
index 368bec5..518bb55 100644
---
a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
+++
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
@@ -173,7 +173,18 @@ public class EndpointAnnotationProcessor extends
AbstractCamelAnnotationProcesso
String json = createParameterJsonSchema(componentModel,
componentOptions, endpointPaths, endpointOptions, schemes, parentData);
writer.println(json);
- if (uriEndpoint.generateConfigurer()) {
+ // special for activemq and amqp scheme which should reuse jms
+ if ("activemq".equals(scheme) || "amqp".equals(scheme)) {
+ TypeElement parent = findTypeElement(processingEnv, roundEnv,
"org.apache.camel.component.jms.JmsEndpointConfigurer");
+ String fqen = classElement.getQualifiedName().toString();
+ String pn = fqen.substring(0, fqen.lastIndexOf('.'));
+ String en = classElement.getSimpleName().toString();
+ String cn = en + "Configurer";
+ String fqn = pn + "." + cn;
+
+
EndpointPropertyConfigurerGenerator.generateExtendConfigurer(processingEnv,
parent, pn, cn, fqn);
+
EndpointPropertyConfigurerGenerator.generateMetaInfConfigurer(processingEnv,
componentModel.getScheme() + "-endpoint", fqn);
+ } else if (uriEndpoint.generateConfigurer() &&
!endpointOptions.isEmpty()) {
TypeElement parent = findTypeElement(processingEnv, roundEnv,
"org.apache.camel.support.component.EndpointPropertyConfigurerSupport");
String fqen = classElement.getQualifiedName().toString();
String pn = fqen.substring(0, fqen.lastIndexOf('.'));
diff --git
a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java
index 477dc9c..7aa8661 100644
---
a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java
+++
b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java
@@ -38,6 +38,36 @@ public final class EndpointPropertyConfigurerGenerator {
private EndpointPropertyConfigurerGenerator() {
}
+ public static void generateExtendConfigurer(ProcessingEnvironment
processingEnv, TypeElement parent,
+ String pn, String cn, String
fqn) {
+
+
+
+ Writer w = null;
+ try {
+ JavaFileObject src =
processingEnv.getFiler().createSourceFile(fqn, parent);
+ w = src.openWriter();
+
+ w.write("/* Generated by org.apache.camel:apt */\n");
+ w.write("package " + pn + ";\n");
+ w.write("\n");
+ w.write("import " + parent.getQualifiedName().toString() + ";\n");
+ w.write("\n");
+ w.write("/**\n");
+ w.write(" * Source code generated by org.apache.camel:apt\n");
+ w.write(" */\n");
+ w.write("public class " + cn + " extends " +
parent.getSimpleName().toString() + " {\n");
+ w.write("\n");
+ w.write("}\n");
+ w.write("\n");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
"Unable to generate source code file: " + fqn + ": " + e.getMessage());
+ dumpExceptionToErrorFile("camel-apt-error.log", "Unable to
generate source code file: " + fqn, e);
+ } finally {
+ IOHelper.close(w);
+ }
+ }
+
public static void generatePropertyConfigurer(ProcessingEnvironment
processingEnv, TypeElement parent,
String pn, String cn, String
fqn, String en, String fqen,
Set<EndpointOption> options)
{