SPR-6448
+ commit the gross of the files
+ added maven pom
This commit is contained in:
Costin Leau 2009-11-25 18:45:52 +00:00 committed by Mic
parent 9dd07f05f3
commit 521d01db95
117 changed files with 6945 additions and 10 deletions

View file

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!-- Custom aspects for the PetClinic sample application -->
<aspectj>
<weaver>
<include within="org.springframework.samples.petclinic..*"/>
</weaver>
<aspects>
<aspect name="org.springframework.samples.petclinic.aspects.UsageLogAspect"/>
<concrete-aspect name="org.springframework.samples.petclinic.aspects.ApplicationTraceAspect"
extends="org.springframework.samples.petclinic.aspects.AbstractTraceAspect">
<pointcut name="traced" expression="execution(* org.springframework.samples..*.*(..))"/>
</concrete-aspect>
</aspects>
</aspectj>

View file

@ -0,0 +1,7 @@
<!-- Tomcat context descriptor used for specifying a custom ClassLoader -->
<Context path="/petclinic" reloadable="false">
<!-- please note that useSystemClassLoaderAsParent is available since Tomcat 5.5.20 / remove if previous versions are being used -->
<!--
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false"/>
-->
</Context>

View file

@ -0,0 +1,7 @@
DROP TABLE visits;
DROP TABLE pets;
DROP TABLE owners;
DROP TABLE types;
DROP TABLE vet_specialties;
DROP TABLE specialties;
DROP TABLE vets;

View file

@ -0,0 +1,55 @@
CREATE TABLE vets (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30)
);
CREATE INDEX vets_last_name ON vets(last_name);
CREATE TABLE specialties (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
name VARCHAR(80)
);
CREATE INDEX specialties_name ON specialties(name);
CREATE TABLE vet_specialties (
vet_id INTEGER NOT NULL,
specialty_id INTEGER NOT NULL
);
alter table vet_specialties add constraint fk_vet_specialties_vets foreign key (vet_id) references vets(id);
alter table vet_specialties add constraint fk_vet_specialties_specialties foreign key (specialty_id) references specialties(id);
CREATE TABLE types (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
name VARCHAR(80)
);
CREATE INDEX types_name ON types(name);
CREATE TABLE owners (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30),
address VARCHAR(255),
city VARCHAR(80),
telephone VARCHAR(20)
);
CREATE INDEX owners_last_name ON owners(last_name);
CREATE TABLE pets (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
name VARCHAR(30),
birth_date DATE,
type_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL
);
alter table pets add constraint fk_pets_owners foreign key (owner_id) references owners(id);
alter table pets add constraint fk_pets_types foreign key (type_id) references types(id);
CREATE INDEX pets_name ON pets(name);
CREATE TABLE visits (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
pet_id INTEGER NOT NULL,
visit_date DATE,
description VARCHAR(255)
);
alter table visits add constraint fk_visits_pets foreign key (pet_id) references pets(id);
CREATE INDEX visits_pet_id ON visits(pet_id);

View file

@ -0,0 +1,53 @@
INSERT INTO vets VALUES (1, 'James', 'Carter');
INSERT INTO vets VALUES (2, 'Helen', 'Leary');
INSERT INTO vets VALUES (3, 'Linda', 'Douglas');
INSERT INTO vets VALUES (4, 'Rafael', 'Ortega');
INSERT INTO vets VALUES (5, 'Henry', 'Stevens');
INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins');
INSERT INTO specialties VALUES (1, 'radiology');
INSERT INTO specialties VALUES (2, 'surgery');
INSERT INTO specialties VALUES (3, 'dentistry');
INSERT INTO vet_specialties VALUES (2, 1);
INSERT INTO vet_specialties VALUES (3, 2);
INSERT INTO vet_specialties VALUES (3, 3);
INSERT INTO vet_specialties VALUES (4, 2);
INSERT INTO vet_specialties VALUES (5, 1);
INSERT INTO types VALUES (1, 'cat');
INSERT INTO types VALUES (2, 'dog');
INSERT INTO types VALUES (3, 'lizard');
INSERT INTO types VALUES (4, 'snake');
INSERT INTO types VALUES (5, 'bird');
INSERT INTO types VALUES (6, 'hamster');
INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
INSERT INTO pets VALUES (1, 'Leo', '2000-09-07', 1, 1);
INSERT INTO pets VALUES (2, 'Basil', '2002-08-06', 6, 2);
INSERT INTO pets VALUES (3, 'Rosy', '2001-04-17', 2, 3);
INSERT INTO pets VALUES (4, 'Jewel', '2000-03-07', 2, 3);
INSERT INTO pets VALUES (5, 'Iggy', '2000-11-30', 3, 4);
INSERT INTO pets VALUES (6, 'George', '2000-01-20', 4, 5);
INSERT INTO pets VALUES (7, 'Samantha', '1995-09-04', 1, 6);
INSERT INTO pets VALUES (8, 'Max', '1995-09-04', 1, 6);
INSERT INTO pets VALUES (9, 'Lucky', '1999-08-06', 5, 7);
INSERT INTO pets VALUES (10, 'Mulligan', '1997-02-24', 2, 8);
INSERT INTO pets VALUES (11, 'Freddy', '2000-03-09', 5, 9);
INSERT INTO pets VALUES (12, 'Lucky', '2000-06-24', 2, 10);
INSERT INTO pets VALUES (13, 'Sly', '2002-06-08', 1, 10);
INSERT INTO visits VALUES (1, 7, '1996-03-04', 'rabies shot');
INSERT INTO visits VALUES (2, 8, '1996-03-04', 'rabies shot');
INSERT INTO visits VALUES (3, 8, '1996-06-04', 'neutered');
INSERT INTO visits VALUES (4, 7, '1996-09-04', 'spayed');

View file

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
version="1.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
<persistence-unit-defaults>
<access>PROPERTY</access>
</persistence-unit-defaults>
</persistence-unit-metadata>
<package>org.springframework.samples.petclinic</package>
<mapped-superclass class="BaseEntity">
<attributes>
<id name="id">
<generated-value strategy="IDENTITY"/>
</id>
<transient name="new"/>
</attributes>
</mapped-superclass>
<mapped-superclass class="NamedEntity">
<attributes>
<basic name="name">
<column name="NAME"/>
</basic>
</attributes>
</mapped-superclass>
<mapped-superclass class="Person">
<attributes>
<basic name="firstName">
<column name="FIRST_NAME"/>
</basic>
<basic name="lastName">
<column name="LAST_NAME"/>
</basic>
</attributes>
</mapped-superclass>
<entity class="Vet">
<table name="VETS"/>
<attributes>
<many-to-many name="specialtiesInternal" target-entity="Specialty" fetch="EAGER">
<join-table name="VET_SPECIALTIES">
<join-column name="VET_ID"/>
<inverse-join-column name="SPECIALTY_ID"/>
</join-table>
</many-to-many>
<transient name="specialties"/>
<transient name="nrOfSpecialties"/>
</attributes>
</entity>
<entity class="Specialty">
<table name="SPECIALTIES"/>
</entity>
<entity class="Owner">
<table name="OWNERS"/>
<attributes>
<basic name="address"/>
<basic name="city"/>
<basic name="telephone"/>
<one-to-many name="petsInternal" target-entity="Pet" mapped-by="owner" fetch="EAGER">
<cascade>
<cascade-all/>
</cascade>
</one-to-many>
<transient name="pets"/>
</attributes>
</entity>
<entity class="Pet">
<table name="PETS"/>
<attributes>
<basic name="birthDate">
<column name="BIRTH_DATE"/>
<temporal>DATE</temporal>
</basic>
<many-to-one name="owner" fetch="EAGER">
<cascade>
<cascade-all/>
</cascade>
</many-to-one>
<many-to-one name="type" fetch="EAGER">
<cascade>
<cascade-all/>
</cascade>
</many-to-one>
<one-to-many name="visitsInternal" target-entity="Visit" mapped-by="pet" fetch="EAGER">
<cascade>
<cascade-all/>
</cascade>
</one-to-many>
<transient name="visits"/>
</attributes>
</entity>
<entity class="PetType">
<table name="TYPES"/>
</entity>
<entity class="Visit">
<table name="VISITS"/>
<attributes>
<basic name="date">
<column name="VISIT_DATE"/>
<temporal>DATE</temporal>
</basic>
<many-to-one name="pet" fetch="EAGER">
<cascade>
<cascade-all/>
</cascade>
</many-to-one>
</attributes>
</entity>
</entity-mappings>

View file

@ -0,0 +1,16 @@
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="PetClinic" transaction-type="RESOURCE_LOCAL">
<!-- Explicitly define mapping file path, else Hibernate won't find the default -->
<mapping-file>META-INF/orm.xml</mapping-file>
<!-- Prevent annotation scanning. In this app we are purely driven by orm.xml -->
<exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>
</persistence>

View file

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Application context definition for PetClinic on Hibernate.
-->
<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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!--
Uses Apache Commons DBCP for connection pooling. See Commons DBCP documentation
for the required JAR files. Alternatively you can use another connection pool
such as C3P0, similarly configured using Spring.
-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}"
p:password="${jdbc.password}"/>
<!-- JNDI DataSource for JEE environments -->
<!--
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
-->
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
p:dataSource-ref="dataSource" p:mappingResources="petclinic.hbm.xml">
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
</props>
</property>
<property name="eventListeners">
<map>
<entry key="merge">
<bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>
</entry>
</map>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory"/>
<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
<!--
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
-->
<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
<!--
Activates various annotations to be detected in bean classes:
Spring's @Required and @Autowired, as well as JSR 250's @Resource.
-->
<context:annotation-config/>
<!--
Instruct Spring to perform declarative transaction management
automatically on annotated classes.
-->
<tx:annotation-driven/>
<!--
Exporter that exposes the Hibernate statistics service via JMX. Autodetects the
service MBean, using its bean name as JMX object name.
-->
<context:mbean-export/>
<!-- PetClinic's central data access object: Hibernate implementation -->
<bean id="clinic" class="org.springframework.samples.petclinic.hibernate.HibernateClinic"/>
<!-- Hibernate's JMX statistics service -->
<bean name="petclinic:type=HibernateStatistics" class="org.hibernate.jmx.StatisticsService" autowire="byName"/>
</beans>

View file

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Application context definition for PetClinic on JDBC.
-->
<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:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!--
Spring FactoryBean that creates a DataSource using Apache Commons DBCP for connection
pooling. See Commons DBCP documentation for the required JAR files. This factory bean
can populate the data source with a schema and data scripts if configured to do so.
An alternate factory bean can be created for different connection pool implementations,
C3P0 for example.
-->
<bean id="dataSource" class="org.springframework.samples.petclinic.config.DbcpDataSourceFactory"
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
p:username="${jdbc.username}" p:password="${jdbc.password}" p:populate="${jdbc.populate}"
p:schemaLocation="${jdbc.schemaLocation}" p:dataLocation="${jdbc.dataLocation}"/>
<!-- JNDI DataSource for JEE environments -->
<!--
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
-->
<!-- Transaction manager for a single JDBC DataSource (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref="dataSource"/>
<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
<!--
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
-->
<!-- ========================= 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 retrieve and apply @AspectJ aspects which are defined
as beans in this context (such as the CallMonitoringAspect below).
-->
<aop:aspectj-autoproxy/>
<!--
Instruct Spring to perform automatic transaction management on annotated classes.
The SimpleJdbcClinic implementation declares @Transactional annotations.
"proxy-target-class" is set because of SimpleJdbcClinic's @ManagedOperation usage.
-->
<tx:annotation-driven/>
<!--
Exporter that exposes the Clinic DAO and the CallMonitoringAspect via JMX,
based on the @ManagedResource, @ManagedAttribute, and @ManagedOperation annotations.
-->
<context:mbean-export/>
<!-- PetClinic's central data access object using Spring's SimpleJdbcTemplate -->
<bean id="clinic" class="org.springframework.samples.petclinic.jdbc.SimpleJdbcClinic"/>
<!-- Call monitoring aspect that monitors call count and call invocation time -->
<bean id="callMonitor" class="org.springframework.samples.petclinic.aspects.CallMonitoringAspect"/>
</beans>

View file

@ -0,0 +1,101 @@
<?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:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
<!--
Activates a load-time weaver for the context. Any bean within the context that
implements LoadTimeWeaverAware (such as LocalContainerEntityManagerFactoryBean)
will receive a reference to the autodetected load-time weaver.
-->
<context:load-time-weaver/>
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!--
Uses Apache Commons DBCP for connection pooling. See Commons DBCP documentation
for the required JAR files. Alternatively you can use another connection pool
such as C3P0, similarly configured using Spring.
-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}"
p:password="${jdbc.password}"/>
<!-- JNDI DataSource for JEE environments -->
<!--
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
-->
<!-- 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.TopLinkJpaVendorAdapter"
p:databasePlatform="${jpa.databasePlatform}" p:showSql="${jpa.showSql}"/>
<!--
<bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"
p:database="${jpa.database}" p:showSql="${jpa.showSql}"/>
-->
<!--
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="${jpa.database}" p:showSql="${jpa.showSql}"/>
-->
</property>
</bean>
<!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"/>
<!-- ========================= 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.
-->
<tx:annotation-driven mode="aspectj"/>
<!--
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.
-->
<bean class="org.springframework.samples.petclinic.aspects.UsageLogAspect" p:historySize="300"/>
<!--
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"/>
<!--
Will automatically be transactional due to @Transactional.
EntityManager will be auto-injected due to @PersistenceContext.
PersistenceExceptions will be auto-translated due to @Repository.
-->
<bean id="clinic" class="org.springframework.samples.petclinic.jpa.EntityManagerClinic"/>
</beans>

View file

@ -0,0 +1,18 @@
# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
# For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
log4j.rootLogger=INFO, stdout, logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=${petclinic.root}/WEB-INF/petclinic.log
log4j.appender.logfile.MaxFileSize=512KB
# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.logger.org.springframework.samples.petclinic.aspects=DEBUG

View file

@ -0,0 +1,8 @@
welcome=Welcome
required=is required
notFound=has not been found
duplicate=is already in use
nonNumeric=must be all numeric
duplicateFormSubmission=Duplicate form submission is not allowed
typeMismatch.date=invalid date
typeMismatch.birthDate=invalid date

View file

@ -0,0 +1,8 @@
welcome=Willkommen
required=muss angegeben werden
notFound=wurde nicht gefunden
duplicate=ist bereits vergeben
nonNumeric=darf nur numerisch sein
duplicateFormSubmission=Wiederholtes Absenden des Formulars ist nicht erlaubt
typeMismatch.date=ungültiges Datum
typeMismatch.birthDate=ungültiges Datum

View file

@ -0,0 +1 @@
# This file is intentionally empty. Message look-ups will fall back to the default "messages.properties" file.

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
configId="org/springframework/samples/petclinic">
<context-root>/petclinic</context-root>
<context-priority-classloader>true</context-priority-classloader>
</web-app>

View file

@ -0,0 +1,19 @@
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<%
Exception ex = (Exception) request.getAttribute("exception");
%>
<h2>Data access failure: <%= ex.getMessage() %></h2>
<p/>
<%
ex.printStackTrace(new java.io.PrintWriter(out));
%>
<p/>
<br/>
<a href="<spring:url value="/" htmlEscape="true" />">Home</a>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>

View file

@ -0,0 +1,12 @@
<table class="footer">
<tr>
<td><a href="<spring:url value="/" htmlEscape="true" />">Home</a></td>
<td align="right"><img src="<spring:url value="/static/images/springsource-logo.png" htmlEscape="true" />" alt="Sponsored by SpringSource"/></td>
</tr>
</table>
</div>
</body>
</html>

View file

@ -0,0 +1,14 @@
<!--
PetClinic :: a Spring Framework demonstration
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="<spring:url value="/static/styles/petclinic.css" htmlEscape="true" />" type="text/css"/>
<title>PetClinic :: a Spring Framework demonstration</title>
</head>
<body>
<div id="main">

View file

@ -0,0 +1,5 @@
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

View file

@ -0,0 +1,61 @@
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<c:choose>
<c:when test="${owner.new}"><c:set var="method" value="post"/></c:when>
<c:otherwise><c:set var="method" value="put"/></c:otherwise>
</c:choose>
<h2><c:if test="${owner.new}">New </c:if>Owner:</h2>
<form:form modelAttribute="owner" method="${method}">
<table>
<tr>
<th>
First Name: <form:errors path="firstName" cssClass="errors"/>
<br/>
<form:input path="firstName" size="30" maxlength="80"/>
</th>
</tr>
<tr>
<th>
Last Name: <form:errors path="lastName" cssClass="errors"/>
<br/>
<form:input path="lastName" size="30" maxlength="80"/>
</th>
</tr>
<tr>
<th>
Address: <form:errors path="address" cssClass="errors"/>
<br/>
<form:input path="address" size="30" maxlength="80"/>
</th>
</tr>
<tr>
<th>
City: <form:errors path="city" cssClass="errors"/>
<br/>
<form:input path="city" size="30" maxlength="80"/>
</th>
</tr>
<tr>
<th>
Telephone: <form:errors path="telephone" cssClass="errors"/>
<br/>
<form:input path="telephone" size="20" maxlength="20"/>
</th>
</tr>
<tr>
<td>
<c:choose>
<c:when test="${owner.new}">
<p class="submit"><input type="submit" value="Add Owner"/></p>
</c:when>
<c:otherwise>
<p class="submit"><input type="submit" value="Update Owner"/></p>
</c:otherwise>
</c:choose>
</td>
</tr>
</table>
</form:form>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>

View file

@ -0,0 +1,34 @@
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<h2>Owners:</h2>
<table>
<thead>
<th>Name</th>
<th>Address</th>
<th>City</th>
<th>Telephone</th>
<th>Pets</th>
</thead>
<c:forEach var="owner" items="${selections}">
<tr>
<td>
<spring:url value="owners/{ownerId}" var="ownerUrl">
<spring:param name="ownerId" value="${owner.id}"/>
</spring:url>
<a href="${fn:escapeXml(ownerUrl)}">${owner.firstName} ${owner.lastName}</a>
</td>
<td>${owner.address}</td>
<td>${owner.city}</td>
<td>${owner.telephone}</td>
<td>
<c:forEach var="pet" items="${owner.pets}">
${pet.name} &nbsp;
</c:forEach>
</td>
</tr>
</c:forEach>
</table>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>

View file

@ -0,0 +1,26 @@
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<h2>Find Owners:</h2>
<spring:url value="/owners" var="formUrl"/>
<form:form modelAttribute="owner" action="${fn:escapeXml(formUrl)}" method="get">
<table>
<tr>
<th>
Last Name: <form:errors path="*" cssClass="errors"/>
<br/>
<form:input path="lastName" size="30" maxlength="80" />
</th>
</tr>
<tr>
<td><p class="submit"><input type="submit" value="Find Owners"/></p></td>
</tr>
</table>
</form:form>
<br/>
<a href='<spring:url value="/owners/new" htmlEscape="true"/>'>Add Owner</a>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>

View file

@ -0,0 +1,108 @@
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<h2>Owner Information</h2>
<table>
<tr>
<th>Name</th>
<td><b>${owner.firstName} ${owner.lastName}</b></td>
</tr>
<tr>
<th>Address</th>
<td>${owner.address}</td>
</tr>
<tr>
<th>City</th>
<td>${owner.city}</td>
</tr>
<tr>
<th>Telephone </th>
<td>${owner.telephone}</td>
</tr>
</table>
<table class="table-buttons">
<tr>
<td colspan="2" align="center">
<spring:url value="{ownerId}/edit" var="editUrl">
<spring:param name="ownerId" value="${owner.id}" />
</spring:url>
<a href="${fn:escapeXml(editUrl)}">Edit Owner</a>
</td>
<td>
<spring:url value="{ownerId}/pets/new" var="addUrl">
<spring:param name="ownerId" value="${owner.id}" />
</spring:url>
<a href="${fn:escapeXml(addUrl)}">Add New Pet</a>
</td>
</tr>
</table>
<h2>Pets and Visits</h2>
<c:forEach var="pet" items="${owner.pets}">
<table width="94%">
<tr>
<td valign="top">
<table>
<tr>
<th>Name</th>
<td><b>${pet.name}</b></td>
</tr>
<tr>
<th>Birth Date</th>
<td><fmt:formatDate value="${pet.birthDate}" pattern="yyyy-MM-dd"/></td>
</tr>
<tr>
<th>Type</th>
<td>${pet.type.name}</td>
</tr>
</table>
</td>
<td valign="top">
<table>
<thead>
<th>Visit Date</th>
<th>Description</th>
</thead>
<c:forEach var="visit" items="${pet.visits}">
<tr>
<td><fmt:formatDate value="${visit.date}" pattern="yyyy-MM-dd"/></td>
<td>${visit.description}</td>
</tr>
</c:forEach>
</table>
</td>
</tr>
</table>
<table class="table-buttons">
<tr>
<td>
<spring:url value="{ownerId}/pets/{petId}/edit" var="petUrl">
<spring:param name="ownerId" value="${owner.id}"/>
<spring:param name="petId" value="${pet.id}"/>
</spring:url>
<a href="${fn:escapeXml(petUrl)}">Edit Pet</a>
</td>
<td></td>
<td>
<spring:url value="{ownerId}/pets/{petId}/visits/new" var="visitUrl">
<spring:param name="ownerId" value="${owner.id}"/>
<spring:param name="petId" value="${pet.id}"/>
</spring:url>
<a href="${fn:escapeXml(visitUrl)}">Add Visit</a>
</td>
<td></td>
<td>
<spring:url value="{ownerId}/pets/{petId}/visits.atom" var="feedUrl">
<spring:param name="ownerId" value="${owner.id}"/>
<spring:param name="petId" value="${pet.id}"/>
</spring:url>
<a href="${fn:escapeXml(feedUrl)}" rel="alternate" type="application/atom+xml">Atom Feed</a>
</td>
</tr>
</table>
</c:forEach>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>

View file

@ -0,0 +1,56 @@
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<c:choose>
<c:when test="${pet.new}"><c:set var="method" value="post"/></c:when>
<c:otherwise><c:set var="method" value="put"/></c:otherwise>
</c:choose>
<h2><c:if test="${pet.new}">New </c:if>Pet</h2>
<b>Owner:</b> ${pet.owner.firstName} ${pet.owner.lastName}
<br/>
<form:form modelAttribute="pet" method="${method}">
<table>
<tr>
<th>
Name: <form:errors path="name" cssClass="errors"/>
<br/>
<form:input path="name" size="30" maxlength="30"/>
</th>
</tr>
<tr>
<th>
Birth Date: <form:errors path="birthDate" cssClass="errors"/>
<br/>
<form:input path="birthDate" size="10" maxlength="10"/> (yyyy-mm-dd)
</th>
</tr>
<tr>
<th>
Type: <form:errors path="type" cssClass="errors"/>
<br/>
<form:select path="type" items="${types}"/>
</th>
</tr>
<tr>
<td>
<c:choose>
<c:when test="${pet.new}">
<p class="submit"><input type="submit" value="Add Pet"/></p>
</c:when>
<c:otherwise>
<p class="submit"><input type="submit" value="Update Pet"/></p>
</c:otherwise>
</c:choose>
</td>
</tr>
</table>
</form:form>
<c:if test="${!pet.new}">
<form:form method="delete">
<p class="submit"><input type="submit" value="Delete Pet"/></p>
</form:form>
</c:if>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>

View file

@ -0,0 +1,68 @@
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<h2><c:if test="${visit.new}">New </c:if>Visit:</h2>
<form:form modelAttribute="visit">
<b>Pet:</b>
<table width="333">
<thead>
<th>Name</th>
<th>Birth Date</th>
<th>Type</th>
<th>Owner</th>
</thead>
<tr>
<td>${visit.pet.name}</td>
<td><fmt:formatDate value="${visit.pet.birthDate}" pattern="yyyy-MM-dd"/></td>
<td>${visit.pet.type.name}</td>
<td>${visit.pet.owner.firstName} ${visit.pet.owner.lastName}</td>
</tr>
</table>
<table width="333">
<tr>
<th>
Date:
<br/><form:errors path="date" cssClass="errors"/>
</th>
<td>
<form:input path="date" size="10" maxlength="10"/> (yyyy-mm-dd)
</td>
<tr/>
<tr>
<th valign="top">
Description:
<br/><form:errors path="description" cssClass="errors"/>
</th>
<td>
<form:textarea path="description" rows="10" cols="25"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" name="petId" value="${visit.pet.id}"/>
<p class="submit"><input type="submit" value="Add Visit"/></p>
</td>
</tr>
</table>
</form:form>
<br/>
<b>Previous Visits:</b>
<table width="333">
<tr>
<th>Date</th>
<th>Description</th>
</tr>
<c:forEach var="visit" items="${visit.pet.visits}">
<c:if test="${!visit.new}">
<tr>
<td><fmt:formatDate value="${visit.date}" pattern="yyyy-MM-dd"/></td>
<td>${visit.description}</td>
</tr>
</c:if>
</c:forEach>
</table>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>

View file

@ -0,0 +1,49 @@
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<h2/>Internal error</h2>
<p/>
<%
try {
// The Servlet spec guarantees this attribute will be available
Throwable exception = (Throwable) request.getAttribute("javax.servlet.error.exception");
if (exception != null) {
if (exception instanceof ServletException) {
// It's a ServletException: we should extract the root cause
ServletException sex = (ServletException) exception;
Throwable rootCause = sex.getRootCause();
if (rootCause == null)
rootCause = sex;
out.println("** Root cause is: "+ rootCause.getMessage());
rootCause.printStackTrace(new java.io.PrintWriter(out));
}
else {
// It's not a ServletException, so we'll just show it
exception.printStackTrace(new java.io.PrintWriter(out));
}
}
else {
out.println("No error information available");
}
// Display cookies
out.println("\nCookies:\n");
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
out.println(cookies[i].getName() + "=[" + cookies[i].getValue() + "]");
}
}
} catch (Exception ex) {
ex.printStackTrace(new java.io.PrintWriter(out));
}
%>
<p/>
<br/>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>

View file

@ -0,0 +1,31 @@
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<h2>Veterinarians:</h2>
<table>
<thead>
<th>Name</th>
<th>Specialties</th>
</thead>
<c:forEach var="vet" items="${vets.vetList}">
<tr>
<td>${vet.firstName} ${vet.lastName}</td>
<td>
<c:forEach var="specialty" items="${vet.specialties}">
${specialty.name}
</c:forEach>
<c:if test="${vet.nrOfSpecialties == 0}">none</c:if>
</td>
</tr>
</c:forEach>
</table>
<table class="table-buttons">
<tr>
<td>
<a href="<spring:url value="/vets.xml" htmlEscape="true" />">View as XML</a>
</td>
</tr>
</table>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>

View file

@ -0,0 +1,15 @@
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<img src="<spring:url value="/static/images/pets.png" htmlEscape="true" />" align="right" style="position:relative;right:30px;">
<h2><fmt:message key="welcome"/></h2>
<ul>
<li><a href="<spring:url value="/owners/search" htmlEscape="true" />">Find owner</a></li>
<li><a href="<spring:url value="/vets" htmlEscape="true" />">Display all veterinarians</a></li>
<li><a href="<spring:url value="/static/html/tutorial.html" htmlEscape="true" />">Tutorial</a></li>
</ul>
<p>&nbsp;</p>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>

View file

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- DispatcherServlet application context for PetClinic's web tier.
-->
<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:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">
<!--
- The controllers are autodetected POJOs labeled with the @Controller annotation.
-->
<context:component-scan base-package="org.springframework.samples.petclinic.web"/>
<!--
- The form-based controllers within this application provide @RequestMapping
- 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, ClinicController - which is not form-based - provides
- @RequestMapping only at the method level for path mapping URLs.
-
- DefaultAnnotationHandlerMapping is driven by these annotations and is
- enabled by default with Java 5+.
-->
<!--
- This bean processes annotated handler methods, applying PetClinic-specific PropertyEditors
- for request parameter binding. It overrides the default AnnotationMethodHandlerAdapter.
-->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<bean class="org.springframework.samples.petclinic.web.ClinicBindingInitializer"/>
</property>
</bean>
<!--
- This bean resolves specific types of exceptions to corresponding logical
- view names for error views. The default behaviour of DispatcherServlet
- is to propagate all exceptions to the servlet container: this will happen
- here with all other types of exceptions.
-->
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="org.springframework.web.servlet.PageNotFound">pageNotFound</prop>
<prop key="org.springframework.dao.DataAccessException">dataAccessFailure</prop>
<prop key="org.springframework.transaction.TransactionException">dataAccessFailure</prop>
</props>
</property>
</bean>
<!--
- This view resolver delegates to the InternalResourceViewResolver and BeanNameViewResolver,
- and uses the requested media type to pick a matching view. When the media type is 'text/html',
- it will delegate to the InternalResourceViewResolver's JstlView, otherwise to the
- BeanNameViewResolver. Note the use of the expression language to refer to the contentType
- property of the vets view bean, setting it to 'application/vnd.springsource.samples.petclinic+xml'.
-->
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="xml" value="#{vets.contentType}"/>
<entry key="atom" value="#{visits.contentType}"/>
</map>
</property>
<property name="order" value="0"/>
</bean>
<!--
- The BeanNameViewResolver is used to pick up the visits view name (below).
- It has the order property set to 2, which means that this will
- be the first view resolver to be used after the delegating content
- negotiating view resolver.
-->
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="1"/>
<!--
- This bean configures the 'prefix' and 'suffix' properties of
- InternalResourceViewResolver, which resolves logical view names
- returned by Controllers. For example, a logical view name of "vets"
- will be mapped to "/WEB-INF/jsp/vets.jsp".
-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" p:order="2"/>
<!--
- The AtomView rendering a Atom feed of the visits
-->
<bean id="visits" class="org.springframework.samples.petclinic.web.VisitsAtomView"/>
<bean id="vets" class="org.springframework.web.servlet.view.xml.MarshallingView">
<property name="contentType" value="application/vnd.springsource.samples.petclinic+xml"/>
<property name="marshaller" ref="marshaller"/>
</bean>
<oxm:jaxb2-marshaller id="marshaller">
<oxm:class-to-be-bound name="org.springframework.samples.petclinic.Vets"/>
</oxm:jaxb2-marshaller>
<!--
- Message source for this context, loaded from localized "messages_xx" files.
- Could also reside in the root application context, as it is generic,
- but is currently just used within PetClinic's web tier.
-->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"
p:basename="messages"/>
</beans>

View file

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Spring PetClinic</display-name>
<description>Spring PetClinic sample application</description>
<!--
Key of the system property that should specify the root directory of this
web app. Applied by WebAppRootListener or Log4jConfigListener.
-->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>petclinic.root</param-value>
</context-param>
<!--
Location of the Log4J config file, for initialization and refresh checks.
Applied by Log4jConfigListener.
-->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<!--
- Location of the XML file that defines the root application context.
- Applied by ContextLoaderServlet.
-
- Can be set to:
- "/WEB-INF/applicationContext-hibernate.xml" for the Hibernate implementation,
- "/WEB-INF/applicationContext-jpa.xml" for the JPA one, or
- "/WEB-INF/applicationContext-jdbc.xml" for the JDBC one.
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-jdbc.xml</param-value>
<!--
<param-value>/WEB-INF/applicationContext-hibernate.xml</param-value>
<param-value>/WEB-INF/applicationContext-jpa.xml</param-value>
-->
<!--
To use the JPA variant above, you will need to enable Spring load-time
weaving in your server environment. See PetClinic's readme and/or
Spring's JPA documentation for information on how to do this.
-->
</context-param>
<!--
- Configures Log4J for this web app.
- As this context specifies a context-param "log4jConfigLocation", its file path
- is used to load the Log4J configuration, including periodic refresh checks.
-
- Would fall back to default Log4J initialization (non-refreshing) if no special
- context-params are given.
-
- Exports a "web app root key", i.e. a system property that specifies the root
- directory of this web app, for usage in log file paths.
- This web app specifies "petclinic.root" (see log4j.properties file).
-->
<!-- Leave the listener commented-out if using JBoss -->
<!--
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
-->
<!--
- Loads the root application context of this web app at startup,
- by default from "/WEB-INF/applicationContext.xml".
- Note that you need to fall back to Spring's ContextLoaderServlet for
- J2EE servers that do not follow the Servlet 2.4 initialization order.
-
- Use WebApplicationContextUtils.getWebApplicationContext(servletContext)
- to access it anywhere in the web application, outside of the framework.
-
- The root context is the parent of all servlet-specific contexts.
- This means that its beans are automatically available in these child contexts,
- both for getBean(name) calls and (external) bean references.
-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--
- Map static resources to the default servlet
- examples:
- http://localhost:8080/static/images/pets.png
- http://localhost:8080/static/styles/petclinic.css
-->
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/static/*</url-pattern>
</servlet-mapping>
<!--
- Servlet that dispatches request to registered handlers (Controller implementations).
- Has its own application context, by default defined in "{servlet-name}-servlet.xml",
- i.e. "petclinic-servlet.xml".
-
- A web app can contain any number of such servlets.
- Note that this web app has a shared root application context, serving as parent
- of all DispatcherServlet contexts.
-->
<servlet>
<servlet-name>petclinic</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<!--
- Maps the petclinic dispatcher to "*.do". All handler mappings in
- petclinic-servlet.xml will by default be applied to this subpath.
- If a mapping isn't a /* subpath, the handler mappings are considered
- relative to the web app root.
-
- NOTE: A single dispatcher can be mapped to multiple paths, like any servlet.
-->
<servlet-mapping>
<servlet-name>petclinic</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>httpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>httpMethodFilter</filter-name>
<servlet-name>petclinic</servlet-name>
</filter-mapping>
<session-config>
<session-timeout>10</session-timeout>
</session-config>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<!-- Displays a stack trace -->
<location>/WEB-INF/jsp/uncaughtException.jsp</location>
</error-page>
<!--
- Reference to PetClinic database.
- Only needed if not using a local DataSource but a JNDI one instead.
-->
<!--
<resource-ref>
<res-ref-name>jdbc/petclinic</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
-->
</web-app>

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -0,0 +1,234 @@
/* main elements */
body,div,td {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666;
}
body {
background-color: #fff;
background-image: url(../images/banner-graphic.png);
background-position: top center;
background-repeat: no-repeat;
text-align: center;
min-width: 600px;
margin-top: 60px;
margin-left: auto;
margin-right: auto;
}
div {
margin: 5px 25px 5px 25px;
text-align: left;
}
/* header and footer elements */
#main {
margin:0 auto;
position:relative;
top: 35px;
left:0px;
width:560px;
text-align:left;
}
.footer {
background:#fff;
border:none;
margin-top:20px;
border-top:1px solid #999999;
width:100%;
}
.footer td {color:#999999;}
.footer a:link {color: #7db223;}
/* text styles */
h1,h2,h3 {
font-family: Helvetica, sans-serif;
color: #7db223;
}
h1 {
font-size: 20px;
line-height: 26px;
}
h2 {
font-size: 18px;
line-height: 24px;
}
h3 {
font-size: 15px;
line-height: 21px;
color:#555;
}
h4 {
font-size: 14px;
line-height: 20px;
}
.errors {
color: red;
font-weight: bold;
}
a {
text-decoration: underline;
font-size: 13px;
}
a:link {
color: #7db223;
}
a:hover {
color: #456314;
}
a:active {
color: #7db223;
}
a:visited {
color: #7db223;
}
ul {
list-style: disc url(../images/bullet-arrow.png);
}
li {
padding-top: 5px;
text-align: left;
}
li ul {
list-style: square url(../images/bullet-arrow.png);
}
li ul li ul {
list-style: circle none;
}
/* table elements */
table {
background: #d6e2c3;
margin: 3px 0 0 0;
border: 4px solid #d6e2c3;
border-collapse: collapse;
}
table table {
margin: -5px 0;
border: 0px solid #e0e7d3;
width: 100%;
}
table td,table th {
padding: 8px;
}
table th {
font-size: 12px;
text-align: left;
font-weight: bold;
}
table thead {
font-weight: bold;
font-style: italic;
background-color: #c2ceaf;
}
table a:link {color: #303030;}
caption {
caption-side: top;
width: auto;
text-align: left;
font-size: 12px;
color: #848f73;
padding-bottom: 4px;
}
fieldset {
background: #e0e7d3;
padding: 8px;
padding-bottom: 22px;
border: none;
width: 560px;
}
fieldset label {
width: 70px;
float: left;
margin-top: 1.7em;
margin-left: 20px;
}
fieldset textfield {
margin: 3px;
height: 20px;
background: #e0e7d3;
}
fieldset textarea {
margin: 3px;
height: 165px;
background: #e0e7d3;
}
fieldset input {
margin: 3px;
height: 20px;
background: #e0e7d3;
}
fieldset table {
width: 100%;
}
fieldset th {
padding-left: 25px;
}
.table-buttons {
background-color:#fff;
border:none;
}
.table-buttons td {
border:none;
}
.submit input {
background:url(../images/submit-bg.png) repeat-x;
border: 2px outset #d7b9c9;
color:#383838;
padding:2px 10px;
font-size:11px;
text-transform:uppercase;
font-weight:bold;
}
.updated {
background:#ecf1e5;
font-size:11px;
margin-left:2px;
border:4px solid #ecf1e5;
}
.updated td {
padding:2px 8px;
font-size:11px;
color:#888888;
}