From 46260018d18292a1523a94943ca58fb332b33b58 Mon Sep 17 00:00:00 2001
From: Gordon Dickens <gordon@gordondickens.com>
Date: Tue, 19 Feb 2013 10:44:33 -0500
Subject: [PATCH] switched to modern logback for logging, see logback.xml and
 logback-test.xml for configuration

---
 pom.xml                                  |  59 +++++++-
 src/main/resources/logback.xml           |   2 +-
 src/main/resources/spring/dao-config.xml | 183 ++++++++++++-----------
 src/test/resources/logback-test.xml      |   2 +-
 4 files changed, 152 insertions(+), 94 deletions(-)

diff --git a/pom.xml b/pom.xml
index d58492d..5d05fd8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,6 +49,7 @@
         <maven-help-plugin.version>2.1.1</maven-help-plugin.version>
         <maven-install-plugin.version>2.4</maven-install-plugin.version>
         <maven-jar-plugin.version>2.4</maven-jar-plugin.version>
+        <maven-javadoc-plugin.version>2.9</maven-javadoc-plugin.version>
         <maven-jetty-plugin.version>8.1.9.v20130131</maven-jetty-plugin.version>
         <maven-m2e-lifecycle-plugin.version>1.0.0</maven-m2e-lifecycle-plugin.version>
         <maven-plugin-plugin.version>3.2</maven-plugin-plugin.version>
@@ -62,6 +63,9 @@
         <maven.version.range>[2.2.1,3.1.0)</maven.version.range>
         <maven-war-plugin.version>2.3</maven-war-plugin.version>
         <mysql.version>5.1.22</mysql.version>
+        <!-- gDickens: Best Practice: ALWAYS define source encoding for platform independence -->
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <rome.version>1.0</rome.version>
         <servlet.version>2.5</servlet.version>
         <slf4j.version>1.7.2</slf4j.version>
@@ -462,6 +466,59 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>${maven-resources-plugin.version}</version>
+                <configuration>
+                    <encoding>${project.build.sourceEncoding}</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-site-plugin</artifactId>
+                <version>${maven-site-plugin.version}</version>
+                <executions>
+                    <execution>
+                        <id>attach-descriptor</id>
+                        <goals>
+                            <goal>attach-descriptor</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <reportPlugins>
+                        <plugin>
+                            <groupId>org.apache.maven.plugins</groupId>
+                            <artifactId>maven-surefire-report-plugin</artifactId>
+                            <version>${maven-surefire-plugin.version}</version>
+                            <configuration>
+                                <outputDirectory>${project.reporting.outputDirectory}/testresults</outputDirectory>
+                            </configuration>
+                        </plugin>
+                        <plugin>
+                            <groupId>org.apache.maven.plugins</groupId>
+                            <artifactId>maven-javadoc-plugin</artifactId>
+                            <version>${maven-javadoc-plugin.version}</version>
+                            <configuration>
+                                <aggregate>true</aggregate>
+                            </configuration>
+                        </plugin>
+                        <plugin>
+                            <groupId>org.apache.maven.plugins</groupId>
+                            <artifactId>maven-project-info-reports-plugin</artifactId>
+                            <version>${maven-project-info-reports-plugin.version}</version>
+                            <configuration>
+                                <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
+                                <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
+                            </configuration>
+                        </plugin>
+                    </reportPlugins>
+                    <locales>en</locales>
+                </configuration>
+            </plugin>
+
+
         </plugins>
 
         <!-- gDickens: For Eclipse's M2E plugin support -->
@@ -885,5 +942,5 @@
         </dependencies>
     </dependencyManagement>
 
-    
+
 </project>
\ No newline at end of file
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index 9ccd2fc..3213b02 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<configuration debug="true" scan="true" scanPeriod="30 seconds">
+<configuration scan="true" scanPeriod="30 seconds">
 
     <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
         <resetJUL>true</resetJUL>
diff --git a/src/main/resources/spring/dao-config.xml b/src/main/resources/spring/dao-config.xml
index d4a4110..e5b8346 100644
--- a/src/main/resources/spring/dao-config.xml
+++ b/src/main/resources/spring/dao-config.xml
@@ -3,99 +3,100 @@
 	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: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
+       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="datasource-config.xml"/> 
-
-
-	<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
-	<!-- (in this case, JDBC-related settings for the JPA EntityManager definition below) -->
-	<context:property-placeholder location="classpath:spring/jdbc.properties"/>
-
-	<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
-
-	<!--
-		Activates various annotations to be detected in bean classes: Spring's
-		@Required and @Autowired, as well as JSR 250's @PostConstruct,
-		@PreDestroy and @Resource (if available) and JPA's @PersistenceContext
-		and @PersistenceUnit (if available).
-	-->
-	<context:annotation-config/>
-
-	<!--
-		Instruct Spring to perform declarative transaction management
-		automatically on annotated classes.
-		
-		for mode="aspectj"/ see SPR-6392
-	-->
-	<tx:annotation-driven/>
-
-	<beans profile="jpa,spring-data-jpa">
-		<!-- JPA EntityManagerFactory -->
-		<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
-				p:dataSource-ref="dataSource">
-			<property name="jpaVendorAdapter">			
-				<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
-						p:database="${jpa.database}" p:showSql="${jpa.showSql}" />			
-			</property>
-			<property name="persistenceUnitName" value="petclinic" />
-			<property name="packagesToScan" value="org/springframework/samples/petclinic" />
-		</bean>
-			
-		<!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
-		<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
-				p:entityManagerFactory-ref="entityManagerFactory"/>
-	
-	
-	
-		<!--
-			Post-processor to perform exception translation on @Repository classes (from native
-			exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy).
-		-->
-		<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
-	
-	</beans>
-	
-	<beans profile="jdbc">
-			<!-- Transaction manager for a single JDBC DataSource (alternative to JTA) -->
-			<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
-				p:dataSource-ref="dataSource"/>
-
-			<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
-				<constructor-arg ref="dataSource" />			
-			</bean>
-			
-			<bean id="namedParameterJdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
-				<constructor-arg ref="dataSource" />			
-			</bean>
-			 
-			<context:component-scan base-package="org.springframework.samples.petclinic.repository.jdbc"/>
-	
-	</beans>
-	
-	<beans profile="jpa">
-		<!--
-			Will automatically be transactional due to @Transactional.
-			EntityManager will be auto-injected due to @PersistenceContext.
-			PersistenceExceptions will be auto-translated due to @Repository.
-		-->
-		<context:component-scan base-package="org.springframework.samples.petclinic.repository.jpa"/>
-
-	</beans>
-	
-	<beans profile="spring-data-jpa">
-		<jpa:repositories base-package="org.springframework.samples.petclinic.repository.springdatajpa"/>
-		
-		<!-- Custom configuration for the custom implementation based on JPA -->
-		<bean id="owerRepository" class="org.springframework.samples.petclinic.repository.springdatajpa.JpaOwnerRepositoryImpl"/>
-	
-	</beans>
+    <!-- ========================= RESOURCE DEFINITIONS ========================= -->
+
+    <!-- import the dataSource definition -->
+    <import resource="datasource-config.xml"/>
+
+
+    <!-- Configurer that replaces ${...} placeholders with values from a properties file -->
+    <!-- (in this case, JDBC-related settings for the JPA EntityManager definition below) -->
+    <context:property-placeholder location="classpath:spring/jdbc.properties"/>
+
+    <!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
+
+    <!--
+        Activates various annotations to be detected in bean classes: Spring's
+        @Required and @Autowired, as well as JSR 250's @PostConstruct,
+        @PreDestroy and @Resource (if available) and JPA's @PersistenceContext
+        and @PersistenceUnit (if available).
+    -->
+    <context:annotation-config/>
+
+    <!--
+        Instruct Spring to perform declarative transaction management
+        automatically on annotated classes.
+        
+        for mode="aspectj"/ see SPR-6392
+    -->
+    <tx:annotation-driven/>
+
+    <beans profile="jpa,spring-data-jpa">
+        <!-- JPA EntityManagerFactory -->
+        <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
+              p:dataSource-ref="dataSource">
+            <property name="jpaVendorAdapter">
+                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
+                      p:database="${jpa.database}" p:showSql="${jpa.showSql}"/>
+            </property>
+            <property name="persistenceUnitName" value="petclinic"/>
+            <property name="packagesToScan" value="org/springframework/samples/petclinic"/>
+        </bean>
+
+        <!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
+        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
+              p:entityManagerFactory-ref="entityManagerFactory"/>
+
+
+        <!--
+            Post-processor to perform exception translation on @Repository classes (from native
+            exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy).
+        -->
+        <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
+
+    </beans>
+
+    <beans profile="jdbc">
+        <!-- Transaction manager for a single JDBC DataSource (alternative to JTA) -->
+        <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
+              p:dataSource-ref="dataSource"/>
+
+        <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
+            <constructor-arg ref="dataSource"/>
+        </bean>
+
+        <bean id="namedParameterJdbcTemplate"
+              class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
+            <constructor-arg ref="dataSource"/>
+        </bean>
+
+        <context:component-scan base-package="org.springframework.samples.petclinic.repository.jdbc"/>
+
+    </beans>
+
+    <beans profile="jpa">
+        <!--
+            Will automatically be transactional due to @Transactional.
+            EntityManager will be auto-injected due to @PersistenceContext.
+            PersistenceExceptions will be auto-translated due to @Repository.
+        -->
+        <context:component-scan base-package="org.springframework.samples.petclinic.repository.jpa"/>
+
+    </beans>
+
+    <beans profile="spring-data-jpa">
+        <jpa:repositories base-package="org.springframework.samples.petclinic.repository.springdatajpa"/>
+
+        <!-- Custom configuration for the custom implementation based on JPA -->
+        <bean id="owerRepository"
+              class="org.springframework.samples.petclinic.repository.springdatajpa.JpaOwnerRepositoryImpl"/>
+
+    </beans>
 </beans>
\ No newline at end of file
diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml
index 682928c..5a3eb20 100644
--- a/src/test/resources/logback-test.xml
+++ b/src/test/resources/logback-test.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<configuration debug="true" scan="true" scanPeriod="30 seconds">
+<configuration debug="true">
 
     <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
         <resetJUL>true</resetJUL>
-- 
GitLab