Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 110 lines (89 sloc) 5.298 kB
6ada2bf Import the project
jeremy-aubert authored
1 ==========================================================================
2 === Spring PetClinic Sample Application
3 ==========================================================================
4
5 @author Ken Krebs
6 @author Juergen Hoeller
7 @author Rob Harrop
8 @author Costin Leau
9 @author Sam Brannen
10 @author Scott Andrews
11
12 ==========================================================================
13 === Data Access Strategies
14 ==========================================================================
15
16 PetClinic features alternative DAO implementations and application
17 configurations for JDBC, Hibernate, and JPA, with HSQLDB and MySQL as
18 target databases. The default PetClinic configuration is JDBC on HSQLDB.
19 See "src/main/resources/jdbc.properties" as well as web.xml and
20 applicationContext-*.xml in the "src/main/webapp/WEB-INF" folder for
21 details. A simple comment change in web.xml switches between the data
22 access strategies.
23
24 The JDBC and Hibernate versions of PetClinic also demonstrate JMX support
25 via the use of <context:mbean-export/> for exporting MBeans.
26 SimpleJdbcClinic exposes the SimpleJdbcClinicMBean management interface
27 via JMX through the use of the @ManagedResource and @ManagedOperation
28 annotations; whereas, the HibernateStatistics service is exposed via JMX
29 through auto-detection of the service MBean. You can start up the JDK's
30 JConsole to manage the exported bean.
31
32 All data access strategies can work with JTA for transaction management by
33 activating the JtaTransactionManager and a JndiObjectFactoryBean that
34 refers to a transactional container DataSource. The default for JDBC is
35 DataSourceTransactionManager; for Hibernate, HibernateTransactionManager;
36 for JPA, JpaTransactionManager. Those local strategies allow for working
37 with any locally defined DataSource.
38
39 Note that the sample configurations for JDBC, Hibernate, and JPA configure
40 a BasicDataSource from the Apache Commons DBCP project for connection
41 pooling.
42
43 ==========================================================================
44 === Build and Deployment
45 ==========================================================================
46
47 The Spring PetClinic sample application is built using Maven.
48 When the project is first built, Maven will automatically download all required
49 dependencies (if these haven't been downloaded before). Thus the initial build
50 may take a few minutes depending on the speed of your Internet connection,
51 but subsequent builds will be much faster.
52
53 Available build commands:
54
55 - mvn clean --> cleans the project
56 - mvn clean test --> cleans the project and runs all tests
57 - mvn clean package --> cleans the project and builds the WAR
58
59 After building the project with "mvn clean package", you will find the
60 resulting WAR file in the "target/" directory. By default, an
61 embedded HSQLDB instance in configured. No other steps are necessary to
62 get the data source up and running: you can simply deploy the built WAR
63 file directly to your Servlet container.
64
65 For MySQL, you'll need to use the corresponding schema and SQL scripts in
66 the "db/mysql" subdirectory. Follow the steps outlined in
67 "db/mysql/petclinic_db_setup_mysql.txt" for explicit details.
68
69 In you intend to use a local DataSource, the JDBC settings can be adapted
70 in "src/main/resources/jdbc.properties". To use a JTA DataSource, you need
71 to set up corresponding DataSources in your Java EE container.
72
73 Notes on enabling Log4J:
74 - Log4J is disabled by default due to issues with JBoss.
75 - Uncomment the Log4J listener in "WEB-INF/web.xml" to enable logging.
76
77 Notes on service static resources:
78 - Most web containers provide a 'default' servlet for serving static
79 resources; Petclinic relies on it for its images.
80 - On containers without such a mapping (ex: GlassFish), uncomment the
81 'default' declaration in "WEB-INF/web.xml".
82
83 ==========================================================================
84 === JPA on Tomcat
85 ==========================================================================
86
87 This section provides tips on using the Java Persistence API (JPA) on
88 Apache Tomcat 4.x or higher with a persistence provider that requires
89 class instrumentation (such as TopLink Essentials).
90
91 To use JPA class instrumentation, Tomcat has to be instructed to use a
92 custom class loader which supports instrumentation. See the JPA section of
93 the Spring reference manual for complete details.
94
95 The basic steps are:
96 - Copy "org.springframework.instrument.tomcat-3.0.0.RELEASE.jar" from the
97 Spring distribution to "TOMCAT_HOME/server/lib".
98 - If you're running on Tomcat 5.x, modify "TOMCAT_HOME/conf/server.xml"
99 and add a new "<Context>" element for 'petclinic' (see below). You can
100 alternatively deploy the WAR including "META-INF/context.xml" from this
101 sample application's "src/main/webapp" directory, in which case you
102 will need to uncomment the Loader element in that file to enable the
103 use of the TomcatInstrumentableClassLoader.
104
105 <Context path="/petclinic" docBase="/petclinic/location" ...>
106 <!-- please note that useSystemClassLoaderAsParent is available since Tomcat 5.5.20; remove it if previous versions are being used -->
107 <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false"/>
108 ...
109 </Context>
Something went wrong with that request. Please try again.