All,
Does anyone have recommendations for getting dependency injection of spring services to work for domain objects that are persisted by hibernate?
I have a case where it makes sense for a domain object to access a service that's managed by spring.
My software remotely manages PCs with different operating systems. I have low level services that deal with communicating with the PCs, and these services in turn use hibernate as well.
Let's say I have an interface called Computer, and various implementations - XPComputer, LinuxComputer, etc. which are persisted by hibernate.
Essentially, I want to be able to write code that looks like this:
and let polymorphism take care of the rest.Code:computer.reboot();
The implementations of the command could look like this:
Any ideas/recommendations about how this could be achieved?Code:XPComputer: void reboot() { xpCommunicationService.reboot(ipAddress); //xpCommunicationService is managed by spring } LinuxComputer: void reboot() { linuxCommunicationService.reboot(ipAddress); //linuxCommunicationService is managed by spring }
Thanks in advance!


Reply With Quote