I am designing the dao/service layer plus remoting layer of our app; trying to adhere to the DRY principle by using convention over configuration.
I can already automatically instantiate all service beans in one package using component-scan and autowiring for injecting the DAO's.
I am exposing the service like so:
And at the client side create them like this:Code:<bean class="org.springframework.remoting.rmi.RmiServiceExporter"> <property name="service" ref="personServiceImpl"/> <property name="serviceName" value="PersonService"/> <property name="serviceInterface" value="nl.huizemolenaar.obliprototype.service.IPersonService"/> </bean>
Is there an easy way to automatically expose all services in the package, and being able to automatically use them by their name at the client side?Code:<bean id="personService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean"> <property name="serviceUrl" value="rmi://${remote.server}/PersonService" /> <property name="serviceInterface" value="nl.huizemolenaar.obliprototype.service.IPersonService" /> </bean>
Example: I create a new ReservationService on the server side. I make a GUI bean that expects an IReservationService. I can directly inject the remote service by injecting the bean with the name "reservationService" without having to adjust the xml files.
Related question: I may create a lot of services; in the worst case one for each domain entity. Should I expose a new RMI Service for each of them, or should I make a single service for them all?
How can I still inject them by name on the client if I go this way?
Finally, I will probably also use both service/client side transparent caching with ehcache or jcs; it would be nice if this was done automatically too so I can still inject them by name.


Reply With Quote
