As I understand it, an IoC container is useful when creating application-level objects, such as services and factories. But domain level objects must be created manually. The Spring manual says: "Normally, fine-grained domain objects are not defined in a container, because DAO and business logic are usually required to create / load domain objects."
Well. But what if my domain is a “fine-grained” object depending on some application-level object. For example, I have a UserViewer (user user, UserConstants). There, the user is a domain object that cannot be entered, but UserViewer also needs UserConstants, which is a high-level object injected by the IoC container.
I want to add UserConstants from an IoC container, but I also need a User runtime temporary parameter.
What is wrong with the design?
Thanks in advance!
UPDATE
It seems I was not accurate enough with my question. I really need an example of how to do this:
create an instance of the UserViewer class (User user, UserService service), where the user is passed as a parameter and the service is entered from IoC.
If I add a UserViewer viewer, then how do I pass it to the user?
If I create the UserViewer viewer manually, then how do I pass it?
source share