jamesnetherton commented on code in PR #30376:
URL: https://github.com/apache/camel/pull/30376#discussion_r4626330327


##########
components/camel-jq/src/main/java/org/apache/camel/language/jq/JqFunctions.java:
##########
@@ -19,106 +19,172 @@
 import java.util.List;
 import java.util.Map;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.NullNode;
-import com.fasterxml.jackson.databind.node.TextNode;
-import net.thisptr.jackson.jq.BuiltinFunctionLoader;
-import net.thisptr.jackson.jq.Expression;
-import net.thisptr.jackson.jq.Function;
-import net.thisptr.jackson.jq.PathOutput;
-import net.thisptr.jackson.jq.Scope;
-import net.thisptr.jackson.jq.Version;
-import net.thisptr.jackson.jq.Versions;
-import net.thisptr.jackson.jq.exception.JsonQueryException;
-import net.thisptr.jackson.jq.internal.tree.FunctionCall;
-import net.thisptr.jackson.jq.path.Path;
+import net.thisptr.jackson.jq.v2.core.EnvironmentBuilder;
+import net.thisptr.jackson.jq.v2.core.version.Versions;
+import net.thisptr.jackson.jq.v2.json.JsonNodeType;
+import net.thisptr.jackson.jq.v2.json.JsonProvider;
+import net.thisptr.jackson.jq.v2.json.impl.jackson3.Jackson3JsonProvider;
+import net.thisptr.jackson.jq.v2.spi.BindContext;
+import net.thisptr.jackson.jq.v2.spi.Expression;
+import net.thisptr.jackson.jq.v2.spi.Function;
+import net.thisptr.jackson.jq.v2.spi.FunctionSignature;
+import net.thisptr.jackson.jq.v2.spi.Output;
+import net.thisptr.jackson.jq.v2.spi.RuntimeContext;
+import net.thisptr.jackson.jq.v2.spi.annotations.FunctionRegistration;
+import net.thisptr.jackson.jq.v2.spi.exception.JsonQueryException;
+import net.thisptr.jackson.jq.v2.spi.path.Path;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.StreamCache;
 import org.apache.camel.util.concurrent.ContextValue;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
+import tools.jackson.databind.JsonNode;
+
+/**
+ * The Camel supplied jq functions.
+ * <p/>
+ * A new function must be annotated with {@link FunctionRegistration}, listed 
in
+ * {@code META-INF/services/net.thisptr.jackson.jq.v2.spi.Function} and added 
to {@link #CAMEL_FUNCTIONS}. The
+ * {@code ServiceLoader} lookup brings the functions to an environment that 
Camel does not build, such as one from a CDI
+ * producer, as a built environment cannot be changed. There a function of the 
same signature in another jar may win, as
+ * jackson-jq resolves such a clash in classpath order.
+ */
 public final class JqFunctions {
 
     public static final ContextValue<Exchange> EXCHANGE_LOCAL = 
ContextValue.newThreadLocal("JqExchange");
 
     private static final Logger LOGGER = 
LoggerFactory.getLogger(JqFunctions.class);
 
+    private static final Map<FunctionSignature, Function> CAMEL_FUNCTIONS = 
Map.of(
+            FunctionSignature.of(Header.NAME, 1), new Header(),
+            FunctionSignature.of(Header.NAME, 2), new Header(),
+            FunctionSignature.of(Property.NAME, 1), new Property(),
+            FunctionSignature.of(Property.NAME, 2), new Property(),
+            FunctionSignature.of(Constant.NAME, 1), new Constant(),
+            FunctionSignature.of(Constant.NAME, 2), new Constant(),
+            FunctionSignature.of(Variable.NAME, 1), new Variable(),
+            FunctionSignature.of(Variable.NAME, 2), new Variable(),
+            FunctionSignature.of(Body.NAME, 0), new Body());

Review Comment:
   Answered in the earlier thread 
(https://github.com/apache/camel/pull/30376#discussion_r4625838166): keeping 
`Map.of`, as going over the limit fails to compile at that line, so nothing can 
break at runtime.
   
   _Claude Code on behalf of jamesnetherton_



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