dependency injection - Inversion of control domain objects construction problem -


As I understand, IoC-container is useful in building application-level objects such as services and factories. But domain-level objects should be made manually The Spring Manual tells us: "Usually does not configure objects in the container, because it is usually the responsibility of the DAO and there is business logic for creating / loading domain objects."

Good. But what if my domain "Fine" object depends on some application-level object. For example, I have a UserViewer class (User User, User Constant Constraint) class. There is a user domain object that can not be injected, but UserViewer also needs high-level objects injected by the UOC-container.

I want to inject UserConstants from IOC container, but also me

UPDATE

It seems that I was not quite accurate with my question What exactly do I need to do this example:

class UserViewer (user user, user service service) , where the user has been passed as the parameter and service are injected with IOC is.

How do I pass the user if I inject the UserViewer viewer

If I manually Form the UserViewer viewer how do I pass it service ?

There is nothing wrong in this design, you use factory for this , Which has a leg in the domain, has a foot in the infrastructure.

You can write them manually or the container can do this for you things like Windsor.

Also, when your domain objects come from the firmness layer, you can plug your container inject to the services they want (NHibernate can do this).


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -