-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce SPI to configure the SpEL Indexer #26409
Comments
Can you please describe your use case and explain why you want to parse Jackson types in a SpEL expression? |
well, we are building up a code-less project which should store request context in JSON since it's data structure is completely dynamic. And this request context will be used by some handler by using config data. For example, if the request context looks like this: it is easy to implement only the fetch logic here. However we might also want to execute some functions and even a calculation. It is hard to finish it from scratch, and here SpEL comes into play, and that is why we need an extended mode for the Indexer class. |
How are you evaluating your SpEL expressions? Do you have custom setup for the |
yes, the context can config property accessor,however, that is no the case for arrayNode. an array item is accessed by the Indexer class which doesn't allow for extending |
That is precisely why we asked if you have custom setup for the I'm assuming you answered "yes" to that question. If that is not what you were answering "yes" to, please expound. In light of that, would it meet your needs if we made it possible to configure the |
yes, it is totally enough. |
@aclement, do you have time to introduce a new strategy for customizing the indexer? If not, simply providing some pseudo-code style tips regarding how you best foresee accomplishing this might be enough for a core committer to take over. |
Maybe I can help. I would try to provide a solution for this issue at weekend.
|
I just learned that Spring Integration has custom SpEL support for Jackson. See their JsonPropertyAccessor (and its nested Perhaps their is room for synergies between Spring Integration (SI) and Spring Framework regarding SI's current support, this issue, and #26323. @garyrussell, @artembilan, @aclement, and @jhoeller : thoughts? |
Right. We don't have any objections to move The To have a fix for #26323 would be a good addition, too. |
warping ArrayNode in a list seems good. however, I still commit a pr for this problem as an alternative. |
this solution looks like better than #26323 thus it would be possible for any type of indexer to make its own accessing implementation |
This comment was marked as off-topic.
This comment was marked as off-topic.
When indexing into an object, the target object can never be null. See spring-projectsgh-26409 See spring-projectsgh-26478
Prior to this commit, the read() method in the IndexAccessor SPI declared a return type of ValueRef which introduced a package cycle. This commit addresses this by aligning with the PropertyAccess SPI and returning TypedValue from IndexAccessor's read() method. This commit also reworks the internals of Indexer based on a new, local IndexAccessorValueRef implementation. See spring-projectsgh-26409 See spring-projectsgh-26478
Prior to this commit, the read() method in the IndexAccessor SPI declared a return type of ValueRef which introduced a package cycle. This commit addresses this by aligning with the PropertyAccess SPI and returning TypedValue from IndexAccessor's read() method. This commit also reworks the internals of Indexer based on a new, local IndexAccessorValueRef implementation. See gh-26409 See gh-26478
This set of commits introduces a new IndexAccessor SPI for the Spring Expression Language (SpEL) which allows third parties to customize the SpEL Indexer. A custom IndexAccessor implementation can be registered in a StandardEvaluationContext. For an example, see the JacksonArrayNodeIndexAccessor in IndexingTests in the spring-expression module. See gh-26409 Closes gh-26478
The SpEL indexer doesn't provide support for Jackson's
ArrayNode
, and it seems to be non-extensible; whereas, a JacksonObjectNode
can be operated on within a SpEL expression viaPropertyAccessor
support.The text was updated successfully, but these errors were encountered: