davsclaus commented on code in PR #30398:
URL: https://github.com/apache/camel/pull/30398#discussion_r4629325398
##########
core/camel-support/src/main/java/org/apache/camel/support/NormalizedUri.java:
##########
@@ -40,13 +50,41 @@ private NormalizedUri(String value) {
* @return the created normalized uri
*/
public static NormalizedUri newNormalizedUri(String uri, boolean
normalized) {
+ return newNormalizedUri(uri, normalized, false);
+ }
+
+ /**
+ * Creates a new {@link NormalizedUri} instance.
+ *
+ * @param uri the uri
+ * @param normalized whether its already normalized
+ * @param literalOptionBinding whether the uri was computed from the
current message, so its option values are
+ * bound as literal text: no property
placeholders, {@code #class:} or
+ * {@code #property:}; registry references
({@code #bean:}, {@code #type:}) are still
+ * resolved
+ * @return the created normalized uri
+ * @since 4.24
Review Comment:
Done in 6620f22e3674 (@since 4.18.6).
_Claude Code on behalf of Claus Ibsen_
##########
core/camel-support/src/main/java/org/apache/camel/support/NormalizedUri.java:
##########
@@ -40,13 +50,41 @@ private NormalizedUri(String value) {
* @return the created normalized uri
*/
public static NormalizedUri newNormalizedUri(String uri, boolean
normalized) {
+ return newNormalizedUri(uri, normalized, false);
+ }
+
+ /**
+ * Creates a new {@link NormalizedUri} instance.
+ *
+ * @param uri the uri
+ * @param normalized whether its already normalized
+ * @param literalOptionBinding whether the uri was computed from the
current message, so its option values are
+ * bound as literal text: no property
placeholders, {@code #class:} or
+ * {@code #property:}; registry references
({@code #bean:}, {@code #type:}) are still
+ * resolved
+ * @return the created normalized uri
+ * @since 4.24
+ */
+ public static NormalizedUri newNormalizedUri(String uri, boolean
normalized, boolean literalOptionBinding) {
if (normalized) {
- return new NormalizedUri(uri);
+ return new NormalizedUri(uri, literalOptionBinding);
} else {
- return new NormalizedUri(EndpointHelper.normalizeEndpointUri(uri));
+ return new NormalizedUri(EndpointHelper.normalizeEndpointUri(uri),
literalOptionBinding);
}
}
+ /**
+ * Whether this uri was computed from the current message at runtime, so
the option values of the endpoint created
+ * from it are bound as literal text: a property placeholder ({@code
{{...}}}), a {@code #class:} value or a
+ * {@code #property:} value is not resolved. Registry references ({@code
#bean:}, {@code #type:}) are still
+ * resolved.
+ *
+ * @since 4.24
Review Comment:
Done in 6620f22e3674 (@since 4.18.6).
_Claude Code on behalf of Claus Ibsen_
##########
core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java:
##########
@@ -111,10 +111,77 @@ public final class PropertyBindingSupport {
private PropertyBindingSupport() {
}
+ // a thread-scoped signal that the endpoint currently being created has a
uri computed from the current message at
+ // runtime (a dynamic endpoint such as
toD/enrich/wireTap/pollEnrich/recipientList/routingSlip/dynamicRouter), so
+ // its option values are bound as literal text. The CamelContext sets it
(in a try/finally) around
+ // Component#createEndpoint(String, Map) only. While it is set, the
Builder binds in literal mode, and resolveBean
+ // and EndpointHelper#resolveReferenceParameter refuse the values that are
kept literal, so every way a component
+ // binds its options is covered (generated configurers, setProperties
overloads, resolveAndRemoveReferenceParameter
+ // and direct use of this class).
+ private static final ThreadLocal<Boolean> LITERAL_OPTION_BINDING = new
ThreadLocal<>();
+
public static Builder build() {
return new Builder();
}
+ /**
+ * Whether the endpoint currently being created on this thread binds its
option values as literal text, because its
+ * uri was computed from the current message at runtime, see {@link
Builder#withLiteral(boolean)}.
+ *
+ * @return true if literal option binding is active on the current thread
+ * @since 4.24
Review Comment:
Done in 6620f22e3674 (@since 4.18.6).
_Claude Code on behalf of Claus Ibsen_
##########
core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java:
##########
@@ -111,10 +111,77 @@ public final class PropertyBindingSupport {
private PropertyBindingSupport() {
}
+ // a thread-scoped signal that the endpoint currently being created has a
uri computed from the current message at
+ // runtime (a dynamic endpoint such as
toD/enrich/wireTap/pollEnrich/recipientList/routingSlip/dynamicRouter), so
+ // its option values are bound as literal text. The CamelContext sets it
(in a try/finally) around
+ // Component#createEndpoint(String, Map) only. While it is set, the
Builder binds in literal mode, and resolveBean
+ // and EndpointHelper#resolveReferenceParameter refuse the values that are
kept literal, so every way a component
+ // binds its options is covered (generated configurers, setProperties
overloads, resolveAndRemoveReferenceParameter
+ // and direct use of this class).
+ private static final ThreadLocal<Boolean> LITERAL_OPTION_BINDING = new
ThreadLocal<>();
+
public static Builder build() {
return new Builder();
}
+ /**
+ * Whether the endpoint currently being created on this thread binds its
option values as literal text, because its
+ * uri was computed from the current message at runtime, see {@link
Builder#withLiteral(boolean)}.
+ *
+ * @return true if literal option binding is active on the current thread
+ * @since 4.24
+ */
+ public static boolean isLiteralOptionBinding() {
+ return Boolean.TRUE.equals(LITERAL_OPTION_BINDING.get());
+ }
+
+ /**
+ * Marks (or clears) the current thread as creating an endpoint whose
option values are bound as literal text. The
+ * caller MUST restore the returned previous value in a {@code finally}
block. The CamelContext does this around
+ * {@link org.apache.camel.Component#createEndpoint(String, Map)} when the
uri was computed from the current
+ * message.
+ *
+ * @param literalOptionBinding whether literal option binding is active
+ * @return the previous value, to be restored by the
caller
+ * @since 4.24
Review Comment:
Done in 6620f22e3674 (@since 4.18.6).
_Claude Code on behalf of Claus Ibsen_
--
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]