You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2022/01/27 14:10:26 UTC
[camel-quarkus] branch main updated: Removed the deprecated @BuildTimeAvroDataFormat annotation #2791
This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new b586b73 Removed the deprecated @BuildTimeAvroDataFormat annotation #2791
b586b73 is described below
commit b586b73c5d1b82d6277544280884cc7e6936605b
Author: aldettinger <al...@gmail.com>
AuthorDate: Thu Jan 27 12:48:40 2022 +0100
Removed the deprecated @BuildTimeAvroDataFormat annotation #2791
---
docs/modules/ROOT/pages/migration-guide/2.7.0.adoc | 6 ++
.../ROOT/pages/reference/extensions/avro.adoc | 23 +-----
extensions/avro/deployment/pom.xml | 5 --
.../component/avro/deployment/AvroProcessor.java | 91 ----------------------
.../deployment/BuildTimeAvroDataFormatTest.java | 70 -----------------
.../src/test/resources/schemas/a-user.avsc | 7 --
.../src/test/resources/schemas/another-user.avsc | 7 --
extensions/avro/runtime/pom.xml | 5 --
.../avro/runtime/src/main/doc/configuration.adoc | 25 +-----
.../component/avro/AvroDataFormatProducer.java | 53 -------------
.../camel/quarkus/component/avro/AvroRecorder.java | 36 ---------
.../quarkus/component/avro/AvroSchemaRegistry.java | 35 ---------
.../component/avro/AvroSchemaSubstitution.java | 57 --------------
.../component/avro/BuildTimeAvroDataFormat.java | 36 ---------
.../component/avro/AvroDataFormatProducerTest.java | 58 --------------
.../quarkus/component/avro/it/AvroResource.java | 12 ---
.../camel/quarkus/component/avro/it/AvroRoute.java | 7 --
.../camel/quarkus/component/avro/it/AvroTest.java | 6 --
18 files changed, 9 insertions(+), 530 deletions(-)
diff --git a/docs/modules/ROOT/pages/migration-guide/2.7.0.adoc b/docs/modules/ROOT/pages/migration-guide/2.7.0.adoc
index 9712597..a4a491e 100644
--- a/docs/modules/ROOT/pages/migration-guide/2.7.0.adoc
+++ b/docs/modules/ROOT/pages/migration-guide/2.7.0.adoc
@@ -10,3 +10,9 @@ The deprecated `vertx-kafka` extension has been removed. Any routes using this c
xref:{cq-camel-components}:others:main.adoc[Camel Main] has been enabled as the default bootstrap mode since Camel Quarkus 1.8.0. The configuration property `quarkus.camel.main.enabled`
has now been removed as there are no major benefits to disabling Camel Main.
+
+== Removal of @BuildTimeAvroDataFormat
+
+The deprecated `@BuildTimeAvroDataFormat` annotation has been removed.
+Users are kindly asked to use the parsing of Avro schema at build time as described in the xref:reference/extensions/avro.adoc[Camel Quarkus Avro Extension] documentation.
+
diff --git a/docs/modules/ROOT/pages/reference/extensions/avro.adoc b/docs/modules/ROOT/pages/reference/extensions/avro.adoc
index 178cc16..01263de 100644
--- a/docs/modules/ROOT/pages/reference/extensions/avro.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/avro.adoc
@@ -43,7 +43,7 @@ Check the xref:user-guide/index.adoc[User guide] for more information about writ
Beyond standard usages known from vanilla Camel, Camel Quarkus adds the possibility to parse the Avro schema at build time both in JVM and Native mode.
-Since Camel Quarkus 2.0.0, the preferred approach to generate Avro classes from Avro schema files is the one coined by the `quarkus-avro` extension. It requires the following:
+The approach to generate Avro classes from Avro schema files is the one coined by the `quarkus-avro` extension. It requires the following:
1. Store `*.avsc` files in a folder named `src/main/avro` or `src/test/avro`
2. In addition to the usual `build` goal of `quarkus-maven-plugin`, add the `generate-code` goal:
@@ -67,24 +67,3 @@ Since Camel Quarkus 2.0.0, the preferred approach to generate Avro classes from
Please see a working configuration in link:https://github.com/apache/camel-quarkus/tree/main/integration-tests/avro[Camel Quarkus Avro integration test] and link:https://github.com/quarkusio/quarkus/tree/main/integration-tests/avro-reload/src/test/avro[Quarkus Avro integration test].
-=== Deprecated: `@BuildTimeAvroDataFormat` annotation.
-
-Before Camel Quarkus 2.0.0, the `@BuildTimeAvroDataFormat` annotation was the preferred way to generate Avro entities from Avro schema files.
-
-In the example below, the `user.avsc` schema resource is first parsed at build time.
-Then, an `AvroDataFormat` instance using the previously parsed schema is injected in the `buildTimeAvroDataFormat` field at runtime.
-At the end of the day, the injected data format is used from the `configure()` method in order to marshal an incoming message.
-
-[source,java]
-----
-import org.apache.camel.quarkus.component.avro.BuildTimeAvroDataFormat;
-...
-@BuildTimeAvroDataFormat("user.avsc")
-AvroDataFormat buildTimeAvroDataFormat;
-
-@Override
-public void configure() {
- from("direct:marshalUsingBuildTimeAvroDataFormat").marshal(buildTimeAvroDataFormat);
-}
-----
-
diff --git a/extensions/avro/deployment/pom.xml b/extensions/avro/deployment/pom.xml
index 0b44599..558f4a1 100644
--- a/extensions/avro/deployment/pom.xml
+++ b/extensions/avro/deployment/pom.xml
@@ -42,11 +42,6 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-avro</artifactId>
</dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-junit5-internal</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/extensions/avro/deployment/src/main/java/org/apache/camel/quarkus/component/avro/deployment/AvroProcessor.java b/extensions/avro/deployment/src/main/java/org/apache/camel/quarkus/component/avro/deployment/AvroProcessor.java
index 48604a0..1668d7f 100644
--- a/extensions/avro/deployment/src/main/java/org/apache/camel/quarkus/component/avro/deployment/AvroProcessor.java
+++ b/extensions/avro/deployment/src/main/java/org/apache/camel/quarkus/component/avro/deployment/AvroProcessor.java
@@ -16,51 +16,17 @@
*/
package org.apache.camel.quarkus.component.avro.deployment;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
-import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem;
-import io.quarkus.arc.deployment.BeanArchiveIndexBuildItem;
-import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
-import io.quarkus.arc.processor.AnnotationsTransformer;
-import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.builditem.ObjectSubstitutionBuildItem;
-import io.quarkus.deployment.builditem.ObjectSubstitutionBuildItem.Holder;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
-import io.quarkus.deployment.recording.RecorderContext;
-import io.quarkus.runtime.RuntimeValue;
-import org.apache.avro.Schema;
-import org.apache.avro.SchemaParseException;
import org.apache.avro.generic.GenericContainer;
-import org.apache.camel.quarkus.component.avro.AvroDataFormatProducer;
-import org.apache.camel.quarkus.component.avro.AvroRecorder;
-import org.apache.camel.quarkus.component.avro.AvroSchemaRegistry;
-import org.apache.camel.quarkus.component.avro.AvroSchemaSubstitution;
-import org.apache.camel.quarkus.component.avro.BuildTimeAvroDataFormat;
-import org.jboss.jandex.AnnotationInstance;
-import org.jboss.jandex.DotName;
-import org.jboss.jandex.FieldInfo;
-import org.jboss.jandex.IndexView;
-import org.jboss.logging.Logger;
class AvroProcessor {
- private static final Logger LOG = Logger.getLogger(AvroProcessor.class);
private static final String FEATURE = "camel-avro";
- private static DotName BUILD_TIME_AVRO_DATAFORMAT_ANNOTATION = DotName
- .createSimple(BuildTimeAvroDataFormat.class.getName());
@BuildStep
FeatureBuildItem feature() {
@@ -74,61 +40,4 @@ class AvroProcessor {
return items;
}
- @BuildStep
- void additionalBeanClasses(BuildProducer<AdditionalBeanBuildItem> additionalBeanProducer) {
- additionalBeanProducer.produce(new AdditionalBeanBuildItem(AvroDataFormatProducer.class));
- }
-
- @BuildStep
- AnnotationsTransformerBuildItem markFieldsAnnotatedWithBuildTimeAvroDataFormatAsInjectable() {
- return new AnnotationsTransformerBuildItem(new AnnotationsTransformer() {
-
- public boolean appliesTo(org.jboss.jandex.AnnotationTarget.Kind kind) {
- return kind == org.jboss.jandex.AnnotationTarget.Kind.FIELD;
- }
-
- @Override
- public void transform(TransformationContext ctx) {
- FieldInfo fieldInfo = ctx.getTarget().asField();
- if (fieldInfo.annotation(BUILD_TIME_AVRO_DATAFORMAT_ANNOTATION) != null) {
- ctx.transform().add(Inject.class).done();
- }
- }
- });
- }
-
- @BuildStep
- void overrideAvroSchemasSerialization(BuildProducer<ObjectSubstitutionBuildItem> substitutions) {
- Holder<Schema, byte[]> holder = new Holder(Schema.class, byte[].class, AvroSchemaSubstitution.class);
- substitutions.produce(new ObjectSubstitutionBuildItem(holder));
- }
-
- @BuildStep
- @Record(ExecutionTime.STATIC_INIT)
- SyntheticBeanBuildItem avroSchemaRegistry(
- RecorderContext ctx,
- AvroRecorder recorder,
- BeanArchiveIndexBuildItem beanArchiveIndex) {
- final RuntimeValue<Map<String, Schema>> schemas = ctx.newInstance(LinkedHashMap.class.getName());
- final IndexView index = beanArchiveIndex.getIndex();
- for (AnnotationInstance annotation : index.getAnnotations(BUILD_TIME_AVRO_DATAFORMAT_ANNOTATION)) {
- String schemaResourceName = annotation.value().asString();
- FieldInfo fieldInfo = annotation.target().asField();
- String injectedFieldId = fieldInfo.declaringClass().name() + "." + fieldInfo.name();
- try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(schemaResourceName)) {
- Schema avroSchema = new Schema.Parser().parse(is);
- recorder.addSchema(schemas, injectedFieldId, avroSchema);
- LOG.debug("Parsed the avro schema at build time from resource named " + schemaResourceName);
- } catch (SchemaParseException | IOException ex) {
- final String message = "An issue occured while parsing schema resource on field " + injectedFieldId;
- throw new RuntimeException(message, ex);
- }
- }
-
- return SyntheticBeanBuildItem.configure(AvroSchemaRegistry.class)
- .scope(Singleton.class)
- .runtimeValue(recorder.avroSchemaRegistry(schemas))
- .done();
- }
-
}
diff --git a/extensions/avro/deployment/src/test/java/org/apache/camel/quarkus/component/avro/deployment/BuildTimeAvroDataFormatTest.java b/extensions/avro/deployment/src/test/java/org/apache/camel/quarkus/component/avro/deployment/BuildTimeAvroDataFormatTest.java
deleted file mode 100644
index e5d27b7..0000000
--- a/extensions/avro/deployment/src/test/java/org/apache/camel/quarkus/component/avro/deployment/BuildTimeAvroDataFormatTest.java
+++ /dev/null
@@ -1,70 +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.quarkus.component.avro.deployment;
-
-import io.quarkus.test.QuarkusUnitTest;
-import org.apache.avro.Schema;
-import org.apache.camel.dataformat.avro.AvroDataFormat;
-import org.apache.camel.quarkus.component.avro.BuildTimeAvroDataFormat;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class BuildTimeAvroDataFormatTest {
-
- @RegisterExtension
- static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addAsResource("schemas/a-user.avsc")
- .addAsResource("schemas/another-user.avsc"));
-
- @BuildTimeAvroDataFormat("schemas/a-user.avsc")
- AvroDataFormat aUserBuildTimeAvroDataFormat;
-
- @BuildTimeAvroDataFormat("schemas/a-user.avsc")
- AvroDataFormat aUserBuildTimeAvroDataFormatBis;
-
- @BuildTimeAvroDataFormat("schemas/another-user.avsc")
- AvroDataFormat anotherUserBuildTimeAvroDataFormat;
-
- @Test
- void buildTimeAvroDataFormatAnnotationsShouldBeProcessed() {
- assertNotNull(aUserBuildTimeAvroDataFormat);
- Object aUserObjectSchema = aUserBuildTimeAvroDataFormat.getSchema();
- assertNotNull(aUserObjectSchema);
- assertTrue(aUserObjectSchema instanceof Schema);
- Schema aUserSchema = (Schema) aUserObjectSchema;
- assertEquals("a.user", aUserSchema.getNamespace());
-
- Object aUserBisObjectSchema = aUserBuildTimeAvroDataFormatBis.getSchema();
- assertNotNull(aUserBisObjectSchema);
- assertNotSame(aUserObjectSchema, aUserBisObjectSchema);
-
- assertNotNull(anotherUserBuildTimeAvroDataFormat);
- Object anotherUserObjectSchema = anotherUserBuildTimeAvroDataFormat.getSchema();
- assertNotNull(anotherUserObjectSchema);
- assertTrue(anotherUserObjectSchema instanceof Schema);
- Schema anotherUserSchema = (Schema) anotherUserObjectSchema;
- assertEquals("another.user", anotherUserSchema.getNamespace());
- }
-
-}
diff --git a/extensions/avro/deployment/src/test/resources/schemas/a-user.avsc b/extensions/avro/deployment/src/test/resources/schemas/a-user.avsc
deleted file mode 100644
index a5c4d47..0000000
--- a/extensions/avro/deployment/src/test/resources/schemas/a-user.avsc
+++ /dev/null
@@ -1,7 +0,0 @@
-{"namespace": "a.user",
- "type": "record",
- "name": "User",
- "fields": [
- {"name": "name", "type": "string"}
- ]
-}
\ No newline at end of file
diff --git a/extensions/avro/deployment/src/test/resources/schemas/another-user.avsc b/extensions/avro/deployment/src/test/resources/schemas/another-user.avsc
deleted file mode 100644
index 2cba772..0000000
--- a/extensions/avro/deployment/src/test/resources/schemas/another-user.avsc
+++ /dev/null
@@ -1,7 +0,0 @@
-{"namespace": "another.user",
- "type": "record",
- "name": "User",
- "fields": [
- {"name": "name", "type": "string"}
- ]
-}
\ No newline at end of file
diff --git a/extensions/avro/runtime/pom.xml b/extensions/avro/runtime/pom.xml
index 2c2edea..a7ff101 100644
--- a/extensions/avro/runtime/pom.xml
+++ b/extensions/avro/runtime/pom.xml
@@ -59,11 +59,6 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-avro</artifactId>
</dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-junit5-mockito</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/extensions/avro/runtime/src/main/doc/configuration.adoc b/extensions/avro/runtime/src/main/doc/configuration.adoc
index fe57043..02223d0 100644
--- a/extensions/avro/runtime/src/main/doc/configuration.adoc
+++ b/extensions/avro/runtime/src/main/doc/configuration.adoc
@@ -1,6 +1,6 @@
Beyond standard usages known from vanilla Camel, Camel Quarkus adds the possibility to parse the Avro schema at build time both in JVM and Native mode.
-Since Camel Quarkus 2.0.0, the preferred approach to generate Avro classes from Avro schema files is the one coined by the `quarkus-avro` extension. It requires the following:
+The approach to generate Avro classes from Avro schema files is the one coined by the `quarkus-avro` extension. It requires the following:
1. Store `*.avsc` files in a folder named `src/main/avro` or `src/test/avro`
2. In addition to the usual `build` goal of `quarkus-maven-plugin`, add the `generate-code` goal:
@@ -22,25 +22,4 @@ Since Camel Quarkus 2.0.0, the preferred approach to generate Avro classes from
</plugin>
----
-Please see a working configuration in link:https://github.com/apache/camel-quarkus/tree/main/integration-tests/avro[Camel Quarkus Avro integration test] and link:https://github.com/quarkusio/quarkus/tree/main/integration-tests/avro-reload/src/test/avro[Quarkus Avro integration test].
-
-=== Deprecated: `@BuildTimeAvroDataFormat` annotation.
-
-Before Camel Quarkus 2.0.0, the `@BuildTimeAvroDataFormat` annotation was the preferred way to generate Avro entities from Avro schema files.
-
-In the example below, the `user.avsc` schema resource is first parsed at build time.
-Then, an `AvroDataFormat` instance using the previously parsed schema is injected in the `buildTimeAvroDataFormat` field at runtime.
-At the end of the day, the injected data format is used from the `configure()` method in order to marshal an incoming message.
-
-[source,java]
-----
-import org.apache.camel.quarkus.component.avro.BuildTimeAvroDataFormat;
-...
-@BuildTimeAvroDataFormat("user.avsc")
-AvroDataFormat buildTimeAvroDataFormat;
-
-@Override
-public void configure() {
- from("direct:marshalUsingBuildTimeAvroDataFormat").marshal(buildTimeAvroDataFormat);
-}
-----
+Please see a working configuration in link:https://github.com/apache/camel-quarkus/tree/main/integration-tests/avro[Camel Quarkus Avro integration test] and link:https://github.com/quarkusio/quarkus/tree/main/integration-tests/avro-reload/src/test/avro[Quarkus Avro integration test].
\ No newline at end of file
diff --git a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroDataFormatProducer.java b/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroDataFormatProducer.java
deleted file mode 100644
index 37582dc..0000000
--- a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroDataFormatProducer.java
+++ /dev/null
@@ -1,53 +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.quarkus.component.avro;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Modifier;
-
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.inject.Singleton;
-
-import org.apache.avro.Schema;
-import org.apache.camel.dataformat.avro.AvroDataFormat;
-
-@Singleton
-public class AvroDataFormatProducer {
-
- private final AvroSchemaRegistry schemaRegistry;
-
- public AvroDataFormatProducer(AvroSchemaRegistry schemaRegistry) {
- this.schemaRegistry = schemaRegistry;
- }
-
- @Produces
- AvroDataFormat produceAvroDataFormat(InjectionPoint injectionPoint) {
- Member member = injectionPoint.getMember();
- if (member instanceof Field) {
- Field field = (Field) member;
- if (!Modifier.isStatic(member.getModifiers()) && field.getAnnotation(BuildTimeAvroDataFormat.class) != null) {
- String injectedFieldId = member.getDeclaringClass().getName() + "." + member.getName();
- Schema schema = schemaRegistry.getSchema(injectedFieldId);
- return new AvroDataFormat(schema);
- }
- }
- String message = "AvroDataFormat beans can only be injected into non-static field annotated with @";
- throw new IllegalArgumentException(message + BuildTimeAvroDataFormat.class.getName());
- }
-}
diff --git a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroRecorder.java b/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroRecorder.java
deleted file mode 100644
index 08562e7..0000000
--- a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroRecorder.java
+++ /dev/null
@@ -1,36 +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.quarkus.component.avro;
-
-import java.util.Map;
-
-import io.quarkus.runtime.RuntimeValue;
-import io.quarkus.runtime.annotations.Recorder;
-import org.apache.avro.Schema;
-
-@Recorder
-public class AvroRecorder {
-
- public void addSchema(RuntimeValue<Map<String, Schema>> schemas, String injectedFieldId, Schema schema) {
- schemas.getValue().put(injectedFieldId, schema);
- }
-
- public RuntimeValue<AvroSchemaRegistry> avroSchemaRegistry(RuntimeValue<Map<String, Schema>> schemas) {
- return new RuntimeValue<>(new AvroSchemaRegistry(schemas.getValue()));
- }
-
-}
diff --git a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroSchemaRegistry.java b/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroSchemaRegistry.java
deleted file mode 100644
index d72a2ff..0000000
--- a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroSchemaRegistry.java
+++ /dev/null
@@ -1,35 +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.quarkus.component.avro;
-
-import java.util.Map;
-
-import org.apache.avro.Schema;
-
-public class AvroSchemaRegistry {
-
- private final Map<String, Schema> schemaRegistry;
-
- public AvroSchemaRegistry(Map<String, Schema> schemaRegistry) {
- this.schemaRegistry = schemaRegistry;
- }
-
- public Schema getSchema(String injectedFieldId) {
- return schemaRegistry.get(injectedFieldId);
- }
-
-}
diff --git a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroSchemaSubstitution.java b/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroSchemaSubstitution.java
deleted file mode 100644
index aac3bfc..0000000
--- a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/AvroSchemaSubstitution.java
+++ /dev/null
@@ -1,57 +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.quarkus.component.avro;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import io.quarkus.runtime.ObjectSubstitution;
-import org.apache.avro.Schema;
-
-/**
- * {@code AvroSchemaSubstitution} offers a way to bypass Quarkus
- * default serialization. This workaround has been introduced as Quarkus default
- * serialization used to failed with {@code org.apache.avro.Schema}.
- */
-public class AvroSchemaSubstitution implements ObjectSubstitution<Schema, byte[]> {
-
- @Override
- public byte[] serialize(Schema schema) {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
- try (ObjectOutputStream out = new ObjectOutputStream(baos)) {
- out.writeObject(schema);
- } catch (final IOException ex) {
- throw new RuntimeException("Could not serialize " + Schema.class.getName() + " " + schema, ex);
- }
- return baos.toByteArray();
- }
-
- @Override
- public Schema deserialize(byte[] schemaBytes) {
- final InputStream inputStream = new ByteArrayInputStream(schemaBytes);
- try (ObjectInputStream in = new ObjectInputStream(inputStream)) {
- return (Schema) in.readObject();
- } catch (final ClassNotFoundException | IOException ex) {
- throw new RuntimeException("Could not deserialize " + Schema.class.getName(), ex);
- }
- }
-
-}
diff --git a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/BuildTimeAvroDataFormat.java b/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/BuildTimeAvroDataFormat.java
deleted file mode 100644
index b77722d..0000000
--- a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/BuildTimeAvroDataFormat.java
+++ /dev/null
@@ -1,36 +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.quarkus.component.avro;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target({ ElementType.FIELD })
-@Retention(RetentionPolicy.RUNTIME)
-@Deprecated
-/**
- * @deprecated Prefer storing *.avsc files in a folder named 'avro' to have @AvroGenerated class created at build-time
- * by quarkus-avro.
- * @see <a href=
- * "https://github.com/quarkusio/quarkus/tree/main/integration-tests/avro-reload/src/test/avro">quarkus-avro/a>
- * test.
- */
-public @interface BuildTimeAvroDataFormat {
- public String value();
-}
diff --git a/extensions/avro/runtime/src/test/java/org/apache/camel/quarkus/component/avro/AvroDataFormatProducerTest.java b/extensions/avro/runtime/src/test/java/org/apache/camel/quarkus/component/avro/AvroDataFormatProducerTest.java
deleted file mode 100644
index 814defc..0000000
--- a/extensions/avro/runtime/src/test/java/org/apache/camel/quarkus/component/avro/AvroDataFormatProducerTest.java
+++ /dev/null
@@ -1,58 +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.quarkus.component.avro;
-
-import java.lang.reflect.Field;
-import java.util.Collections;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.apache.camel.dataformat.avro.AvroDataFormat;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class AvroDataFormatProducerTest {
-
- private AvroDataFormatProducer instance;
-
- private InjectionPoint mockInjectionPoint;
- @SuppressWarnings("unused")
- private static AvroDataFormat injectedField;
- private Field injectedFieldMember;
-
- @BeforeEach
- public void setup() throws NoSuchFieldException, SecurityException {
- instance = new AvroDataFormatProducer(new AvroSchemaRegistry(Collections.emptyMap()));
- injectedFieldMember = AvroDataFormatProducerTest.class.getDeclaredField("injectedField");
- mockInjectionPoint = mock(InjectionPoint.class);
- when(mockInjectionPoint.getMember()).thenReturn(injectedFieldMember);
- }
-
- @Test
- void produceAvroDataFormatFromNonStaticFieldShouldThrow() {
- IllegalArgumentException iaex = assertThrows(IllegalArgumentException.class, () -> {
- instance.produceAvroDataFormat(mockInjectionPoint);
- });
- assertNotNull(iaex.getMessage());
- }
-
-}
diff --git a/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroResource.java b/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroResource.java
index efd6587..d626f12 100644
--- a/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroResource.java
+++ b/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroResource.java
@@ -38,18 +38,6 @@ public class AvroResource {
@Inject
ProducerTemplate producerTemplate;
- @Path("/genericMarshalUnmarshalUsingBuildTimeAvroDataFormat/{value}")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String genericMarshalUnmarshalUsingBuildTimeAvroDataFormat(@PathParam("value") String value) {
- GenericRecord input = new GenericData.Record(getSchema());
- input.put("name", value);
- Object marshalled = producerTemplate.requestBody("direct:marshalUsingBuildTimeAvroDataFormat", input);
- GenericRecord output = producerTemplate.requestBody("direct:unmarshalUsingBuildTimeAvroDataFormat", marshalled,
- GenericRecord.class);
- return output.get("name").toString();
- }
-
@Path("/genericMarshalUnmarshalUsingBuildTimeGeneratedClass/{value}")
@GET
@Produces(MediaType.TEXT_PLAIN)
diff --git a/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroRoute.java b/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroRoute.java
index 95a20d0..ce70524 100644
--- a/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroRoute.java
+++ b/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroRoute.java
@@ -21,22 +21,15 @@ import javax.enterprise.context.ApplicationScoped;
import example.avro.Admin;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.dataformat.avro.AvroDataFormat;
-import org.apache.camel.quarkus.component.avro.BuildTimeAvroDataFormat;
import static org.apache.camel.quarkus.component.avro.it.AvroSchemaLoader.getSchema;
@ApplicationScoped
public class AvroRoute extends RouteBuilder {
- @BuildTimeAvroDataFormat("user.avsc")
- AvroDataFormat buildTimeAvroDataFormat;
-
@Override
public void configure() {
- from("direct:marshalUsingBuildTimeAvroDataFormat").marshal(buildTimeAvroDataFormat);
- from("direct:unmarshalUsingBuildTimeAvroDataFormat").unmarshal(buildTimeAvroDataFormat);
-
from("direct:marshalUsingBuildTimeGeneratedClass").marshal().avro(Admin.class);
from("direct:unmarshalUsingBuildTimeGeneratedClass").unmarshal().avro(Admin.class);
diff --git a/integration-tests/avro/src/test/java/org/apache/camel/quarkus/component/avro/it/AvroTest.java b/integration-tests/avro/src/test/java/org/apache/camel/quarkus/component/avro/it/AvroTest.java
index 900414d..0c49f13 100644
--- a/integration-tests/avro/src/test/java/org/apache/camel/quarkus/component/avro/it/AvroTest.java
+++ b/integration-tests/avro/src/test/java/org/apache/camel/quarkus/component/avro/it/AvroTest.java
@@ -26,12 +26,6 @@ import static org.hamcrest.Matchers.is;
class AvroTest {
@Test
- void genericMarshalUnmarshalUsingBuildTimeAvroDataFormatShouldSucceed() {
- RestAssured.get("/avro/genericMarshalUnmarshalUsingBuildTimeAvroDataFormat/jack").then().statusCode(200)
- .body(is("jack"));
- }
-
- @Test
void genericMarshalUnmarshalUsingBuildTimeGeneratedClassShouldSucceed() {
RestAssured.get("/avro/genericMarshalUnmarshalUsingBuildTimeGeneratedClass/bill").then().statusCode(200)
.body(is("bill"));