Petclinic seems to work

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@310 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Arjen Poutsma 2008-11-20 15:08:30 +00:00
parent d5c8a26643
commit 7b12e5f570
4 changed files with 145 additions and 45 deletions

View File

@ -1,5 +1,5 @@
#HSQL Database Engine 1.8.0.9
#Thu Nov 20 16:03:56 CET 2008
#HSQL Database Engine
#Mon Jan 09 09:39:15 GMT 2006
hsqldb.script_format=0
runtime.gc_interval=0
sql.enforce_strict_size=false
@ -10,6 +10,7 @@ hsqldb.cache_scale=14
version=1.8.0
hsqldb.default_table_type=memory
hsqldb.cache_file_scale=1
sql.compare_in_locale=false
hsqldb.log_size=200
modified=yes
hsqldb.cache_version=1.7.0

View File

@ -11,9 +11,6 @@
<configurations>
<include file="${spring.build.dir}/common/default-ivy-configurations.xml"/>
<conf name="hibernate" extends="runtime" description="JARs needed to use Hibernate"/>
<conf name="jpa" extends="runtime" description="JARs needed to develop JPA beans"/>
<conf name="toplink-essentials" extends="jpa" description="JARs needed to use TopLink Essentials JPA"/>
</configurations>
<publications>
@ -22,20 +19,23 @@
</publications>
<dependencies>
<dependency org="com.oracle.toplink.essentials" name="com.springsource.oracle.toplink.essentials" rev="2.0.0.b41-beta2" conf="optional, toplink-essentials->compile"/>
<dependency org="javax.persistence" name="com.springsource.javax.persistence" rev="1.0.0" conf="provided, jpa->compile"/>
<dependency org="javax.servlet" name="com.springsource.javax.servlet" rev="2.4.0" conf="compile->compile"/>
<dependency org="com.oracle.toplink.essentials" name="com.springsource.oracle.toplink.essentials" rev="2.0.0.b41-beta2" conf="compile->compile"/>
<dependency org="javax.persistence" name="com.springsource.javax.persistence" rev="1.0.0" conf="compile->compile"/>
<dependency org="javax.servlet" name="com.springsource.javax.servlet" rev="2.4.0" conf="provided->runtime"/>
<dependency org="javax.servlet" name="com.springsource.javax.servlet.jsp.jstl" rev="1.1.2" conf="compile->runtime"/>
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.logging" rev="1.1.1" conf="compile->compile"/>
<dependency org="org.apache.log4j" name="com.springsource.org.apache.log4j" rev="1.2.15" conf="compile->compile"/>
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.dbcp" rev="1.2.2.osgi" conf="compile->runtime"/>
<dependency org="org.apache.taglibs" name="com.springsource.org.apache.taglibs.standard" rev="1.1.2" conf="compile->runtime"/>
<dependency org="org.aspectj" name="com.springsource.org.aspectj.weaver" rev="1.5.4" conf="compile->compile"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate" rev="3.2.6.ga" conf="optional, hibernate->compile"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate" rev="3.2.6.ga" conf="compile->compile"/>
<dependency org="org.hsqldb" name="com.springsource.org.hsqldb" rev="1.8.0.9" conf="compile->runtime"/>
<dependency org="org.objectweb.asm" name="com.springsource.org.objectweb.asm" rev="2.2.3" conf="compile->compile" />
<dependency org="org.objectweb.asm" name="com.springsource.org.objectweb.asm.commons" rev="2.2.3" conf="compile->compile" />
<dependency org="org.springframework" name="org.springframework.orm" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.web.servlet" rev="latest.integration" conf="compile->compile"/>
<!-- test dependencies -->
<dependency org="org.junit" name="com.springsource.org.junit" rev="4.4.0" conf="test->runtime" />
<dependency org="org.springframework" name="org.springframework.test" rev="latest.integration" conf="test->compile"/>
<dependency org="org.objectweb.asm" name="com.springsource.org.objectweb.asm" rev="2.2.3" conf="test->compile" />
<dependency org="org.objectweb.asm" name="com.springsource.org.objectweb.asm.commons" rev="2.2.3" conf="test->compile" />
</dependencies>

View File

@ -1,30 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<facet type="jpa" name="JPA">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" optional="false" version="2.5" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
<building>
<setting name="EXPLODED_URL" value="file://$MODULE_DIR$/../out/exploded/petclinicWeb" />
<setting name="EXPLODED_ENABLED" value="true" />
<setting name="JAR_URL" value="file://" />
<setting name="JAR_ENABLED" value="false" />
<setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
</building>
<packaging>
<containerElement type="module" name="petclinic">
<attribute name="method" value="1" />
<attribute name="URI" value="/WEB-INF/classes" />
</containerElement>
</packaging>
<setting name="validation-enabled" value="true" />
<setting name="provider-name" value="" />
<setting name="targe-facet" value="" />
<datasource-mapping>
<factory-entry name="PetClinic" />
</datasource-mapping>
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" optional="false" version="1.0" />
</configuration>
</facet>
<facet type="web" name="Web2">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" optional="false" version="2.5" />
@ -32,11 +20,15 @@
<webroots>
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
</webroots>
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
<building>
<setting name="EXPLODED_URL" value="file://" />
<setting name="EXPLODED_ENABLED" value="false" />
<setting name="JAR_URL" value="file://" />
<setting name="JAR_ENABLED" value="false" />
<setting name="JAR_URL" value="file://$MODULE_DIR$/../out/petclinic.war" />
<setting name="JAR_ENABLED" value="true" />
<setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
</building>
<packaging>
@ -47,21 +39,14 @@
</packaging>
</configuration>
</facet>
<facet type="jpa" name="JPA">
<configuration>
<setting name="validation-enabled" value="true" />
<setting name="provider-name" value="" />
<setting name="targe-facet" value="" />
<datasource-mapping />
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" optional="false" version="1.0" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
@ -136,6 +121,15 @@
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/j2ee.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

View File

@ -0,0 +1,105 @@
=========================================
== Spring PetClinic sample application ==
=========================================
@author Ken Krebs
@author Juergen Hoeller
@author Rob Harrop
@author Costin Leau
@author Sam Brannen
--------------------------------------------------------------------------------
1. DATA ACCESS STRATEGIES
PetClinic features alternative DAO implementations and application
configurations for JDBC, Hibernate and JPA, with HSQLDB and MySQL as target
databases. The default PetClinic configuration is JDBC on HSQLDB. See
"src/jdbc.properties", "war/WEB-INF/web.xml" and
"war/WEB-INF/applicationContext-*.xml" for details. A simple comment change in
"web.xml" switches between the data access strategies.
The JDBC and Hibernate versions of PetClinic also demonstrate JMX support via
the use of "<context:mbean-export/>" for exporting MBeans. SimpleJdbcClinic
exposes the SimpleJdbcClinicMBean management interface via JMX through the use
of the @ManagedResource and @ManagedOperation annotations; whereas, the
HibernateStatistics service is exposed via JMX through auto-detection of the
service MBean. You can start up the JDK's JConsole to manage the exported bean.
The Spring distribution comes with all required Hibernate and TopLink Essentials
(JPA RI) JAR files to be able to build and run PetClinic on those two ORM tools.
All data access strategies can work with JTA for transaction management, by
activating the JtaTransactionManager and a JndiObjectFactoryBean that refers to
a transactional container DataSource. The default for JDBC is
DataSourceTransactionManager; for Hibernate, HibernateTransactionManager; for
JPA, JpaTransactionManager. Those local strategies allow for working with any
locally defined DataSource.
Note that in the default case, the sample configurations for Hibernate and JPA
specify Spring's non-pooling DriverManagerDataSource as a local DataSource.
You can change the DataSource definition to a Commons DBCP BasicDataSource to
get proper connection pooling. See "war/WEB-INF/applicationContext-jdbc.xml" for
an example.
--------------------------------------------------------------------------------
2. BUILD AND DEPLOYMENT
This directory contains the web app source. For deployment, it needs to be built
with Apache Ant 1.6 or higher.
Run "build.bat" in this directory for available targets (e.g. "build.bat build",
"build.bat warfile"). You can use "warfile.bat" as a shortcut for WAR file
creation. The WAR file will be created in the "dist" directory.
You can also invoke an existing installation of Ant with this directory as the
execution directory. Note that you must do this in order to execute the "tests"
target, as you need the JUnit task from Ant's optional.jar, which is not
included in this sample application.
To execute the web application with its default settings, simply start the
HSQLDB instance in the "db/hsqldb" directory, for example using "server.bat".
For MySQL, you'll need to use the corresponding schema and SQL scripts in the
"db/mysql" subdirectory. Follow the steps outlined in
"db/mysql/petclinic_db_setup_mysql.txt" for explicit details.
In you intend to use a local DataSource, the JDBC settings can be adapted in
"src/jdbc.properties". To use a JTA DataSource, you need to set up corresponding
DataSources in your Java EE container.
Notes on enabling Log4J:
- Log4J is disabled by default, due to JBoss issues
- Uncomment the Log4J listener in "WEB-INF/web.xml"
--------------------------------------------------------------------------------
3. JPA ON TOMCAT
Notes on using the Java Persistence API (JPA) on Apache Tomcat 4.x or higher,
with a persistence provider that requires class instrumentation (such as TopLink
Essentials):
To use JPA class instrumentation, Tomcat has to be instructed to use a custom
class loader which supports instrumentation. See the JPA section of the Spring
reference manual for complete details.
The basic steps are:
- Copy "spring-tomcat-weaver.jar" from the Spring distribution to
"TOMCAT_HOME/server/lib".
- If you're running on Tomcat 5.x, modify "TOMCAT_HOME/conf/server.xml"
and add a new "<Context>" element for 'petclinic' (see below). You can
alternatively deploy the WAR including "META-INF/context.xml" from this
sample application's "war" directory, in which case you will need to
uncomment the Loader element in that file to enable the use of the
TomcatInstrumentableClassLoader.
<Context path="/petclinic" docBase="/petclinic/location" ...>
<!-- please note that useSystemClassLoaderAsParent is available since Tomcat 5.5.20; remove it if previous versions are being used -->
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false"/>
...
</Context>