This is an automated email from the ASF dual-hosted git repository.

jamesnetherton 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 af70309e6b Remove Spring dependencies from Jira extension
af70309e6b is described below

commit af70309e6b1b5bf8508a712b4a7c317412f5749d
Author: James Netherton <jamesnether...@gmail.com>
AuthorDate: Wed Jun 21 07:19:08 2023 +0100

    Remove Spring dependencies from Jira extension
    
    Fixes #3889
---
 extensions/jira/deployment/pom.xml                 |  4 --
 .../component/jira/deployment/JiraProcessor.java   | 43 +++++++++++++++++++++-
 extensions/jira/runtime/pom.xml                    |  4 --
 3 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/extensions/jira/deployment/pom.xml 
b/extensions/jira/deployment/pom.xml
index 45ea626cf1..93b33ec391 100644
--- a/extensions/jira/deployment/pom.xml
+++ b/extensions/jira/deployment/pom.xml
@@ -46,10 +46,6 @@
             <groupId>org.apache.camel.quarkus</groupId>
             
<artifactId>camel-quarkus-support-commons-logging-deployment</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.camel.quarkus</groupId>
-            <artifactId>camel-quarkus-support-spring-deployment</artifactId>
-        </dependency>
         <dependency>
             <groupId>io.quarkus</groupId>
             <artifactId>quarkus-rest-client-deployment</artifactId>
diff --git 
a/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java
 
b/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java
index 9dabba03a4..acfe87f4e0 100644
--- 
a/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java
+++ 
b/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java
@@ -16,23 +16,30 @@
  */
 package org.apache.camel.quarkus.component.jira.deployment;
 
+import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.function.BooleanSupplier;
 
+import io.quarkus.deployment.GeneratedClassGizmoAdaptor;
+import io.quarkus.deployment.annotations.BuildProducer;
 import io.quarkus.deployment.annotations.BuildStep;
 import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
 import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
 import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
 import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
 import 
io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
 import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.gizmo.ClassCreator;
+import io.quarkus.gizmo.MethodCreator;
 import org.jboss.jandex.IndexView;
 import org.joda.time.DateTimeZone;
 
 class JiraProcessor {
-
     private static final String FEATURE = "camel-jira";
     private static final String JIRA_MODEL_PACKAGE = 
"com.atlassian.jira.rest.client.api.domain";
+    private static final String DISPOSABLE_BEAN_CLASS_NAME = 
"org.springframework.beans.factory.DisposableBean";
 
     @BuildStep
     ExtensionSslNativeSupportBuildItem activateSslNativeSupport() {
@@ -80,4 +87,38 @@ class JiraProcessor {
         
items.add(ReflectiveClassBuildItem.builder("org.codehaus.jettison.json.JSONObject").methods(true).build());
         return items;
     }
+
+    @BuildStep(onlyIf = IsSpringBeansAbsent.class)
+    void generateDisposableInterface(BuildProducer<GeneratedClassBuildItem> 
generatedClass) {
+        // TODO: remove if https://ecosystem.atlassian.net/browse/JRJC-258 
eventually gets fixed
+        try (ClassCreator classCreator = ClassCreator.interfaceBuilder()
+                .className(DISPOSABLE_BEAN_CLASS_NAME)
+                .classOutput(new GeneratedClassGizmoAdaptor(generatedClass, 
false))
+                .build()) {
+
+            /*
+             * Original implementation of DisposableBean is:
+             *
+             * public interface DisposableBean {
+             *   void destroy() throws Exception;
+             * }
+             */
+            try (MethodCreator methodCreator = 
classCreator.getMethodCreator("destroy", void.class)) {
+                methodCreator.setModifiers(Modifier.PUBLIC | 
Modifier.ABSTRACT);
+                methodCreator.addException(Exception.class);
+            }
+        }
+    }
+
+    static final class IsSpringBeansAbsent implements BooleanSupplier {
+        @Override
+        public boolean getAsBoolean() {
+            try {
+                Class.forName(DISPOSABLE_BEAN_CLASS_NAME, true, 
Thread.currentThread().getContextClassLoader());
+                return false;
+            } catch (ClassNotFoundException e) {
+                return true;
+            }
+        }
+    }
 }
diff --git a/extensions/jira/runtime/pom.xml b/extensions/jira/runtime/pom.xml
index f6daed2b6c..d1bcba86b6 100644
--- a/extensions/jira/runtime/pom.xml
+++ b/extensions/jira/runtime/pom.xml
@@ -77,10 +77,6 @@
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-support-commons-logging</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.camel.quarkus</groupId>
-            <artifactId>camel-quarkus-support-spring</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.httpcomponents</groupId>
             <artifactId>httpclient-cache</artifactId>

Reply via email to