diff --git a/.springBeans b/.springBeans index 2bef418560110b8b481c1c5bc941a96a85325243..a22a616d68cb53761a055f5f45a18c85fdfe35e2 100644 --- a/.springBeans +++ b/.springBeans @@ -8,7 +8,26 @@ <enableImports><![CDATA[false]]></enableImports> <configs> <config>src/main/webapp/WEB-INF/mvc-core-config.xml</config> + <config>src/main/webapp/WEB-INF/mvc-view-config.xml</config> + <config>src/main/resources/spring/dao-config.xml</config> + <config>src/main/resources/spring/datasource-config.xml</config> + <config>src/main/resources/spring/service-config.xml</config> </configs> <configSets> + <configSet> + <name><![CDATA[config]]></name> + <allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding> + <incomplete>false</incomplete> + <configs> + <config>src/main/webapp/WEB-INF/mvc-core-config.xml</config> + <config>src/main/webapp/WEB-INF/mvc-view-config.xml</config> + <config>src/main/resources/spring/dao-config.xml</config> + <config>src/main/resources/spring/datasource-config.xml</config> + <config>src/main/resources/spring/jmx-aop-config.xml</config> + <config>src/main/resources/spring/service-config.xml</config> + </configs> + <profiles> + </profiles> + </configSet> </configSets> </beansProjectDescription> diff --git a/src/main/java/org/springframework/samples/petclinic/aspects/CallMonitoringAspect.java b/src/main/java/org/springframework/samples/petclinic/aspects/CallMonitoringAspect.java index c6d88878c9efc450104446b428b1db866586c154..234a25be0606da2c2d2bc1f7b28b8821bd197609 100644 --- a/src/main/java/org/springframework/samples/petclinic/aspects/CallMonitoringAspect.java +++ b/src/main/java/org/springframework/samples/petclinic/aspects/CallMonitoringAspect.java @@ -2,8 +2,10 @@ package org.springframework.samples.petclinic.aspects; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedOperation; +import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.util.StopWatch; /** @@ -12,10 +14,11 @@ import org.springframework.util.StopWatch; * * @author Rob Harrop * @author Juergen Hoeller + * @author Michael Isvy * @since 2.5 */ -//@ManagedResource("petclinic:type=CallMonitor") -//@Aspect +@ManagedResource("petclinic:type=CallMonitor") +@Aspect public class CallMonitoringAspect { private boolean isEnabled = true; diff --git a/src/main/java/org/springframework/samples/petclinic/aspects/UsageLogAspect.java b/src/main/java/org/springframework/samples/petclinic/aspects/UsageLogAspect.java deleted file mode 100644 index a8a4d51e1941b41f0afcf343ba4b6676d5fa238a..0000000000000000000000000000000000000000 --- a/src/main/java/org/springframework/samples/petclinic/aspects/UsageLogAspect.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.springframework.samples.petclinic.aspects; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; - -/** - * Sample AspectJ annotation-style aspect that saves - * every owner name requested to the petRepository. - * - * @author Rod Johnson - * @author Juergen Hoeller - * @since 2.0 - */ -@Aspect -public class UsageLogAspect { - - private int historySize = 100; - - // Of course saving all names is not suitable for - // production use, but this is a simple example. - private List<String> namesRequested = new ArrayList<String>(this.historySize); - - - public synchronized void setHistorySize(int historySize) { - this.historySize = historySize; - this.namesRequested = new ArrayList<String>(historySize); - } - - @Before("execution(* *.find*(String)) && args(name)") - public synchronized void logNameRequest(String name) { - // Not the most efficient implementation, - // but we're aiming to illustrate the power of - // @AspectJ AOP, not write perfect code here :-) - if (this.namesRequested.size() > this.historySize) { - this.namesRequested.remove(0); - } - this.namesRequested.add(name); - } - - public synchronized List<String> getNamesRequested() { - return Collections.unmodifiableList(this.namesRequested); - } - -} diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java index 04a8aea5641262ac392b1c653484a4957e7de9b6..0b35952a2e4f3a547ea7084f8b90b3a7571a4d93 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java @@ -22,7 +22,7 @@ import org.springframework.samples.petclinic.Visit; import org.springframework.samples.petclinic.repository.OwnerRepository; import org.springframework.samples.petclinic.repository.VisitRepository; import org.springframework.samples.petclinic.util.EntityUtils; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; /** @@ -36,7 +36,7 @@ import org.springframework.transaction.annotation.Transactional; * @author Thomas Risberg * @author Mark Fisher */ -@Service +@Repository public class JdbcOwnerRepositoryImpl implements OwnerRepository { private VisitRepository visitRepository; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java index 60e9ef92ab302403923f64d1008318e1a1468bf5..c6acf372159f0e85453d735a6236fa2515cf17ee 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java @@ -18,7 +18,7 @@ import org.springframework.samples.petclinic.Specialty; import org.springframework.samples.petclinic.Vet; import org.springframework.samples.petclinic.repository.VetRepository; import org.springframework.samples.petclinic.util.EntityUtils; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; /** @@ -30,7 +30,7 @@ import org.springframework.transaction.annotation.Transactional; * @author Thomas Risberg * @author Mark Fisher */ -@Service +@Repository public class JdbcVetRepositoryImpl implements VetRepository { private final Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java index 52519eecef79cab78662239a0bb590c0f4dd6590..5be02e79498465f151c0dc0c60cf1328c4884bd8 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java @@ -17,7 +17,7 @@ import org.springframework.jdbc.core.simple.SimpleJdbcInsert; import org.springframework.samples.petclinic.Visit; import org.springframework.samples.petclinic.repository.VisitRepository; import org.springframework.samples.petclinic.service.ClinicService; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Repository; /** * A simple JDBC-based implementation of the {@link ClinicService} interface. @@ -31,7 +31,7 @@ import org.springframework.stereotype.Service; * @author Mark Fisher * @author Michael Isvy */ -@Service +@Repository public class JdbcVisitRepositoryImpl implements VisitRepository { private JdbcTemplate jdbcTemplate; diff --git a/src/main/resources/spring/applicationContext-dao.xml b/src/main/resources/spring/dao-config.xml similarity index 72% rename from src/main/resources/spring/applicationContext-dao.xml rename to src/main/resources/spring/dao-config.xml index f74d0cf4ca637b599d9696c473c6470c9f9342a1..80ea4fbf86dbf2db0f0b08b7611e7a93f5e99dd3 100644 --- a/src/main/resources/spring/applicationContext-dao.xml +++ b/src/main/resources/spring/dao-config.xml @@ -3,19 +3,17 @@ Application context definition for PetClinic on JPA. --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" - xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" - xmlns:jpa="http://www.springframework.org/schema/data/jpa" - xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd + xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" + xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- ========================= RESOURCE DEFINITIONS ========================= --> <!-- import the dataSource definition --> - <import resource="applicationContext-dataSource.xml"/> + <import resource="datasource-config.xml"/> <!-- Configurer that replaces ${...} placeholders with values from a properties file --> @@ -40,28 +38,6 @@ --> <tx:annotation-driven/> - <!-- - Simply defining this bean will cause requests to owner names to be saved. - This aspect is defined in petclinic.jar's META-INF/aop.xml file. - Note that we can dependency inject this bean like any other bean. - --> - <aop:aspectj-autoproxy> - <aop:include name="usageLogAspect"/> - <aop:include name="callMonitor"/> - </aop:aspectj-autoproxy> - <bean id="usageLogAspect" class="org.springframework.samples.petclinic.aspects.UsageLogAspect" p:historySize="300"/> - - <!-- Call monitoring aspect that monitors call count and call invocation time --> - <bean id="callMonitor" class="org.springframework.samples.petclinic.aspects.CallMonitoringAspect"/> - - <!-- - Exporter that exposes the Clinic DAO and the CallMonitoringAspect via JMX, - based on the @ManagedResource, @ManagedAttribute, and @ManagedOperation annotations. - --> - <context:mbean-export/> - - - <beans profile="jpa,spring-data-jpa"> <!-- JPA EntityManagerFactory --> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" diff --git a/src/main/resources/spring/applicationContext-dataSource.xml b/src/main/resources/spring/datasource-config.xml similarity index 100% rename from src/main/resources/spring/applicationContext-dataSource.xml rename to src/main/resources/spring/datasource-config.xml diff --git a/src/main/resources/spring/jmx-aop-config.xml b/src/main/resources/spring/jmx-aop-config.xml new file mode 100644 index 0000000000000000000000000000000000000000..3dc3c35cf74317f03a152704e6a6d56a0387d73c --- /dev/null +++ b/src/main/resources/spring/jmx-aop-config.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Application context definition for PetClinic on JPA. +--> +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> + + <!-- + Simply defining this bean will cause requests to owner names to be saved. + This aspect is defined in petclinic.jar's META-INF/aop.xml file. + Note that we can dependency inject this bean like any other bean. + --> + <aop:aspectj-autoproxy> + <aop:include name="callMonitor"/> + </aop:aspectj-autoproxy> + + <!-- Call monitoring aspect that monitors call count and call invocation time --> + <bean id="callMonitor" class="org.springframework.samples.petclinic.aspects.CallMonitoringAspect"/> + + <!-- + Exporter that exposes the CallMonitoringAspect via JMX, + based on the @ManagedResource, @ManagedAttribute, and @ManagedOperation annotations. + --> + <context:mbean-export /> + +</beans> \ No newline at end of file diff --git a/src/main/resources/spring/service-config.xml b/src/main/resources/spring/service-config.xml new file mode 100644 index 0000000000000000000000000000000000000000..99ef66db79ea9739efb4e25fa39edb3dfbcaabe3 --- /dev/null +++ b/src/main/resources/spring/service-config.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Application context definition for PetClinic on JPA. +--> +<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" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> + + + <context:component-scan base-package="org.springframework.samples.petclinic.service"/> + +</beans> \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp b/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp index f360fec67ed14239c4ef5110377197abb1cbd2d3..f8f4645c75c20e033c79617f5d4d7d92cff9cdea 100644 --- a/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp +++ b/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp @@ -8,9 +8,9 @@ <ul class="nav"> <li style="width: 100px;"><a href="<spring:url value="/" htmlEscape="true" />"><i class="icon-home"></i> Home</a></li> <li style="width: 130px;"><a href="<spring:url value="/owners/find.html" htmlEscape="true" />"><i class="icon-search"></i> Find owners</a></li> - <li style="width: 130px;"><a href="<spring:url value="/vets.html" htmlEscape="true" />"><i class="icon-th-list"></i> Veterinarians</a></li> - <li style="width: 100px;"><a href="<spring:url value="/resources/html/tutorial.html" htmlEscape="true" />"><i class=" icon-question-sign"></i> Tutorial</a></li> - <li style="width: 80px;"><a href="<spring:url value="/oups.html" htmlEscape="true" />" title="trigger a RuntimeException to see how it is handled"><i class="icon-warning-sign"></i> Error</a></li> + <li style="width: 140px;"><a href="<spring:url value="/vets.html" htmlEscape="true" />"><i class="icon-th-list"></i> Veterinarians</a></li> + <li style="width: 90px;"><a href="<spring:url value="/oups.html" htmlEscape="true" />" title="trigger a RuntimeException to see how it is handled"><i class="icon-warning-sign"></i> Error</a></li> + <li style="width: 80px;"><a href="#" title="not available yet. Work in progress!!"><i class=" icon-question-sign"></i> Help</a></li> </ul> </div> </div> diff --git a/src/main/webapp/WEB-INF/mvc-core-config.xml b/src/main/webapp/WEB-INF/mvc-core-config.xml index 6ce11a4a6efbff6b42c47488ef8101aa68079b6c..3b1a242bbbb33d721defbef6b28666983e4187e6 100644 --- a/src/main/webapp/WEB-INF/mvc-core-config.xml +++ b/src/main/webapp/WEB-INF/mvc-core-config.xml @@ -15,7 +15,7 @@ <!-- - POJOs labeled with the @Controller and @Service annotations are auto-detected. --> - <context:component-scan base-package="org.springframework.samples.petclinic.web, org.springframework.samples.petclinic.service"/> + <context:component-scan base-package="org.springframework.samples.petclinic.web"/> <mvc:annotation-driven conversion-service="conversionService"/> diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 7162fdc46ac508081de5160c82b0a727bc4e5341..0dfdc6bf0746cc763946bb0e5410407bd044f6b6 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -23,7 +23,7 @@ id="WebApp_ID" version="2.5"> --> <context-param> <param-name>contextConfigLocation</param-name> - <param-value>classpath:spring/applicationContext-dao.xml</param-value> + <param-value>classpath:spring/dao-config.xml, classpath:spring/service-config.xml, classpath:spring/jmx-aop-config.xml</param-value> </context-param> <listener> diff --git a/src/main/webapp/resources/html/tutorial.html b/src/main/webapp/resources/html/tutorial.html deleted file mode 100644 index 13250f174daf1108072c8b2b99f56182139030da..0000000000000000000000000000000000000000 --- a/src/main/webapp/resources/html/tutorial.html +++ /dev/null @@ -1,1114 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>The Spring PetClinic Application</title> - <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> - <link rel="stylesheet" href="../css/petclinic.css" type="text/css"> -</head> - -<body> - -<div id="main"> - - <h1>The Spring PetClinic Application</h1> - - <!-- - <table class="updated"> - <tr><td>Updated:</td><td>25.NOV.2009</td><td>Costin Leau(<strong>Work In Progress: not yet fully updated regarding Spring 3.0</strong>)</td></tr> - <tr><td></td><td>11.OCT.2009</td><td>Sam Brannen</td></tr> - <tr><td></td><td>21.OCT.2007</td><td>Sam Brannen</td></tr> - <tr><td></td><td>30.JUN.2006</td><td>Costin Leau</td></tr> - <tr><td></td><td>01.DEC.2004</td><td>Ken Krebs</td></tr> - <tr><td></td><td>16.AUG.2003</td><td>Ken Krebs</td></tr> - </table> - --> - -<!-- === INTRODUCTION ====================================================== --> - <h2>Introduction</h2> - - <p> - The Spring Framework is a collection of small, well-focused, loosely coupled Java - frameworks that can be used independently or collectively to build - industrial strength applications of many different types. The PetClinic - sample application is designed to show how the Spring - framework can be used to build simple, but powerful - database-oriented applications. It will demonstrate the use - of Spring's core functionality: - </p> - - <ul> - <li>Dependency Injection using xml and annotations</li> - <li>Practical database access through JDBC and JPA (Java Persistence API)</li> - <li>Application monitoring based on JMX</li> - <li>Declarative Transaction Management using annotations</li> - <li>Web Presentation Layer based on Spring MVC</li> - <li>Data Validation based on Bean Validation (JSR 303)</li> - </ul> - - <p> - The Spring framework provides a great deal of useful infrastructure to - simplify the tasks faced by application developers. This infrastructure - helps developers to create applications that are: - </p> - - <ul> - <li> - <span style="font-weight: bold; text-decoration: underline;">concise</span> - by handling a lot of the complex control flow that is needed to use the - Java API's, such as JDBC, JNDI, JTA, RMI. - </li> - <li> - <span style="font-weight: bold; text-decoration: underline;">flexible</span> - by simplifying the process of external application configuration - through the use of Reflection and POJOs (Plain Old Java Objects). This allows the developer to - achieve a clean separation of configuration data from application code. - All application and web application objects, including validators, - workflow controllers, and views, are POJOs that can be configured - externally.</li> - <li> - <span style="font-weight: bold; text-decoration: underline;">testable</span> - by supplying an interface based design to maximize pluggability. This - facilitates unit testing of Business Logic without requiring the - presence of application or live database servers.</li> - <li> - <span style="font-weight: bold; text-decoration: underline;">maintainable</span> - by facilitating a clean separation of the application layers. It most - importantly helps maintain the independence of the Business Layer - from the Presentation layer. PetClinic demonstrates the use of a - Model-View-Controller - based web presentation framework that can work seamlessly with many - different types of view technologies. Spring MVC helps developers implement their Presentation as a clean - and thin layer focused on its main missions of translating user actions - into application events and rendering model data.</li> - </ul> - - <p> - It is assumed that users of this tutorial will have a basic knowledge - of object-oriented design, Java, Servlets, JSP, and relational - databases. It also assumes a basic knowledge of the use of a Java EE web - application container. - </p> - - <p> - Since the purpose of the sample application is tutorial in nature, the - implementation presented here will of course provide only a small - subset of the functionality that would be needed by a real world version of a - PetClinic application. - </p> - -<!-- === REQUIREMENTS ====================================================== --> - <h2>PetClinic Sample Application Requirements</h2> - - <p> - The application requirement is for an information system that is - accessible through a web browser. The users of the application are - employees of the clinic who in the course of their work need to view - and manage information regarding the veterinarians, the clients, and their - pets. The sample application supports the following: - </p> - - <h3>Use Cases</h3> - <ul> - <li>View a list of veterinarians and their specialties</li> - <li>View information pertaining to a pet owner</li> - <li>Update the information pertaining to a pet owner</li> - <li>Add a new pet owner to the system</li> - <li>View information pertaining to a pet</li> - <li>Update the information pertaining to a pet</li> - <li>Add a new pet to the system</li> - <li>View information pertaining to a pet's visitation history</li> - <li>Add information pertaining to a visit to the pet's visitation history</li> - </ul> - - <h3>Business Rules</h3> - <ol> - <li>An owner may not have multiple pets with the same case-insensitive name.</li> - </ol> - -<!-- === DESIGN AND IMPLEMENTATION ========================================= --> - <h2>PetClinic Sample Application Design & Implementation</h2> - - <h3>Server Technology</h3> - <p> - The sample application should be usable with any Java EE web application - container that is compatible with the Servlet 2.4 and JSP 2.0 - specifications. - The view technologies that are to be used for rendering the application are Java Server Pages - (JSP) along with the Java Standard Tag Library (JSTL). - </p> - - <h3>Database Technology</h3> - <p> - The sample application uses a relational database for data storage. - Support has been provided for a choice of 1 of 2 database selections, - MySql or HypersonicSQL. HypersonicSQL is the default - choice. It is possible to easily configure the application to use either database. - Configuration details are provided in the Developer Instructions section. - </p> - - <h3>Development Environment</h3> - <p> - A copy of the Spring runtime library jar file is provided with the - sample application along with some of the other required jar files. The - developer will need to obtain the following tools externally, all of - which are freely available: - </p> - - <ul> - <li>Java SDK 1.6.x</li> - <li>Maven 3.0+</li> - <li>Tomcat 6.0+, or some other Java Servlet container</li> - <li>(Optional) MySQL 5.x with MySQL Connector/J 5.x</li> - </ul> - - <p> - <strong>NOTE:</strong> The version numbers listed are those that were used - in the development of the PetClinic application. Other versions of the same - tools may or may not work. - </p> - - <p> - Download links for the various tools needed are provided in the Developer - Instructions section. - </p> - - <h3>PetClinic Database</h3> - <p> - The following is an overview of the database schema used in PetClinic. - Detailed field descriptions can be found in the - <span style="font-weight: bold; font-style: italic;">"initDB.txt"</span> - SQL script files in the database-specific "db" sub-directories. All "id" key - fields are of Java type <span style="font-weight: bold; font-style: italic;">int</span>. - </p> - - <p> - TABLE: <span style="font-weight: bold; font-style: italic;">owners</span><br> - PRIMARY KEY <span style="font-weight: bold;">id</span> - </p> - - <p> - TABLE: <span style="font-weight: bold; font-style: italic;">types</span><br> - PRIMARY KEY <span style="font-weight: bold;">id</span> - </p> - - <p> - TABLE: <span style="font-weight: bold; font-style: italic;">pets</span><br> - PRIMARY KEY <span style="font-weight: bold;">id</span><br> - FOREIGN KEY <span style="font-weight: bold;">type_id</span> - references the <span style="font-weight: bold; font-style: italic;">types</span> - table<span style="font-weight: bold;"> id</span> field<br> - FOREIGN KEY <span style="font-weight: bold;">owner_id</span> - references the <span style="font-weight: bold; font-style: italic;">owners</span> - table <span style="font-weight: bold;">id</span> field - </p> - - <p> - TABLE: <span style="font-weight: bold; font-style: italic;">vets</span><br> - PRIMARY KEY <span style="font-weight: bold;">id</span> - </p> - - <p> - TABLE: <span style="font-weight: bold; font-style: italic;">specialties</span><br> - PRIMARY KEY <span style="font-weight: bold;">id</span><br> - </p> - - <p> - TABLE: <span style="font-weight: bold; font-style: italic;">vet_specialties</span> - - a link table for <span style="font-weight: bold; font-style: italic;">vets</span> - and their <span style="font-weight: bold; font-style: italic;">specialties</span><br> - FOREIGN KEY <span style="font-weight: bold;">vet_id</span> - references the <span style="font-weight: bold; font-style: italic;">vets</span> - table<span style="font-weight: bold;"> id</span> field<br> - FOREIGN KEY <span style="font-weight: bold;">specialty_id</span> - references the <span style="font-weight: bold; font-style: italic;">specialties</span> - table <span style="font-weight: bold;">id</span> field - </p> - - <p> - TABLE: <span style="font-weight: bold; font-style: italic;">visits</span><br> - PRIMARY KEY <span style="font-weight: bold;">id</span><br> - FOREIGN KEY <span style="font-weight: bold;">pet_id</span> - references the <span style="font-weight: bold; font-style: italic;">pets</span> - table <span style="font-weight: bold;">id</span> field - </p> - - <h3>Directory Structure</h3> - - <p> - d-- indicates a directory holding source code, configuration files, etc.<br> - D-- indicates a directory that is created by the build script - </p> - - <p> - d-- <span style="font-weight: bold; font-style: italic;">petclinic</span>: - the root directory of the project contains build related files<br> - - d-- <span style="font-weight: bold; font-style: italic;">src</span>: contains - Java source code files and ORM configuration files<br> - - d-- <span style="font-weight: bold; font-style: italic;">war</span>: contains - the web application resource files<br> - - d-- <span style="font-weight: bold; font-style: italic;">html</span>: contains - tutorial files<br> - - D-- <span style="font-weight: bold; font-style: italic;">docs</span>: contains - Javadoc files<br> - - d-- <span style="font-weight: bold; font-style: italic;">web-inf</span>: - contains web application configuration files and application context - files<br> - - - d-- <span style="font-weight: bold; font-style: italic;">jsp</span>: - contains Java Server Page files<br> - - - D--<span style="font-weight: bold;"> <span style="font-style: italic;">lib</span></span>: - contains application dependencies<br> - - d-- <span style="font-weight: bold; font-style: italic;">test</span>: contains - testing related - Java source code files<br> - - d-- <span style="font-weight: bold; font-style: italic;">db</span>: contains - database SQL scripts and other related files/directories<br> - - d-- <span style="font-weight: bold; font-style: italic;">hsqldb</span>: - contains files related to HSQL, contains scripts and a Tomcat - context definition file<br> - - d-- <span style="font-weight: bold; font-style: italic;">mysql</span>: - contains files related to MySQL, contains scripts and a Tomcat context - definition file<br> - - D-- <span style="font-weight: bold; font-style: italic;">.classes</span>: - contains compiled Java class files<br> - - D-- <span style="font-weight: bold; font-style: italic;">.testclasses</span>: - contains compiled testing related Java class files<br> - - D-- <span style="font-weight: bold; font-style: italic;">junit-reports</span>: - contains generated xml-formatted test reports<br> - - D-- <span style="font-weight: bold; font-style: italic;">reports/html</span>: - contains generated html-formatted test reports<br> - - D-- <span style="font-weight: bold; font-style: italic;">dist</span>: contains - packaged archives of files - </p> - -<!-- === DESIGN ============================================================ --> - <h2>PetClinic Application Design</h2> - - <h3>Logging</h3> - <p> - Spring supports the use of the Apache Commons Logging API. This API - provides the ability to use Java SE loggers, the simple Commons loggers, - and Apache Log4J loggers. PetClinic uses Log4J. The file, - <span style="font-weight: bold; font-style: italic;">src/main/resources/log4j.xml</span> - configures the definition of <strong>Log4J</strong> loggers. - </p> - - <h3>Business Layer</h3> - <p> - The Business Layer consists of a number of basic Java classes - representing the application domain objects and associated validation - objects that are used by the Presentation Layer. The validation objects - used in PetClinic are all implementations of the - <strong>org.springframework.validation.Validator</strong> interface. - </p> - - <ul> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.Entity</span> - is a superclass used for all persistable objects.</li> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.NamedEntity</span> - is an extension of <span style="font-weight: bold;">Entity</span> that adds a name property.</li> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.Specialty</span> - is an extension of <span style="font-weight: bold;">NamedEntity</span>.</li> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.PetType</span> - is an extension of <span style="font-weight: bold;">NamedEntity</span>.</li> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.Person</span> is - an extension of <span style="font-weight: bold;">Entity</span> that provides a superclass for all objects that - implement the notion of a person.</li> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.Vet</span> is - an extension of <span style="font-weight: bold;">Person</span> that implements a - veterinarian. It holds a <span style="font-weight: bold;">List</span> of - specialties that the <span style="font-weight: bold;">Vet</span> is capable of.</li> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.Owner</span> - is an extension of <span style="font-weight: bold;">Person</span> that implements a pet owner. - It holds a <span style="font-weight: bold;">List</span> of pets owned.</li> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.Pet</span> - is an extension of <span style="font-weight: bold;">NamedEntity</span> that - implements a pet. It holds a <span style="font-weight: bold;">List</span> of - visits made concerning the pet.</li> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.Visit</span> - is a simple JavaBean that implements the notion of a clinic visit - for a pet. </li> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.util.EntityUtils</span> - provides utility methods for handling entities.</li> - </ul> - - <h3>Business / Persistence Layer</h3> - - <p> - Since the PetClinic application is all about database access and there is - very little business logic in the application outside of that, there is - no separation of the primary Business and Persistence Layer API's. - While this design technique should not be used for an application with more - complex business logic, it is acceptable here because all of the - non-persistence related business rules have been implemented in - business objects and have not leaked into the Persistence Layer. The most - important facet of the design is that the Business and Persistence - Layers are <strong>COMPLETELY</strong> independent of the Presentation Layer. - </p> - - <p> - The Persistence Layer can be configured to use either HSQL or MySQL - with any one of the following data access technologies aided by - infrastructure provided by Spring: - </p> - - <ul> - <li>JDBC (using Spring's JdbcTemplate)</li> - <li>JPA</li> - </ul> - - <p> - <span style="font-weight: bold;">NOTE:</span> Spring also provides - infrastructure for using other - <strong>O</strong>bject/<strong>R</strong>elational <strong>M</strong>apping - frameworks such as JDO and iBATIS SqlMaps, but these are not demonstrated in PetClinic. - (See the 'jpetstore' sample application that ships with the full Spring Framework - distribution for an example of using iBatis and Spring.) - </p> - - <p> - One of the key elements provided by Spring is the use of a common set - of meaningful data access exceptions that can be used regardless of - which database or access strategy is used. All of these exceptions - derive from <strong>org.springframework.dao.DataAccessException</strong>. - Since most exceptions encountered during database access are indicative - of programming errors, <strong>DataAccessException</strong> is an - abstract <strong>RuntimeException</strong> whose derivatives only need - to be caught by application code to handle recoverable errors when it - makes sense to do so. This greatly simplifies application code compared - to, for example, code using JDBC directly where <strong>SqlExceptions</strong> - must be caught and database specific error codes must be decoded. - Examination of the PetClinic source code will show that the - persistence-oriented code is completely focused on the relevant - transfer of data to/from the referenced objects without extraneous - error handling. - </p> - - <p> - The high-level business/persistence API for PetClinic is the - <span style="font-weight: bold;">org.springframework.samples.petclinic.Clinic</span> - interface. Each persistence strategy in PetClinic is a different implementation of the - <span style="font-weight: bold;">Clinic</span> interface. In each case, the - <span style="font-weight: bold;">Clinic</span> implementation is fronted by - a transactional proxy, configured via the - <span style="font-weight: bold;">@Transactional</span> annotation, that also - implements <span style="font-weight: bold;">Clinic</span>. These objects - are standard Java dynamic proxies which are created by an instance of - <span style="font-weight: bold;">org.springframework.transaction.interceptor.TransactionProxyFactoryBean</span>. - These proxies are configured in the respective application context file - via <strong><tx:annotation-driven /></strong> and specify that all - <span style="font-weight: bold;">Clinic</span> methods are run in a - transactional context. The transaction managers used in PetClinic are all - implementations of the - <span style="font-weight: bold;">org.springframework.transaction.PlatformTransactionManager</span> - interface. All of the implementations are by default configured - to use Database connection pooling <span style="font-weight: bold;">through</span> - an instance of <span style="font-weight: bold;">org.apache.commons.dbcp.BasicDataSource</span>. - Another alternative would be to obtain one through the Java EE environment - using an instance of - <span style="font-weight: bold;">org.springframework.jndi.JndiObjectFactoryBean</span>. - </p> - - <h3>JDBC Repository Implementations</h3> - <p> - Spring provides a number of high-level database - access convenience classes in the package - <span style="font-weight: bold;">org.springframework.jdbc.object</span>. - These classes and the lower-level Spring classes that they use in the - <span style="font-weight: bold;">org.springframework.jdbc.core</span> package - provide a higher level of abstraction for using JDBC that keeps the developer - from having to correctly implement the handling of the checked - <span style="font-weight: bold;">SqlExceptions</span> with ugly error-prone - nested try-catch-finally blocks. Using the classes in this package - allows the developer to focus efforts on the functionality being - implemented rather than the mechanics of error handling. When using - these classes, it is the responsibility of the developer to provide the - SQL needed and to map the parameters to/from the respective domain - object. This typically is done by extending one of the - <span style="font-weight: bold;">org.springframework.jdbc.object</span> classes, - initializing its SQL, and overriding a method that takes care of - the mapping. In this way, the developer gets to focus on implementing - functionality rather than application plumbing. These classes also - take care of closing connections to prevent hard to find resource - leakage problems. It should be noted that instances of these classes - are lightweight, reusable, and threadsafe. - </p> - - <p> - The JDBC Repository implementations are located inside - <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.repository.jdbc</span>. - They use - <strong>org.springframework.jdbc.core.JdbcTemplate</strong>, and - <strong>org.springframework.jdbc.core.simple.SimpleJdbcInsert</strong>. - It also takes advantage of classes like - <strong>org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource</strong> and - <strong>org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper</strong> - which provide automatic mapping between JavaBean properties and JDBC - parameters or query results. - </p> - - <p> - The transaction manager used in the JDBC Clinic Implementation is an - instance of <span style="font-weight: bold;">org.springframework.jdbc.datasource.DataSourceTransactionManager</span> - that can be used for local transactions. - </p> - - <h3>Java Persistence API (JPA) Repository Implementations</h3> - <p> - The JPA Repository implementations are located inside - <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.repository.jpa</span>. - They are based on native JPA usage combined with Spring's - <span style="font-weight: bold;">@Repository</span> and - <span style="font-weight: bold;">@Transactional</span> annotations but - otherwise have no dependencies on any Spring API's. - To simplify JPA usage, Spring provides (among other classes) the - <span style="font-weight: bold;">org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean</span>. - The JPA configuration is provided by - <span style="font-style: italic;">src/main/resources/META-INF/orm.xml</span> and - <span style="font-style: italic;"> src/main/resources/META-INF/persistence.xml.</span> - The JPA implementation used by Petclinic is Hibernate. - </p> - - <h3>ApplicationContext</h3> - <p> - A Spring <span style="font-weight: bold;">org.springframework.context.ApplicationContext</span> object - provides a map of user-defined JavaBeans that specify either a singleton - object or the initial construction of prototype instances. These beans - constitute the <span style="font-weight: bold;">Business/Persistence - Layer</span> of PetClinic. The following beans are defined in all 3 - versions (1 per access strategy) of the PetClinic - <span style="font-style: italic;">src/main/resources/spring/applicationContext-*.xml</span> - file: - </p> - - <ol> - <li>A <span style="font-weight: bold; font-style: italic;">PropertyPlaceholderConfigurer</span>, - which is configured via - <strong><context:property-placeholder ... /></strong> and - is a singleton bean that replaces ${...} placeholders with values from a - properties file, in this case, JDBC-related settings for the - <span style="font-weight: bold; font-style: italic;">dataSource</span> bean - described below - (see <span style="font-weight: bold; font-style: italic;">src/main/resources/spring/jdbc.properties</span>). - </li> - <li><span style="font-weight: bold; font-style: italic;">dataSource</span>, - which is a singleton bean that defines the implementation of the source - of database connections used by the application. - </li> - <li><span style="font-weight: bold; font-style: italic;">transactionManager</span>, - which is a singleton bean that defines the implementation of the transaction - management strategy for the application. - </li> - <li><span style="font-weight: bold; font-style: italic;">clinic</span>, - which is a singleton bean that defines the implementation of the - <span style="font-weight: bold;">Clinic</span> interface that provides the - primary Business Layer API of the application. - </li> - </ol> - - <h3>Presentation Layer</h3> - <p> - The Presentation Layer is implemented as a Java EE Web Application and - provides a very thin and concise Model-View-Controller type user - interface to the Business and Persistence Layers. - </p> - - <p> - The PetClinic web application is configured via the following files: - </p> - - <ul> - <li><span style="font-weight: bold; font-style: italic;">src/main/webapp/WEB-INF/web.xml</span>: - the web application configuration file.</li> - <li><span style="font-weight: bold; font-style: italic;">src/main/webapp/WEB-INF/petclinic-servlet.xml</span>: - configures the petclinic dispatcher servlet and the other controllers - and forms that it uses. The beans defined in this file reference the - Business/Persistence Layer beans defined in - <span style="font-style: italic;">applicationContext-*.xml.</span></li> - <li><span style="font-weight: bold; font-style: italic;">src/main/resources/messages*.properties</span>: - configures the definition of internationalizable message resources.</li> - </ul> - - <p> - Examine the comments provided in each of these files for a more - in-depth understanding of the details of how the application is - configured. - </p> - - <h3>General</h3> - - <ul> - <li>In <span style="font-weight: bold; font-style: italic;">web.xml</span>, - a context-param, "<span style="font-weight: bold;">webAppRootkey</span>", - provides the key for a system property that specifies the root directory - for the web application. This parameter, - <span style="font-weight: bold;">"petclinic.root"</span>, can be used to aid - in configuring the application.</li> - <li>In <span style="font-weight: bold; font-style: italic;">web.xml</span>, - a <span style="font-weight: bold;">org.springframework.web.context.ContextLoaderListener</span> - is defined that loads the root <span style="font-weight: bold;">ApplicationContext</span> - object of this webapp at startup, by default from the designated - <span style="font-weight: bold; font-style: italic;">/WEB-INF/applicationContext-*.xml</span>. - The root <span style="font-weight: bold;">org.springframework.web.context.WebApplicationContext</span> - of PetClinic is an instance of - <span style="font-weight: bold;">org.springframework.web.context.support.XmlWebApplicationContext</span> - and is the parent of all servlet-specific <span style="font-weight: bold;">ApplicationContexts</span>. - The Spring root <span style="font-weight: bold;">ApplicationContext</span> object - provides a map of user-defined JavaBeans that can be used in any and - all layers of the application. Beans defined in the root - <span style="font-weight: bold;">ApplicationContext</span> are automatically - available in all child <span style="font-weight: bold;">ApplicationContext</span> - objects as (external) bean references. Beans defined in an - <span style="font-weight: bold;">ApplicationContext</span> can also be - accessed directly by Java code through - <span style="font-style: italic;">getBean(name)</span> method calls. - </li> - - <li>In <span style="font-weight: bold; font-style: italic;">web.xml</span>, - a <span style="font-weight: bold;">Servlet</span> named - <span style="font-weight: bold;">"petclinic"</span> is specified to act as - a dispatcher for the entire application. This - <span style="font-weight: bold;">org.springframework.web.servlet.DispatcherServlet</span> - is used to handle all URL's matching the pattern <span style="font-weight: bold;">"*.do"</span>. - As with any <span style="font-weight: bold;">Servlet</span>, multiple URL mappings may - be defined. It is also possible to define multiple instances of - <span style="font-weight: bold;">DispatcherServlet</span>. Each - <span style="font-weight: bold;">DispatcherServlet</span> dispatches - requests to registered handlers (<span style="font-weight: bold;">Controller</span> - interface implementations or POJOs annotated with <strong>@Controller</strong>) - indirectly through a - <span style="font-weight: bold;">org.springframework.web.servlet.handler.HandlerMapping</span> - implementation. Each <span style="font-weight: bold;">DispatcherServlet</span> - has its own <span style="font-weight: bold;">ApplicationContext</span>, - by default defined in <span style="font-weight: bold;">"{servlet-name}-servlet.xml"</span>. - In this case, it is in the file <span style="font-weight: bold;">"petclinic-servlet.xml"</span>. - This <span style="font-weight: bold;">ApplicationContext</span> is - used to specify the various web application user interface beans and - the URL mappings that are used by the <span style="font-weight: bold;">DispatcherServlet</span> - to control the handling of requests. - </li> - </ul> - - <p> - The files <span style="font-weight: bold; font-style: italic;">web.xml</span> and - <span style="font-weight: bold; font-style: italic;">log4j.properties</span> specify - the configuration of logging in the system: - </p> - - <ul> - <li>In <span style="font-weight: bold; font-style: italic;">web.xml</span>, - a <span style="font-weight: bold;">"log4jConfigLocation"</span> context-param - is specified that sets the location of the - <span style="font-weight: bold;">log4j</span> configuration file. The - default location for this file is - <span style="font-weight: bold; font-style: italic;">/WEB-INF/classes/log4j.properties</span>. - Specifying this parameter explicitly allows the location to be changed - from the default and is also used to cause periodic - <span style="font-weight: bold;">log4j</span> configuration refresh checks.</li> - <li>In <span style="font-weight: bold; font-style: italic;">web.xml</span>, - a <span style="font-weight: bold;">Log4jConfigListener</span> is - specified that will initialize <span style="font-weight: bold;">log4j</span> using - the specified configuration file when the web app starts. The - <span style="font-weight: bold;">Log4jConfigListener</span> is commented out - in the file because of a conflict when using JBoss. It should also be - noted that if the container initializes Servlets before Listeners as - some pre-Servlet 2.4 containers do, a <b>Log4jConfigServlet</b> should - be used instead.</li> - <li>In <span style="font-weight: bold; font-style: italic;">log4j.properties</span>, - the following loggers are specified: - <ul> - <li><span style="font-weight: bold; font-style: italic;">"stdout"</span> provides - logging messages to the container's log file.</li> - <li><span style="font-weight: bold; font-style: italic;">"logfile"</span> provides - logging messages to a rolling file that is specified using the - previously defined "petclinic.root".</li> - </ul> - </li> - </ul> - - <p> - Examination and study of these logging files will provide insight into - the operation of the Spring framework and the application as well as - valuable troubleshooting information should something not work - correctly. - </p> - - <h3>DispatcherServlet</h3> - <p> - The following beans are accessible to the - <span style="font-weight: bold;">DispatcherServlet</span> and are defined - in the PetClinic - <span style="font-weight: bold; font-style: italic;">petclinic-servlet.xml</span> - file. This dispatcher uses these definitions to delegate actual display - and form processing tasks to implementations of the Spring - <span style="font-weight: bold;">org.springframework.web.servlet.mvc.Controller</span> - interface. The <span style="font-weight: bold;">DispatcherServlet</span> - acts as the main application <span style="font-weight: bold;">Front Controller</span> - and is responsible for dispatching all requests to the appropriate - <span style="font-weight: bold;">Controller</span> indirectly through a URL - mapping handler. These <span style="font-weight: bold;">Controllers</span> are - responsible for the mechanics of interaction with the user and ultimately - delegate action to the Business/Persistence Layers. - </p> - - <ul> - <li> - <span style="font-weight: bold; font-style: italic;">messageSource</span> - is a singleton bean that defines a message source for this - <span style="font-weight: bold;">ApplicationContext</span>. Messages are - loaded from localized <span style="font-weight: bold;">"messages_xx"</span> - files in the classpath, such as - <span style="font-weight: bold; font-style: italic;">"/WEB-INF/classes/messages.properties"</span> - or <span style="font-weight: bold; font-style: italic;">"/WEB-INF/classes/messages_de.properties"</span>. - <span style="font-style: italic;">getMessage()</span> calls to this context - will use this source. Child contexts can have their own message sources, - which will inherit all messages from this source and are able to define new - messages and override ones defined in the primary message source. - </li> - <li> - <span style="font-weight: bold; font-style: italic;">InternalResourceViewResolver</span> - is a singleton bean that defines the view mappings used by the dispatcher. - Specifically, logical view names returned by Controllers will be mapped to - physical paths using the configured 'prefix' and 'suffix' properties. For - example, a logical view name of "vets" will be mapped to "/WEB-INF/jsp/vets.jsp". - </li> - <li> - <span style="font-weight: bold; font-style: italic;">SimpleMappingExceptionResolver</span> - is a singleton bean that defines how exceptions are propagated. Exceptions - encountered that are not specified are propagated to the servlet container. - </li> - <li> - <span style="font-weight: bold; font-style: italic;"><context:component-scan ... /></span> - is used to autodetect the controllers in the - <strong>org.springframework.samples.petclinic.web</strong> package, which - are POJOs labeled with the <strong>@Controller</strong> annotation. - <ul> - <li> - <strong>ClinicController</strong> is a singleton, annotation-driven - <em>MultiActionController</em> that is used by the dispatcher to handle - non-form based display tasks. A method is provided to handle each - type of request that is supported. - </li> - <li> - In addition, there are 6 singleton, annotation-driven <em>Form</em> controllers, - which are used to handle the various Search, Add and Edit form processing - tasks for the dispatcher. - </li> - </ul> - </li> - <li> - The form-based controllers within the PetClinic application provide - <strong>@RequestMapping</strong> annotations at the type level for path - mapping URLs and @RequestMapping at the method level for request type - mappings (e.g., GET and POST). In contrast, <strong>ClinicController</strong> - – which is not form-based – provides @RequestMapping only at - the method level for path mapping URLs. - <strong>DefaultAnnotationHandlerMapping</strong> is driven by these - annotations and is enabled by default with Java 5+. - </li> - </ul> - - <h3>Views</h3> - <p> - The <span style="font-weight: bold;">Controllers</span> used by the - dispatcher handle the work flow of the application. The actual display - tasks are delegated by the <span style="font-weight: bold;">Controllers</span> - to implementations of the Spring <span style="font-weight: bold;">View - </span>interface. These <span style="font-weight: bold;">View</span> objects are - themselves beans that can render a particular type of view. The - handling <span style="font-weight: bold;">Controller</span> supplies the - <span style="font-weight: bold;">View</span> with a data model to render. - The data model is provided to the <span style="font-weight: bold;">View</span> - as a <span style="font-weight: bold;">Map</span> of objects. - <span style="font-weight: bold;">Views</span> are only responsible for - rendering a display of the data model and performing any display logic - that is particular to the type of <span style="font-weight: bold;">View</span> - being rendered. Spring provides support for rendering many different types of - views: JSP, XSLT, PDF, Velocity templates, Excel files, and others. By - using a <span style="font-weight: bold;">View</span> mapping strategy, - Spring supplies the developer with a great deal of flexibility in supporting - easily configurable view substitution. - </p> - <p> - <strong>ClinicController</strong> relies on - <strong>RequestToViewNameTranslator</strong> to automatically infer the - logical view name from the incoming request URL; whereas, all <em>Form</em> - controllers in the PetClinic application return logical view names as Strings. - These logical view names are then mapped to physical paths via the - configured <strong>InternalResourceViewResolver</strong> (see the - DispatcherServlet section above for further details). Logical view names that - are prepended with <em>"redirect:"</em> will be resolved to instances - of <strong>RedirectView</strong>, which simply redirects to another URL. - The other resolved <strong>View</strong>s will be instances of - <strong>JstlView</strong>, which provides some handy support for - internationalization & localization in JSP pages that use JSTL. - </p> - - <h3>Messages</h3> - <p> - The <span style="font-weight: bold; font-style: italic;">messages*.properties</span> - files are loaded from the classpath to provide localized messages for - the supported languages. PetClinic supplies a localized - <strong>"welcome"</strong> message as well as localized form entry error - messages in the default (i.e., English) and German properties files. - See the "countries" sample application for a more detailed example of Spring's - support for internationalization. - </p> - - <h3>Presentation Layer classes</h3> - <ul> - <li> - <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.web.ClinicController</span> - is an annotation-driven, POJO <em>MultiActionController</em> - that is used to handle simple display-oriented URLs. - </li> - <li> - <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.web.FindOwnersController</span> - is an annotation-driven, POJO <em>Form</em> controller that is used to search for - <strong>Owner</strong>s by last name. - </li> - <li> - <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.web.OwnerController</span> - is an annotation-driven, POJO <em>Form</em> controller that is used to add a new <strong>Owner</strong> - to the system. - </li> - <li> - <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.web.EditOwnerController</span> - is an annotation-driven, POJO <em>Form</em> controller that is used to edit an existing <strong>Owner</strong>. - A copy of the existing <strong>Owner</strong> is used for editing. - </li> - <li> - <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.web.PetController</span> - is an annotation-driven, POJO <em>Form</em> controller that is used to add a new <strong>Pet</strong> - to an existing <strong>Owner</strong>. - </li> - <li> - <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.web.EditPetController</span> - is an annotation-driven, POJO <em>Form</em> controller that is used to edit an existing <strong>Pet</strong>. - A copy of the existing <strong>Pet</strong> is used for editing. - </li> - <li> - <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.web.AddVisitController</span> - is an annotation-driven, POJO <em>Form</em> controller that is used to add a new <strong>Visit</strong> - to an existing <strong>Pet</strong>. - </li> - </ul> - - <h3>Logical Views & Implemented Use Cases</h3> - - <ul> - <li><span style="font-weight: bold; font-style: italic;">welcome</span> is - the "home" screen. It provides links to display a list of all vets, - find an owner, or view documentation.</li> - <li><span style="font-weight: bold; font-style: italic;">vets</span> displays - all vets and their specialties.</li> - <li><span style="font-weight: bold; font-style: italic;">findOwners</span> - is used to find owners by last name.</li> - <li><span style="font-weight: bold; font-style: italic;">findOwnersRedirect</span> - redirects to findOwner.</li> - <li><span style="font-weight: bold; font-style: italic;">selectOwner</span> - allows user to select from a list of multiple owners with the same last - name.</li> - <li><span style="font-weight: bold; font-style: italic;">owner</span> displays - a owner's data and a list of the owner's pets and their data.</li> - <li><span style="font-weight: bold; font-style: italic;">ownerRedirect</span> - redirects to owner.</li> - <li><span style="font-weight: bold; font-style: italic;">owner</span> supports - <span style="font-weight: bold; font-style: italic;">AddOwnerForm</span> - and <span style="font-weight: bold; font-style: italic;">EditOwnerForm</span></li> - <li><span style="font-weight: bold; font-style: italic;">pet</span> supports - <span style="font-weight: bold; font-style: italic;">AddPetForm</span> - and <span style="font-weight: bold; font-style: italic;">web.EditPetForm</span></li> - <li><span style="font-weight: bold; font-style: italic;">visit</span> supports - <span style="font-weight: bold; font-style: italic;">AddVisitForm</span></li> - <li><span style="font-weight: bold; font-style: italic;">dataAccessFailure</span> - displays a stacktrace</li> - </ul> - - <h3>Java Server Pages</h3> - - <ul> - <li><span style="font-weight: bold; font-style: italic;">index.jsp</span> - redirects to the "welcome" page.</li> - <li><span style="font-weight: bold; font-style: italic;">includes.jsp</span> is - statically included in <span style="text-decoration: underline;">all</span> - JSP's used in the application. It specifies the taglibs that are in use.</li> - <li><span style="font-weight: bold; font-style: italic;">header.jsp</span> and - <span style="font-style: italic; font-weight: bold;">footer.jsp</span> - display info common to virtually all pages. Spring also supplies - support for the integration of <a href="http://www.lifl.fr/%7Edumoulin/tiles">Tiles</a> - (included in Struts) but this is not used in PetClinic.</li> - <li><span style="font-weight: bold; font-style: italic;">dataAccessFailure.jsp</span> - is the error page configured via - <span style="font-weight: bold; font-style: italic;">SimpleMappingExceptionResolver</span>, - which displays a stack trace and normally wouldn't be used in a production - version of an application. It can be seen in action by entering a URL of - "editOwner.do" or "editPet.do" with an invalid request parameter, for example: - <a href="http://localhost:8080/org.springframework.samples.petclinic/owner.do?ownerId=-1">/petclinic/owner.do?ownerId=-1</a>. - The handlers for these URLs normally expect to see a respective "ownerId" or "petId" - request parameter corresponding to an Owner or Pet in the database. Thus, - these handlers will throw a <strong>DataAccessException</strong> when such - a request parameter is provided which references a non-existing entity.</li> - <li><span style="font-weight: bold; font-style: italic;">uncaughtException.jsp</span> - is the <span style="font-weight: bold; font-style: italic;">web.xml</span> configured - "error-page". It displays a stack trace and normally wouldn't be used - in a production version of an application. It can be seen in action by - entering a URL of "editOwner.do" or "editPet.do" without a valid request - parameter, for example: - <a href="http://localhost:8080/org.springframework.samples.petclinic/owner.do">/petclinic/owner.do</a>. - The handlers for these URLs normally expect to see a respective "ownerId" or "petId" - request parameter and throw a <strong>ServletException</strong> when such - a request parameter is not found.</li> - <li><span style="font-weight: bold; font-style: italic;">welcome.jsp</span> implements - <span style="font-weight: bold; font-style: italic;">welcome</span>.</li> - <li><span style="font-weight: bold; font-style: italic;">vets.jsp</span> implements - <span style="font-weight: bold; font-style: italic;">vets</span>.</li> - <li><span style="font-weight: bold; font-style: italic;">findOwners.jsp</span> implements - <span style="font-weight: bold; font-style: italic;">findOwners</span>.</li> - <li><span style="font-weight: bold; font-style: italic;">owners.jsp</span> implements - <span style="font-weight: bold; font-style: italic;">selectOwner</span>.</li> - <li><span style="font-weight: bold; font-style: italic;">owner.jsp</span> implements - <span style="font-weight: bold; font-style: italic;">owner</span>.</li> - <li><span style="font-weight: bold; font-style: italic;">ownerForm.jsp</span> implements - <span style="font-weight: bold; font-style: italic;">ownerForm</span>.</li> - <li><span style="font-weight: bold; font-style: italic;">petForm.jsp</span> implements - <span style="font-weight: bold; font-style: italic;">petForm</span>.</li> - <li><span style="font-weight: bold; font-style: italic;">visitForm.jsp</span> implements - <span style="font-weight: bold; font-style: italic;">visitForm</span>.</li> - </ul> - - <p> - The following items should be noted regarding the web application - implementation design: - </p> - - <ol> - <li>all JSP's are stored under <span style="font-weight: bold; font-style: italic;">/WEB-INF/jsp</span> except - for <span style="font-weight: bold; font-style: italic;">index.jsp</span> which - is the configured "welcome-file"</li> - <li>The use of JSP technology in the application is not exposed to - the user, i.e., the end user never sees a URL ending in - <span style="font-weight: bold; font-style: italic;">".jsp".</span></li> - <li>By convention, all URL's in the application ending in - <span style="font-weight: bold; font-style: italic;">".do"</span> are - handled by web application controllers. Static html pages ending in - <span style="font-weight: bold; font-style: italic;">".html"</span>, such as - Javadoc, will be directly served to the end user.</li> - <li>The results of all form entries are handled using browser round - trip redirection to minimize possible end user confusion.</li> - <li>All pages are extremely simple JSP implementations that focus - only on providing the necessary functionality.</li> - <li>References to <span style="font-weight: bold;">Entity</span> objects - are passed around in the application by supplying the object's <code>ID</code> - as a request parameter.</li> - </ol> - - <h3>Testing</h3> - <ul> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.OwnerTests</span> - is a simple JUnit 4 based TestCase that supports Business Rule #1.</li> - <li><span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.AbstractClinicTests</span> - is a JUnit 4 based TestCase requiring a live database connection that is - used to confirm correct operation of the database access objects in the - various implementations of the <strong>Clinic</strong> interface. - "AbstractClinicTests-context.xml" declares a common - <strong>javax.sql.DataSource</strong>. Subclasses specify additional - context locations which declare a - <strong>org.springframework.transaction.PlatformTransactionManager</strong> - and a concrete implementation of <strong>Clinic</strong>. - <p> - AbstractClinicTests extends - <strong>AbstractTransactionalJUnit4SpringContextTests</strong>, - one of the valuable testing support classes provided by the - <em>Spring TestContext Framework</em> found in the - <code>org.springframework.test.context</code> package. The - annotation-driven configuration used here represents best practice for - integration tests with Spring. Note, however, that - AbstractTransactionalJUnit4SpringContextTests serves only as a convenience - for extension. For example, if you do not wish for your test classes to be - tied to a Spring-specific class hierarchy, you may configure your tests with - annotations such as <strong>@ContextConfiguration</strong>, - <strong>@TestExecutionListeners</strong>, <strong>@Transactional</strong>, etc. - </p> - <p> - AbstractClinicTests and its subclasses benefit from the following services - provided by the Spring TestContext Framework: - </p> - <ul> - <li><strong>Spring IoC container caching</strong> which spares us - unnecessary set up time between test execution.</li> - <li><strong>Dependency Injection</strong> of test fixture instances, - meaning that we don't need to perform application context lookups. See the - use of <strong>@Autowired</strong> on the <code>clinic</code> instance - variable, which uses autowiring <em>by type</em>. As an alternative, we - could annotate <code>clinic</code> with JSR 250's - <strong>@Resource</strong> to achieve dependency injection <em>by name</em>. - <em>(see: <strong>@ContextConfiguration</strong>, - <strong>DependencyInjectionTestExecutionListener</strong>)</em></li> - <li><strong>Transaction management</strong>, meaning each test method is - executed in its own transaction, which is automatically rolled back by - default. Thus, even if tests insert or otherwise change database state, there - is no need for a teardown or cleanup script. - <em>(see: <strong>@TransactionConfiguration</strong>, - <strong>@Transactional</strong>, <strong>TransactionalTestExecutionListener</strong>)</em></li> - <li><strong>Useful inherited protected fields</strong>, such as a - <strong>SimpleJdbcTemplate</strong> that can be used to verify - database state after test operations or to verify the results of - queries performed by application code. An - <strong>ApplicationContext</strong> is also inherited and can be - used for explicit bean lookup if necessary. - <em>(see: <strong>AbstractJUnit4SpringContextTests</strong>, - <strong>AbstractTransactionalJUnit4SpringContextTests</strong>)</em></li> - </ul> - <p> - The <em>Spring TestContext Framework</em> and related unit and - integration testing support classes are shipped in - <code>spring-test.jar</code>. - </p> - - </li> - </ul> - - <h3>Downloads</h3> - <ul> - <li>Download and install the - <a href="http://www.springsource.com/download/community?project=Spring%20Framework" target="_blank">Spring Framework</a> - (the PetClinic sample application is included)</li> - <li>Download and install a <a href="http://java.sun.com/" target="_blank">Java</a> - Software Developer Kit, version 1.5 or later</li> - <li>Download and install <a href="http://maven.apache.org" target="_blank">Apache Maven</a>, - preferably version 2.0.10 or later</li> - <li>Download and install <a href="http://ant.apache.org" target="_blank">Apache Ant</a>, - preferably version 1.7.1 or later</li> - <li>Download and install <a href="http://jakarta.apache.org/tomcat/index.html" target="_blank">Apache Tomcat</a>, - preferably version 6.0.20 or later</li> - <li>Download and install <a href="http://dev.mysql.com/downloads/" target="_blank">MySQL</a>, - preferably version 5.1.x or later (optional)</li> - <li><a href="http://hsqldb.sourceforge.net/" target="_blank">Hypersonic SQL</a>, and - <a href="http://hibernate.org/" target="_blank">Hibernate</a> are provided with the - application.</li> - <li>PetClinic and Spring use the <a href="http://www.apache.org/" target="_blank">Apache</a> - <a href="http://commons.apache.org/logging/" target="_blank">Commons Logging</a> - and <a href="http://logging.apache.org/log4j/" target="_blank">log4j</a> - packages.</li> - </ul> - - <h3>Maven Setup</h3> - <p> - Make sure that the Maven executable is in your command shell path. - </p> - - <h3>MYSQL Setup (optional)</h3> - <p> - Add the PetClinic database to a running MySQL server by following the - explicit instructions found in - <span style="font-weight: bold; font-style: italic;">db/mysql/petclinic_db_setup_mysql.txt</span>. - PetClinic expects by default to be able to access the server via the - standard port <code>3306</code>. To use a different port, it will be - necessary to change the PetClinic Database Setup. - </p> - - <h3>PetClinic Database Setup</h3> - <p> - To use a Java EE server supplied connection-pooled data source with - Tomcat, it will be necessary to use and possibly edit the appropriate - context definition file for the petclinic webapp. To use it, deploy a - copy of the appropriate context definition file in Tomcat's webapps - directory and restart the server. Consult the Tomcat log files if - something goes wrong when starting either Tomcat or the PetClinic - application. The context files are named - <span style="font-weight: bold; font-style: italic;">petclinic_tomcat_*.xml</span>, - where <strong>*</strong> is either "hsqldb" or "mysql". - There is a context file supplied for each - database in its respective directory. There is also a context file - <span style="font-weight: bold; font-style: italic;">db/petclinic_tomcat_all.xml</span> - that will provide a JNDI connection-pooled DataSource for all supported - databases. Should you use this file, you must of course make sure that all the - database servers are running when you restart Tomcat. - </p> - - <p> - <a name="dbNotes"></a> - <span style="font-weight: bold;">NOTES:</span> - </p> - - <ol> - <li>Should you deploy one of the context files or define a context in - Tomcat's <span style="font-weight: bold; font-style: italic;">server.xml</span>, - Tomcat will not automatically deploy the webapp from the - <span style="font-weight: bold; font-style: italic;">petclinic.war</span> file. - The webapp will then need to be manually extracted to the target - directory.</li> - <li>The context files will also configure logging to supply a - separate log file for the petclinic context. This will separate the - container logging for petclinic from that of the other webapps. This - should not be confused with the application log file provided through - <span style="font-weight: bold;">log4j.</span></li> - <li>An Ant script (<span style="font-weight: bold; font-style: italic;">db/build.xml</span>) - has been provided that can be used to re-initialize either database. To - select or configure the data source and database used for the webapp and - for testing, you will need to edit the following files: - <ul> - <li><span style="font-weight: bold; font-style: italic;">src/main/webapp/WEB-INF/applicationContext-*.xml</span>: - for configuring the DataSource in the webapp</li> - <li><span style="font-weight: bold; font-style: italic;">src/main/resources/jdbc.properties</span>: - for configuring JDBC connection settings for both the webapp and testing</li> - <li><span style="font-weight: bold; font-style: italic;">build.properties</span>: - for running the "tests" target in Ant</li> - </ul> - </li> - </ol> - - <h3>Building the PetClinic Application</h3> - <p> - Open a command line shell and navigate to the directory containing - PetClinic. Make sure the database is running and execute - "mvn clean package". This will run clean and compile everything - and execute the tests, including integration tests against an in-memory - database. - </p> - - <h3>Deploying the PetClinic Application</h3> - <p> - Deploy the web application to the server in the usual way (see - <a href="#dbNotes">notes</a> regarding database setup). If you need - instructions for web application deployment, see the Tomcat - documentation for details. The Web Application aRchive file is - <span style="font-weight: bold; font-style: italic;">org.springframework.samples.petclinic.war</span> - and can be found in the - <span style="font-weight: bold; font-style: italic;">target/artifacts</span> directory. - </p> - - <h3>Using the PetClinic Application</h3> - <p> - Make sure the PetClinic web application is running and browse to - <a href="http://localhost:8080/org.springframework.samples.petclinic/">http://localhost:8080/org.springframework.samples.petclinic/</a>. - </p> - - <table class="footer"> - <tr> - <td><a href="../welcome.do">Home</a></td> - <td align="right"><img src="../images/springsource-logo.png"/></td> - </tr> - </table> - </div> -</body> - -</html> \ No newline at end of file diff --git a/src/test/java/org/springframework/samples/petclinic/aspects/UsageLogAspectTests.java b/src/test/java/org/springframework/samples/petclinic/aspects/UsageLogAspectTests.java deleted file mode 100644 index 929e1b95165b0fa8080f2c013e9fd6ec5d040d60..0000000000000000000000000000000000000000 --- a/src/test/java/org/springframework/samples/petclinic/aspects/UsageLogAspectTests.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.springframework.samples.petclinic.aspects; - -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; - -import java.util.List; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.samples.petclinic.repository.OwnerRepository; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * <p> - * Tests for the DAO variant based on the shared EntityManager approach. Uses - * TopLink Essentials (the reference implementation) for testing. - * </p> - * <p> - * Specifically tests usage of an <code>orm.xml</code> file, loaded by the - * persistence provider through the Spring-provided persistence unit root URL. - * </p> - * - * @author Rod Johnson - * @author Juergen Hoeller - */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) -@RunWith(SpringJUnit4ClassRunner.class) -@ActiveProfiles({"jpa","plain-jpa"}) -public class UsageLogAspectTests { - - @Autowired - private UsageLogAspect usageLogAspect; - - @Autowired - private OwnerRepository ownerRepository; - - - @Test - public void testUsageLogAspectIsInvoked() { - String lastName1 = "Franklin"; - String lastName2 = "Davis"; - String lastName3 = "foo"; - - assertFalse(this.ownerRepository.findByLastName(lastName1).isEmpty()); - assertFalse(this.ownerRepository.findByLastName(lastName2).isEmpty()); - - List<String> namesRequested = this.usageLogAspect.getNamesRequested(); - assertTrue(namesRequested.contains(lastName1)); - assertTrue(namesRequested.contains(lastName2)); - assertFalse(namesRequested.contains(lastName3)); - } - -} diff --git a/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcOwnerRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcOwnerRepositoryImplTests.java index d470beb2ba16d979fff0d3d2aa0540a9bbc529c3..453bf10f1ee324bccf65c8e22e484a2bcded863d 100644 --- a/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcOwnerRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcOwnerRepositoryImplTests.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Risberg * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("jdbc") public class JdbcOwnerRepositoryImplTests extends AbstractOwnerRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcPetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcPetRepositoryImplTests.java index 5c77bfbeceb68a967f31200b68c751ed947016c8..3e3205d4f30a68d9105fe7ef17780a4c02c81404 100644 --- a/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcPetRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcPetRepositoryImplTests.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Risberg * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("jdbc") public class JdbcPetRepositoryImplTests extends AbstractPetRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcVetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcVetRepositoryImplTests.java index c378ec29c16751135f5a9758dbf34dbeaa8b6bba..b3fc135d170f3337272d825c70f2dacb936d217b 100644 --- a/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcVetRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcVetRepositoryImplTests.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Risberg * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("jdbc") public class JdbcVetRepositoryImplTests extends AbstractVetRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcVisitRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcVisitRepositoryImplTests.java index 174ed4acc9ce6e61d9df0380d1efc396a2f3f0e8..0558d68d5b9c2aa367ca456e429fb13a9806ddcc 100644 --- a/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcVisitRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/jdbc/JdbcVisitRepositoryImplTests.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Risberg * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("jdbc") public class JdbcVisitRepositoryImplTests extends AbstractVisitRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/jpa/JpaOwnerRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/jpa/JpaOwnerRepositoryImplTests.java index e28bd352a3faed0164d6cece7e4269a25619e394..9676c97bd14b7d6e46a757bd0b25f79c915488b5 100644 --- a/src/test/java/org/springframework/samples/petclinic/jpa/JpaOwnerRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/jpa/JpaOwnerRepositoryImplTests.java @@ -26,7 +26,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("jpa") public class JpaOwnerRepositoryImplTests extends AbstractOwnerRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/jpa/JpaPetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/jpa/JpaPetRepositoryImplTests.java index 3d5b026c9ece283a8bf278e8cd8bb321c088ee46..2db73d7da3ffa5b9ffbdd6886e614362af03842e 100644 --- a/src/test/java/org/springframework/samples/petclinic/jpa/JpaPetRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/jpa/JpaPetRepositoryImplTests.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Risberg * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("jpa") public class JpaPetRepositoryImplTests extends AbstractPetRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/jpa/JpaVetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/jpa/JpaVetRepositoryImplTests.java index f4c010102b281941edb9dff6b665e6d3fe50cb48..e5fbac390019a7986ebbf9730da648a5215b8638 100644 --- a/src/test/java/org/springframework/samples/petclinic/jpa/JpaVetRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/jpa/JpaVetRepositoryImplTests.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Risberg * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("jpa") public class JpaVetRepositoryImplTests extends AbstractVetRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/jpa/JpaVisitRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/jpa/JpaVisitRepositoryImplTests.java index 478a4f8121575b6d725467f998d266d469e64257..26a246b0a9e96127ca788ef518e7b1e6125af5c4 100644 --- a/src/test/java/org/springframework/samples/petclinic/jpa/JpaVisitRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/jpa/JpaVisitRepositoryImplTests.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Risberg * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("jpa") public class JpaVisitRepositoryImplTests extends AbstractVisitRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaOwnerRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaOwnerRepositoryImplTests.java index 5315e3d3f1021b3365703bcedb5079a0e72d851a..e8d69faa4c0c198baff28dcff2d4afc409e27a05 100644 --- a/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaOwnerRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaOwnerRepositoryImplTests.java @@ -26,7 +26,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("spring-data-jpa") public class JpaOwnerRepositoryImplTests extends AbstractOwnerRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaPetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaPetRepositoryImplTests.java index 77634a16fbf4765237a23558113e82f5bee905a7..d08ff3a55c27943a5f07da68a28fda1cc52d58fc 100644 --- a/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaPetRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaPetRepositoryImplTests.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Risberg * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("spring-data-jpa") public class JpaPetRepositoryImplTests extends AbstractPetRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaVetRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaVetRepositoryImplTests.java index 3aabfac7a75e043b01e98f6de23fbf07d85344f5..a21cbcd6e5ec7158f21d73e03e35f55982b671c9 100644 --- a/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaVetRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaVetRepositoryImplTests.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Risberg * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("spring-data-jpa") public class JpaVetRepositoryImplTests extends AbstractVetRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaVisitRepositoryImplTests.java b/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaVisitRepositoryImplTests.java index 1f3609279241f5e471be7243d1d7343827ca87e5..5549483bdd6238c055d9a8e112d73e78e95a17b0 100644 --- a/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaVisitRepositoryImplTests.java +++ b/src/test/java/org/springframework/samples/petclinic/springdatajpa/JpaVisitRepositoryImplTests.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Thomas Risberg * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("spring-data-jpa") public class JpaVisitRepositoryImplTests extends AbstractVisitRepositoryTests { diff --git a/src/test/java/org/springframework/samples/petclinic/springdatajpa/SpringDataOwnerRepositoryTests.java b/src/test/java/org/springframework/samples/petclinic/springdatajpa/SpringDataOwnerRepositoryTests.java index 33d80907251945a36ea1accfad351f9f50b5e5ba..23d4ee90201a31416951c88e58cb51badccd39f5 100644 --- a/src/test/java/org/springframework/samples/petclinic/springdatajpa/SpringDataOwnerRepositoryTests.java +++ b/src/test/java/org/springframework/samples/petclinic/springdatajpa/SpringDataOwnerRepositoryTests.java @@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Michael Isvy */ -@ContextConfiguration(locations={"classpath:spring/applicationContext-dao.xml"}) +@ContextConfiguration(locations={"classpath:spring/dao-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("spring-data-jpa") public class SpringDataOwnerRepositoryTests extends AbstractOwnerRepositoryTests {