Service Tier
The service tier is mainly declarative. I mean, it doesn´t include Java code. The reason is that the application itself is too simple and this tier supposes a redundant indirection that could be omitted. This will occur frequently in the type of applications for which the library is thought, especially if the business logic focuses on the domain models themselves.
We use this layer only to to distinguish transactions in execution from PersistentService methods, a simple wrapper to Daos.
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" default-lazy-init="false" default-init-method="init"> <!-- Tx Advice --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <!-- the transactional semantics... --> <tx:attributes> <!-- all methods starting with 'get' and 'load' are read-only --> <tx:method name="get*" read-only="true"/> <tx:method name="load*" read-only="true"/> <!-- other methods use the default transaction settings --> <tx:method name="*"/> </tx:attributes> </tx:advice> <aop:config> <!-- Make all methods on package service transactional --> <aop:pointcut id="serviceOperation" expression="execution(* org.jdal.samples.library.service.*.*(..)) or execution(* info.joseluismartin.service.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation"/> </aop:config> <bean id="persistentService" class="info.joseluismartin.logic.PersistentManager"> <property name="dao" ref="basicDao"/> </bean> <bean id="bookService" class="info.joseluismartin.logic.PersistentManager"> <property name="dao" ref="bookDao"/> </bean> <bean id="authorService" class="org.jdal.samples.library.logic.AuthorManager"> <property name="dao" ref="authorDao"/> </bean> <bean id="categoryService" class="info.joseluismartin.logic.PersistentManager"> <property name="dao" ref="categoryDao"/> </bean> </beans>
Finally we have to perform the Presentation Layer