I am wondering how we could inject the user object (implements UserDetails) into a bean?
An Order object has an instance of user, I want to container automatically injects user (principal) into my order bean.
<bean id="order" class="Order" >
<property name="user" >?????</property>
</bean>
Currently, I am doing it in my service layer as:
Authentication authentication = context.getAuthentication();
if (authentication != null) {
if (authentication.getPrincipal() instanceof User) {
order.setUser((User) authentication.getPrincipal());
}
}



