cplusplus
cplusplus

Reputation: 102

How spring evaluates SPEL internally?

For example, we have an expression like this 'hasAnyRole("ROLE_1","ROLE_2")'

I know that Python has a function like eval to run code from a string. But how it works here? How Spring in Java parses the expression? Does it run it? If yes then how?

My primary question is how Python runs the string containing the expression. How does he understand what to do?

Upvotes: 1

Views: 634

Answers (1)

Gary Russell
Gary Russell

Reputation: 174514

SpEL has a full-blown parser and builds an AST for the expression.

In this case, the evaluation calls the hasAnyRole() method on the root object for the evaluation.

You can dig into the details in a debugger to see the actual workings.

Upvotes: 2

Related Questions