Skip to content

Commit

Permalink
Duration (#1102)
Browse files Browse the repository at this point in the history
CAMEL-20542: spring boot auto-configuration should not type convert java.time objects.
  • Loading branch information
davsclaus committed Mar 8, 2024
1 parent de8b0d9 commit e7286fa
Show file tree
Hide file tree
Showing 28 changed files with 47 additions and 74 deletions.
Expand Up @@ -128,7 +128,7 @@
{
"name": "camel.component.aws2-cw.timestamp",
"type": "java.time.Instant",
"description": "The metric timestamp. The option is a java.time.Instant type.",
"description": "The metric timestamp",
"sourceType": "org.apache.camel.component.aws2.cw.springboot.Cw2ComponentConfiguration"
},
{
Expand Down
Expand Up @@ -71,7 +71,7 @@ public class Cw2ComponentConfiguration
*/
private String region;
/**
* The metric timestamp. The option is a java.time.Instant type.
* The metric timestamp
*/
private Instant timestamp;
/**
Expand Down
Expand Up @@ -40,7 +40,6 @@ public class Cw2ComponentConverter implements GenericConverter {
public Set<ConvertiblePair> getConvertibleTypes() {
Set<ConvertiblePair> answer = new LinkedHashSet<>();
answer.add(new ConvertiblePair(String.class, org.apache.camel.component.aws2.cw.Cw2Configuration.class));
answer.add(new ConvertiblePair(String.class, java.time.Instant.class));
answer.add(new ConvertiblePair(String.class, software.amazon.awssdk.services.cloudwatch.CloudWatchClient.class));
return answer;
}
Expand All @@ -59,7 +58,6 @@ public Object convert(
ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1);
switch (targetType.getName()) {
case "org.apache.camel.component.aws2.cw.Cw2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.cw.Cw2Configuration.class);
case "java.time.Instant": return applicationContext.getBean(ref, java.time.Instant.class);
case "software.amazon.awssdk.services.cloudwatch.CloudWatchClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.cloudwatch.CloudWatchClient.class);
}
return null;
Expand Down
Expand Up @@ -110,7 +110,7 @@
{
"name": "camel.component.azure-servicebus.max-auto-lock-renew-duration",
"type": "java.time.Duration",
"description": "Sets the amount of time to continue auto-renewing the lock. Setting ZERO disables auto-renewal. For ServiceBus receive mode (RECEIVE_AND_DELETE RECEIVE_AND_DELETE), auto-renewal is disabled. The option is a java.time.Duration type.",
"description": "Sets the amount of time to continue auto-renewing the lock. Setting ZERO disables auto-renewal. For ServiceBus receive mode (RECEIVE_AND_DELETE RECEIVE_AND_DELETE), auto-renewal is disabled.",
"sourceType": "org.apache.camel.component.azure.servicebus.springboot.ServiceBusComponentConfiguration"
},
{
Expand Down Expand Up @@ -153,7 +153,7 @@
{
"name": "camel.component.azure-servicebus.scheduled-enqueue-time",
"type": "java.time.OffsetDateTime",
"description": "Sets OffsetDateTime at which the message should appear in the Service Bus queue or topic. The option is a java.time.OffsetDateTime type.",
"description": "Sets OffsetDateTime at which the message should appear in the Service Bus queue or topic.",
"sourceType": "org.apache.camel.component.azure.servicebus.springboot.ServiceBusComponentConfiguration"
},
{
Expand Down
Expand Up @@ -113,8 +113,7 @@ public class ServiceBusComponentConfiguration
/**
* Sets the amount of time to continue auto-renewing the lock. Setting ZERO
* disables auto-renewal. For ServiceBus receive mode (RECEIVE_AND_DELETE
* RECEIVE_AND_DELETE), auto-renewal is disabled. The option is a
* java.time.Duration type.
* RECEIVE_AND_DELETE), auto-renewal is disabled.
*/
private Duration maxAutoLockRenewDuration;
/**
Expand Down Expand Up @@ -178,7 +177,7 @@ public class ServiceBusComponentConfiguration
private ServiceBusProducerOperationDefinition producerOperation = ServiceBusProducerOperationDefinition.sendMessages;
/**
* Sets OffsetDateTime at which the message should appear in the Service Bus
* queue or topic. The option is a java.time.OffsetDateTime type.
* queue or topic.
*/
private OffsetDateTime scheduledEnqueueTime;
/**
Expand Down
Expand Up @@ -43,9 +43,7 @@ public Set<ConvertiblePair> getConvertibleTypes() {
answer.add(new ConvertiblePair(String.class, com.azure.core.util.ClientOptions.class));
answer.add(new ConvertiblePair(String.class, org.apache.camel.component.azure.servicebus.ServiceBusConfiguration.class));
answer.add(new ConvertiblePair(String.class, com.azure.core.amqp.ProxyOptions.class));
answer.add(new ConvertiblePair(String.class, java.time.Duration.class));
answer.add(new ConvertiblePair(String.class, com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient.class));
answer.add(new ConvertiblePair(String.class, java.time.OffsetDateTime.class));
answer.add(new ConvertiblePair(String.class, com.azure.messaging.servicebus.ServiceBusSenderAsyncClient.class));
answer.add(new ConvertiblePair(String.class, com.azure.messaging.servicebus.ServiceBusTransactionContext.class));
answer.add(new ConvertiblePair(String.class, com.azure.core.credential.TokenCredential.class));
Expand All @@ -69,9 +67,7 @@ public Object convert(
case "com.azure.core.util.ClientOptions": return applicationContext.getBean(ref, com.azure.core.util.ClientOptions.class);
case "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.servicebus.ServiceBusConfiguration.class);
case "com.azure.core.amqp.ProxyOptions": return applicationContext.getBean(ref, com.azure.core.amqp.ProxyOptions.class);
case "java.time.Duration": return applicationContext.getBean(ref, java.time.Duration.class);
case "com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient": return applicationContext.getBean(ref, com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient.class);
case "java.time.OffsetDateTime": return applicationContext.getBean(ref, java.time.OffsetDateTime.class);
case "com.azure.messaging.servicebus.ServiceBusSenderAsyncClient": return applicationContext.getBean(ref, com.azure.messaging.servicebus.ServiceBusSenderAsyncClient.class);
case "com.azure.messaging.servicebus.ServiceBusTransactionContext": return applicationContext.getBean(ref, com.azure.messaging.servicebus.ServiceBusTransactionContext.class);
case "com.azure.core.credential.TokenCredential": return applicationContext.getBean(ref, com.azure.core.credential.TokenCredential.class);
Expand Down
Expand Up @@ -74,13 +74,13 @@
{
"name": "camel.component.azure-storage-blob.change-feed-end-time",
"type": "java.time.OffsetDateTime",
"description": "When using getChangeFeed producer operation, this filters the results to return events approximately before the end time. Note: A few events belonging to the next hour can also be returned. A few events belonging to this hour can be missing; to ensure all events from the hour are returned, round the end time up by an hour. The option is a java.time.OffsetDateTime type.",
"description": "When using getChangeFeed producer operation, this filters the results to return events approximately before the end time. Note: A few events belonging to the next hour can also be returned. A few events belonging to this hour can be missing; to ensure all events from the hour are returned, round the end time up by an hour.",
"sourceType": "org.apache.camel.component.azure.storage.blob.springboot.BlobComponentConfiguration"
},
{
"name": "camel.component.azure-storage-blob.change-feed-start-time",
"type": "java.time.OffsetDateTime",
"description": "When using getChangeFeed producer operation, this filters the results to return events approximately after the start time. Note: A few events belonging to the previous hour can also be returned. A few events belonging to this hour can be missing; to ensure all events from the hour are returned, round the start time down by an hour. The option is a java.time.OffsetDateTime type.",
"description": "When using getChangeFeed producer operation, this filters the results to return events approximately after the start time. Note: A few events belonging to the previous hour can also be returned. A few events belonging to this hour can be missing; to ensure all events from the hour are returned, round the start time down by an hour.",
"sourceType": "org.apache.camel.component.azure.storage.blob.springboot.BlobComponentConfiguration"
},
{
Expand Down Expand Up @@ -245,7 +245,7 @@
{
"name": "camel.component.azure-storage-blob.timeout",
"type": "java.time.Duration",
"description": "An optional timeout value beyond which a RuntimeException will be raised. The option is a java.time.Duration type.",
"description": "An optional timeout value beyond which a RuntimeException will be raised.",
"sourceType": "org.apache.camel.component.azure.storage.blob.springboot.BlobComponentConfiguration"
}
],
Expand Down
Expand Up @@ -129,7 +129,6 @@ public class BlobComponentConfiguration
private BlobServiceClient serviceClient;
/**
* An optional timeout value beyond which a RuntimeException will be raised.
* The option is a java.time.Duration type.
*/
private Duration timeout;
/**
Expand Down Expand Up @@ -166,17 +165,15 @@ public class BlobComponentConfiguration
* return events approximately before the end time. Note: A few events
* belonging to the next hour can also be returned. A few events belonging
* to this hour can be missing; to ensure all events from the hour are
* returned, round the end time up by an hour. The option is a
* java.time.OffsetDateTime type.
* returned, round the end time up by an hour.
*/
private OffsetDateTime changeFeedEndTime;
/**
* When using getChangeFeed producer operation, this filters the results to
* return events approximately after the start time. Note: A few events
* belonging to the previous hour can also be returned. A few events
* belonging to this hour can be missing; to ensure all events from the hour
* are returned, round the start time down by an hour. The option is a
* java.time.OffsetDateTime type.
* are returned, round the start time down by an hour.
*/
private OffsetDateTime changeFeedStartTime;
/**
Expand Down
Expand Up @@ -42,9 +42,7 @@ public Set<ConvertiblePair> getConvertibleTypes() {
answer.add(new ConvertiblePair(String.class, org.apache.camel.component.azure.storage.blob.BlobConfiguration.class));
answer.add(new ConvertiblePair(String.class, com.azure.storage.common.StorageSharedKeyCredential.class));
answer.add(new ConvertiblePair(String.class, com.azure.storage.blob.BlobServiceClient.class));
answer.add(new ConvertiblePair(String.class, java.time.Duration.class));
answer.add(new ConvertiblePair(String.class, com.azure.core.util.Context.class));
answer.add(new ConvertiblePair(String.class, java.time.OffsetDateTime.class));
return answer;
}

Expand All @@ -64,9 +62,7 @@ public Object convert(
case "org.apache.camel.component.azure.storage.blob.BlobConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.storage.blob.BlobConfiguration.class);
case "com.azure.storage.common.StorageSharedKeyCredential": return applicationContext.getBean(ref, com.azure.storage.common.StorageSharedKeyCredential.class);
case "com.azure.storage.blob.BlobServiceClient": return applicationContext.getBean(ref, com.azure.storage.blob.BlobServiceClient.class);
case "java.time.Duration": return applicationContext.getBean(ref, java.time.Duration.class);
case "com.azure.core.util.Context": return applicationContext.getBean(ref, com.azure.core.util.Context.class);
case "java.time.OffsetDateTime": return applicationContext.getBean(ref, java.time.OffsetDateTime.class);
}
return null;
}
Expand Down
Expand Up @@ -242,7 +242,7 @@
{
"name": "camel.component.azure-storage-datalake.timeout",
"type": "java.time.Duration",
"description": "Timeout for operation. The option is a java.time.Duration type.",
"description": "Timeout for operation",
"sourceType": "org.apache.camel.component.azure.storage.datalake.springboot.DataLakeComponentConfiguration"
},
{
Expand Down
Expand Up @@ -148,7 +148,7 @@ public class DataLakeComponentConfiguration
*/
private String tenantId;
/**
* Timeout for operation. The option is a java.time.Duration type.
* Timeout for operation
*/
private Duration timeout;
/**
Expand Down
Expand Up @@ -42,7 +42,6 @@ public Set<ConvertiblePair> getConvertibleTypes() {
answer.add(new ConvertiblePair(String.class, org.apache.camel.component.azure.storage.datalake.DataLakeConfiguration.class));
answer.add(new ConvertiblePair(String.class, com.azure.storage.file.datalake.DataLakeServiceClient.class));
answer.add(new ConvertiblePair(String.class, com.azure.storage.common.StorageSharedKeyCredential.class));
answer.add(new ConvertiblePair(String.class, java.time.Duration.class));
answer.add(new ConvertiblePair(String.class, com.azure.identity.ClientSecretCredential.class));
answer.add(new ConvertiblePair(String.class, com.azure.core.credential.AzureSasCredential.class));
return answer;
Expand All @@ -64,7 +63,6 @@ public Object convert(
case "org.apache.camel.component.azure.storage.datalake.DataLakeConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.storage.datalake.DataLakeConfiguration.class);
case "com.azure.storage.file.datalake.DataLakeServiceClient": return applicationContext.getBean(ref, com.azure.storage.file.datalake.DataLakeServiceClient.class);
case "com.azure.storage.common.StorageSharedKeyCredential": return applicationContext.getBean(ref, com.azure.storage.common.StorageSharedKeyCredential.class);
case "java.time.Duration": return applicationContext.getBean(ref, java.time.Duration.class);
case "com.azure.identity.ClientSecretCredential": return applicationContext.getBean(ref, com.azure.identity.ClientSecretCredential.class);
case "com.azure.core.credential.AzureSasCredential": return applicationContext.getBean(ref, com.azure.core.credential.AzureSasCredential.class);
}
Expand Down
Expand Up @@ -124,19 +124,19 @@
{
"name": "camel.component.azure-storage-queue.time-to-live",
"type": "java.time.Duration",
"description": "How long the message will stay alive in the queue. If unset the value will default to 7 days, if -1 is passed the message will not expire. The time to live must be -1 or any positive number. The format should be in this form: PnDTnHnMn.nS., e.g: PT20.345S -- parses as 20.345 seconds, P2D -- parses as 2 days However, in case you are using EndpointDsl\/ComponentDsl, you can do something like Duration.ofSeconds() since these Java APIs are typesafe. The option is a java.time.Duration type.",
"description": "How long the message will stay alive in the queue. If unset the value will default to 7 days, if -1 is passed the message will not expire. The time to live must be -1 or any positive number. The format should be in this form: PnDTnHnMn.nS., e.g: PT20.345S -- parses as 20.345 seconds, P2D -- parses as 2 days However, in case you are using EndpointDsl\/ComponentDsl, you can do something like Duration.ofSeconds() since these Java APIs are typesafe.",
"sourceType": "org.apache.camel.component.azure.storage.queue.springboot.QueueComponentConfiguration"
},
{
"name": "camel.component.azure-storage-queue.timeout",
"type": "java.time.Duration",
"description": "An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown. The option is a java.time.Duration type.",
"description": "An optional timeout applied to the operation. If a response is not returned before the timeout concludes a RuntimeException will be thrown.",
"sourceType": "org.apache.camel.component.azure.storage.queue.springboot.QueueComponentConfiguration"
},
{
"name": "camel.component.azure-storage-queue.visibility-timeout",
"type": "java.time.Duration",
"description": "The timeout period for how long the message is invisible in the queue. The timeout must be between 1 seconds and 7 days. The format should be in this form: PnDTnHnMn.nS., e.g: PT20.345S -- parses as 20.345 seconds, P2D -- parses as 2 days However, in case you are using EndpointDsl\/ComponentDsl, you can do something like Duration.ofSeconds() since these Java APIs are typesafe. The option is a java.time.Duration type.",
"description": "The timeout period for how long the message is invisible in the queue. The timeout must be between 1 seconds and 7 days. The format should be in this form: PnDTnHnMn.nS., e.g: PT20.345S -- parses as 20.345 seconds, P2D -- parses as 2 days However, in case you are using EndpointDsl\/ComponentDsl, you can do something like Duration.ofSeconds() since these Java APIs are typesafe.",
"sourceType": "org.apache.camel.component.azure.storage.queue.springboot.QueueComponentConfiguration"
}
],
Expand Down
Expand Up @@ -134,7 +134,6 @@ public class QueueComponentConfiguration
/**
* An optional timeout applied to the operation. If a response is not
* returned before the timeout concludes a RuntimeException will be thrown.
* The option is a java.time.Duration type.
*/
private Duration timeout;
/**
Expand All @@ -144,8 +143,7 @@ public class QueueComponentConfiguration
* this form: PnDTnHnMn.nS., e.g: PT20.345S -- parses as 20.345 seconds, P2D
* -- parses as 2 days However, in case you are using
* EndpointDsl/ComponentDsl, you can do something like Duration.ofSeconds()
* since these Java APIs are typesafe. The option is a java.time.Duration
* type.
* since these Java APIs are typesafe.
*/
private Duration timeToLive;
/**
Expand All @@ -154,8 +152,7 @@ public class QueueComponentConfiguration
* this form: PnDTnHnMn.nS., e.g: PT20.345S -- parses as 20.345 seconds, P2D
* -- parses as 2 days However, in case you are using
* EndpointDsl/ComponentDsl, you can do something like Duration.ofSeconds()
* since these Java APIs are typesafe. The option is a java.time.Duration
* type.
* since these Java APIs are typesafe.
*/
private Duration visibilityTimeout;
/**
Expand Down
Expand Up @@ -41,7 +41,6 @@ public Set<ConvertiblePair> getConvertibleTypes() {
Set<ConvertiblePair> answer = new LinkedHashSet<>();
answer.add(new ConvertiblePair(String.class, org.apache.camel.component.azure.storage.queue.QueueConfiguration.class));
answer.add(new ConvertiblePair(String.class, com.azure.storage.queue.QueueServiceClient.class));
answer.add(new ConvertiblePair(String.class, java.time.Duration.class));
answer.add(new ConvertiblePair(String.class, com.azure.storage.common.StorageSharedKeyCredential.class));
return answer;
}
Expand All @@ -61,7 +60,6 @@ public Object convert(
switch (targetType.getName()) {
case "org.apache.camel.component.azure.storage.queue.QueueConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.storage.queue.QueueConfiguration.class);
case "com.azure.storage.queue.QueueServiceClient": return applicationContext.getBean(ref, com.azure.storage.queue.QueueServiceClient.class);
case "java.time.Duration": return applicationContext.getBean(ref, java.time.Duration.class);
case "com.azure.storage.common.StorageSharedKeyCredential": return applicationContext.getBean(ref, com.azure.storage.common.StorageSharedKeyCredential.class);
}
return null;
Expand Down

0 comments on commit e7286fa

Please sign in to comment.