llowinge commented on code in PR #8730: URL: https://github.com/apache/camel-quarkus/pull/8730#discussion_r3357227013
########## extensions/ocsf/deployment/src/main/java/org/apache/camel/quarkus/component/ocsf/deployment/OcsfProcessor.java: ########## @@ -0,0 +1,69 @@ +/* + * 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.ocsf.deployment; + +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.IndexDependencyBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import org.jboss.jandex.IndexView; + +class OcsfProcessor { + + private static final String FEATURE = "camel-ocsf"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + IndexDependencyBuildItem registerDependencyForIndex() { + return new IndexDependencyBuildItem("org.apache.camel", "camel-ocsf"); + } + + @BuildStep + void registerForReflection(CombinedIndexBuildItem combinedIndex, + BuildProducer<ReflectiveClassBuildItem> reflectiveClass) { + IndexView index = combinedIndex.getIndex(); + + // Register all OCSF model classes for reflection (generated from JSON schemas) + String[] modelClasses = index.getKnownClasses().stream() + .map(ci -> ci.name().toString()) + .filter(n -> n.startsWith("org.apache.camel.dataformat.ocsf.model")) + .sorted() + .toArray(String[]::new); + + reflectiveClass.produce(ReflectiveClassBuildItem.builder(modelClasses) + .methods() + .fields() + .build()); + + // Register the OCSF DataFormat class + reflectiveClass.produce(ReflectiveClassBuildItem.builder("org.apache.camel.dataformat.ocsf.OcsfDataFormat") + .build()); Review Comment: You are right, thanks. ########## extensions/ocsf/deployment/src/main/java/org/apache/camel/quarkus/component/ocsf/deployment/OcsfProcessor.java: ########## @@ -0,0 +1,69 @@ +/* + * 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.ocsf.deployment; + +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.IndexDependencyBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import org.jboss.jandex.IndexView; + +class OcsfProcessor { + + private static final String FEATURE = "camel-ocsf"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + IndexDependencyBuildItem registerDependencyForIndex() { + return new IndexDependencyBuildItem("org.apache.camel", "camel-ocsf"); + } + + @BuildStep + void registerForReflection(CombinedIndexBuildItem combinedIndex, + BuildProducer<ReflectiveClassBuildItem> reflectiveClass) { + IndexView index = combinedIndex.getIndex(); + + // Register all OCSF model classes for reflection (generated from JSON schemas) + String[] modelClasses = index.getKnownClasses().stream() + .map(ci -> ci.name().toString()) + .filter(n -> n.startsWith("org.apache.camel.dataformat.ocsf.model")) + .sorted() + .toArray(String[]::new); + + reflectiveClass.produce(ReflectiveClassBuildItem.builder(modelClasses) + .methods() + .fields() + .build()); + + // Register the OCSF DataFormat class + reflectiveClass.produce(ReflectiveClassBuildItem.builder("org.apache.camel.dataformat.ocsf.OcsfDataFormat") + .build()); + + // Register Jackson classes needed for OCSF + reflectiveClass.produce(ReflectiveClassBuildItem.builder("com.fasterxml.jackson.databind.JsonNode") + .build()); + reflectiveClass.produce( + ReflectiveClassBuildItem.builder("com.fasterxml.jackson.datatype.jsr310.JavaTimeModule") + .build()); Review Comment: You are right, thanks. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
