davsclaus commented on code in PR #26709:
URL: https://github.com/apache/camel/pull/26709#discussion_r4066222518


##########
components/camel-groovy/src/main/java/org/apache/camel/language/groovy/DefaultGroovyScriptCompiler.java:
##########
@@ -68,6 +71,7 @@ public class DefaultGroovyScriptCompiler extends 
ServiceSupport
     private static final Logger LOG = 
LoggerFactory.getLogger(DefaultGroovyScriptCompiler.class);
 
     private GroovyPreCompiledClassLoader groovyPreCompiledClassLoader;
+    private List<CompilePostProcessor> defaultPostProcessors;

Review Comment:
   Applied in 3207ae6e726b — the field is now an eager `final` `List.of(...)`.
   
   _Claude Code on behalf of davsclaus_



##########
components/camel-groovy/src/main/java/org/apache/camel/language/groovy/DefaultGroovyScriptCompiler.java:
##########
@@ -374,21 +378,29 @@ private void doCompileCode(Map<String, String> codes, 
List<String> cps) throws E
     }
 
     /**
-     * Runs the registered {@link CompilePostProcessor}s on a compiled class, 
as the Java DSL loader does for
-     * {@code .java} sources, so annotations such as {@link BindToRegistry} 
and {@link org.apache.camel.Converter} (and
-     * the Spring and Quarkus equivalents camel-jbang registers) work in 
Groovy sources as well. On a recompile (live
-     * reload) the bean is created and bound again, replacing the previous one.
+     * Runs the {@link CompilePostProcessor}s on a compiled class, as the Java 
DSL loader does for {@code .java}
+     * sources, so annotations such as {@link BindToRegistry} and {@link 
org.apache.camel.Converter} work in Groovy
+     * sources as well. The processors in the registry are used when there are 
any (camel-jbang registers processors
+     * that also handle the Spring and Quarkus annotations); otherwise the 
built-in processors for the Camel annotations
+     * are used, so a Groovy source works the same in every runtime. On a 
recompile (live reload) the bean is created
+     * and bound again, replacing the previous one.
      */
     private void postCompile(Class<?> clazz, byte[] byteCode) throws Exception 
{
-        Set<CompilePostProcessor> posts = 
camelContext.getRegistry().findByType(CompilePostProcessor.class);
-        if (posts == null || posts.isEmpty()) {
-            return;
-        }
         // only annotated classes are instantiated: a plain groovy class or 
script is a DTO or a
         // function library, and creating it here would only run its 
constructor for nothing
         if (clazz.getAnnotations().length == 0 || 
Script.class.isAssignableFrom(clazz)) {
             return;
         }
+        Collection<CompilePostProcessor> posts = 
camelContext.getRegistry().findByType(CompilePostProcessor.class);
+        if (posts == null || posts.isEmpty()) {
+            if (defaultPostProcessors == null) {
+                defaultPostProcessors = List.of(
+                        new TypeConverterCompilePostProcessor(),
+                        new EventNotifierCompilePostProcessor(),
+                        new BindToRegistryCompilePostProcessor());
+            }
+            posts = defaultPostProcessors;
+        }

Review Comment:
   Applied in 3207ae6e726b — the branch is now just `posts = 
defaultPostProcessors;`.
   
   _Claude Code on behalf of davsclaus_



-- 
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]

Reply via email to