This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 04bf9141b98 (chores) camel-platform-http-vertx: add a converter to
improve performance (#12211)
04bf9141b98 is described below
commit 04bf9141b987df2ace64e605cbf4f5fe1186aebc
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Mon Nov 27 15:18:22 2023 +0100
(chores) camel-platform-http-vertx: add a converter to improve performance
(#12211)
This converter provides a small performance boost when creating the HTTP
headers, as it avoids a costlier conversion path involving the core's
ToStringTypeConverter (which is also slower due to multiple type misses).
This provides a direct conversion from the converter cache
---
.../platform/http/vertx/VertxConverterLoader.java | 52 ++++++++++++++++++++++
.../services/org/apache/camel/TypeConverterLoader | 2 +
.../platform/http/vertx/VertxConverter.java | 35 +++++++++++++++
3 files changed, 89 insertions(+)
diff --git
a/components/camel-platform-http-vertx/src/generated/java/org/apache/camel/component/platform/http/vertx/VertxConverterLoader.java
b/components/camel-platform-http-vertx/src/generated/java/org/apache/camel/component/platform/http/vertx/VertxConverterLoader.java
new file mode 100644
index 00000000000..1cc35e6bb80
--- /dev/null
+++
b/components/camel-platform-http-vertx/src/generated/java/org/apache/camel/component/platform/http/vertx/VertxConverterLoader.java
@@ -0,0 +1,52 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.platform.http.vertx;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.DeferredContextBinding;
+import org.apache.camel.Exchange;
+import org.apache.camel.TypeConversionException;
+import org.apache.camel.TypeConverterLoaderException;
+import org.apache.camel.spi.TypeConverterLoader;
+import org.apache.camel.spi.TypeConverterRegistry;
+import org.apache.camel.support.SimpleTypeConverter;
+import org.apache.camel.support.TypeConverterSupport;
+import org.apache.camel.util.DoubleMap;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+@DeferredContextBinding
+public final class VertxConverterLoader implements TypeConverterLoader,
CamelContextAware {
+
+ private CamelContext camelContext;
+
+ public VertxConverterLoader() {
+ }
+
+ @Override
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
+ @Override
+ public void load(TypeConverterRegistry registry) throws
TypeConverterLoaderException {
+ registerConverters(registry);
+ }
+
+ private void registerConverters(TypeConverterRegistry registry) {
+ addTypeConverter(registry, java.lang.String.class,
io.vertx.core.net.impl.SocketAddressImpl.class, false,
+ (type, exchange, value) ->
org.apache.camel.component.platform.http.vertx.VertxConverter.fromSocket((io.vertx.core.net.impl.SocketAddressImpl)
value));
+ }
+
+ private static void addTypeConverter(TypeConverterRegistry registry,
Class<?> toType, Class<?> fromType, boolean allowNull,
SimpleTypeConverter.ConversionMethod method) {
+ registry.addTypeConverter(toType, fromType, new
SimpleTypeConverter(allowNull, method));
+ }
+
+}
diff --git
a/components/camel-platform-http-vertx/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
b/components/camel-platform-http-vertx/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
new file mode 100644
index 00000000000..cf4234a823f
--- /dev/null
+++
b/components/camel-platform-http-vertx/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+org.apache.camel.component.platform.http.vertx.VertxConverterLoader
diff --git
a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxConverter.java
b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxConverter.java
new file mode 100644
index 00000000000..4a198bf04d2
--- /dev/null
+++
b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxConverter.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.platform.http.vertx;
+
+import io.vertx.core.net.impl.SocketAddressImpl;
+import org.apache.camel.Converter;
+
+@Converter(generateLoader = true)
+public final class VertxConverter {
+
+ /*
+ * This converter provides a small performance boost when creating the
HTTP headers, as it avoids a costlier conversion
+ * path involving the core's ToStringTypeConverter (which is also slower
due to multiple type misses). This one provides
+ * a direct conversion from the converter cache.
+ */
+ @Converter
+ public static String fromSocket(SocketAddressImpl socketAddress) {
+ return socketAddress.toString();
+ }
+}