A service is the entry point to the server-side of the application.
A service binds together a bunch of logical operations and connects them to the relevant DAOs. Therefore, the service must be injected with all relevant DAOs when it is instantiated. This is done in Spring.
The following definition needs only appear once in the Spring configuration as it defines the parent service:
<bean id="service" abstract="true" />
Define your service as a concrete bean:
<bean parent="service" id="authorizationService" class="net.sf.shineframework.tolls.services.impl.AuthorizationServiceImpl"> <property name="groupDao" ref="groupDao" /> </bean>
Each service method must use the @Transactional annotation to define the method as a transaction entry point. This definition, in addition to the regular Spring-based aop advices that start and end transactions, will also activate the following advices when necessary:
Methods marked as @Transactional are encouraged to make proper use of the readOnly property of this annotation.