apupier commented on code in PR #8009: URL: https://github.com/apache/camel-quarkus/pull/8009#discussion_r2589016602
########## extensions/ibm-cos/deployment/src/main/java/org/apache/camel/quarkus/component/ibm/cos/deployment/IbmCosProcessor.java: ########## @@ -0,0 +1,102 @@ +/* + * 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.ibm.cos.deployment; + +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.stream.Stream; + +import com.ibm.cloud.objectstorage.ClientConfiguration; +import com.ibm.cloud.objectstorage.auth.DefaultAWSCredentialsProviderChain; +import com.ibm.cloud.objectstorage.auth.InstanceProfileCredentialsProvider; +import com.ibm.cloud.objectstorage.client.builder.AwsClientBuilder; +import com.ibm.cloud.objectstorage.event.SDKProgressPublisher; +import com.ibm.cloud.objectstorage.oauth.Token; +import com.ibm.cloud.objectstorage.regions.AwsRegionProviderChain; +import com.ibm.cloud.objectstorage.regions.InstanceMetadataRegionProvider; +import com.ibm.cloud.objectstorage.retry.PredefinedBackoffStrategies; +import com.ibm.cloud.objectstorage.retry.PredefinedRetryPolicies; +import com.ibm.cloud.objectstorage.services.s3.internal.AWSS3V4Signer; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; + +class IbmCosProcessor { + + private static final String FEATURE = "camel-ibm-cos"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + void runtimeInitialized(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitialized) { + Stream.of( + ClientConfiguration.class.getName(), + AwsClientBuilder.class.getName(), + AwsRegionProviderChain.class.getName(), + InstanceMetadataRegionProvider.class.getName()) + .map(RuntimeInitializedClassBuildItem::new) + .forEach(runtimeInitialized::produce); + } + + @BuildStep + void reflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) { + // The camel component supports only this AWSS3V4Signer method, might need to register other AbstractAWSSigner subclass if it changes + reflectiveClasses.produce(ReflectiveClassBuildItem.builder(AWSS3V4Signer.class).methods().constructors().build()); + + reflectiveClasses.produce(ReflectiveClassBuildItem.builder(Token.class).methods().constructors().build()); + + // TODO: to remove when https://github.com/IBM/ibm-cos-sdk-java/issues/74 is implemented, released and integrated in Camel + reflectiveClasses + .produce(ReflectiveClassBuildItem.builder(ScheduledThreadPoolExecutor.class).methods().constructors().build()); Review Comment: interesting anecdote: there was this warning in log at native execution: ``` Error checking if bucket exists: The request timeout feature is only available for Java 1.7 and above. ``` it comes from https://github.com/IBM/ibm-cos-sdk-java/blob/218a58a58bdc73917895f804dad6369a2b038a1b/ibm-cos-java-sdk-core/src/main/java/com/ibm/cloud/objectstorage/http/timers/TimeoutThreadPoolBuilder.java#L78 and in fact, it was preventing the Camel component to work at all -- 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]
