I want to pass property values assigned in an XML file to a Spring (SpEL) expression in Java. Can you tell me how to achieve this? To make it clear, I gave the following example.
example.xml file:
<beans>
<bean id="user" class="x.y.User">
<property name="name" value="A"/>
<property name="userId" value="33"/>
<bean id="customer" class="x.y.Customer">
<property name="name" value="B"/>
<property name="customerId" value="33"/>
</bean>
</beans>
Keep in mind that I have user and client model classes.
I want to protect a method called "edit" with the Pre-Authorize annotation and Spring expressions as follows.
@PreAuthorize("(#user.userId == #customer.customerId)")
public Boolean edit(User user, Customer custmer) {
return true;
}
The question is, how do I pass the userId and customerId values from the example.xml file into the above expression to compare the two values and then protect the “edit” method?
. . , , . !