You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "zhfeng (via GitHub)" <gi...@apache.org> on 2023/06/21 08:03:09 UTC

[GitHub] [camel-quarkus] zhfeng commented on a diff in pull request #5001: Remove Spring dependencies from Jira extension

zhfeng commented on code in PR #5001:
URL: https://github.com/apache/camel-quarkus/pull/5001#discussion_r1236569715


##########
extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java:
##########
@@ -80,4 +87,38 @@ List<ReflectiveClassBuildItem> registerReflectiveClasses() {
         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);

Review Comment:
   Is it better to load class with TCCL?
   ```suggestion
                   Class.forName(DISPOSABLE_BEAN_CLASS_NAME, true, 
    Thread.currentThread().getContextClassLoader());
   ```



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org