How to 'get' the prototype beans cleanly ?
Hello !
I would like my other classes to interact with my domain's interfaces rather than implementation, so, i would like to avoid this, since i would like the benefit of being able to change the implementation later :
DomainModel myDomainModel = new DefaultDomainModelImpl();
If i use spring container, with the prototype scope, i can use something like :
// <bean id="myDomainBean" scope="prototype" class="kam.albert.content.domain.MyDomainImpl" />
DomainModel myDomainModel = springContext.getBean("myDomainBean");
But i would like to avoid accessing springContext explicitly in my code.
What's the clean way to do this ?
Im currently thinking of creating a factory implementation for each domain implementation, and autowire the factory to create the beans, but that means different implementations of my domain will have different implementations of the factory also.
Please share your opinions, thank you !