Browse files

Granny's Address book - Spring MVC application used for training at OSIL

  • Loading branch information...
1 parent a67309e commit 91932fda86ac027c02b6dda6dc71df4867238efc @lpintosil committed Oct 8, 2012
Showing with 1,190 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +14 −0 SpringGrannyMVC/.classpath
  3. +50 −0 SpringGrannyMVC/.project
  4. +2 −0 SpringGrannyMVC/.settings/com.springsource.server.ide.jdt.core.xml
  5. +12 −0 SpringGrannyMVC/.settings/org.eclipse.jdt.core.prefs
  6. +3 −0 SpringGrannyMVC/.settings/org.eclipse.jst.common.project.facet.core.prefs
  7. +10 −0 SpringGrannyMVC/.settings/org.eclipse.wst.common.component
  8. +7 −0 SpringGrannyMVC/.settings/org.eclipse.wst.common.project.facet.core.xml
  9. +6 −0 SpringGrannyMVC/.settings/org.eclipse.wst.validation.prefs
  10. +9 −0 SpringGrannyMVC/.settings/org.maven.ide.eclipse.prefs
  11. +78 −0 SpringGrannyMVC/.settings/org.springframework.ide.eclipse.beans.core.prefs
  12. +69 −0 SpringGrannyMVC/.settings/org.springframework.ide.eclipse.core.prefs
  13. +13 −0 SpringGrannyMVC/.springBeans
  14. +210 −0 SpringGrannyMVC/pom.xml
  15. +70 −0 SpringGrannyMVC/src/main/java/com/osintegrators/example/Address.java
  16. +13 −0 SpringGrannyMVC/src/main/java/com/osintegrators/example/AddressRepository.java
  17. +15 −0 SpringGrannyMVC/src/main/java/com/osintegrators/example/AddressService.java
  18. +33 −0 SpringGrannyMVC/src/main/java/com/osintegrators/example/AddressServiceImpl.java
  19. +94 −0 SpringGrannyMVC/src/main/java/com/osintegrators/example/HomeController.java
  20. +14 −0 SpringGrannyMVC/src/main/resources/META-INF/persistence.xml
  21. +43 −0 SpringGrannyMVC/src/main/resources/META-INF/spring/app-context.xml
  22. +41 −0 SpringGrannyMVC/src/main/resources/log4j.xml
  23. +28 −0 SpringGrannyMVC/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
  24. +8 −0 SpringGrannyMVC/src/main/webapp/WEB-INF/spring/root-context.xml
  25. +96 −0 SpringGrannyMVC/src/main/webapp/WEB-INF/views/home.jsp
  26. +33 −0 SpringGrannyMVC/src/main/webapp/WEB-INF/web.xml
  27. +65 −0 SpringGrannyMVC/src/main/webapp/resources/grannystyle.css
  28. +102 −0 SpringGrannyMVC/src/test/java/com/osintegrators/example/TestAddressService.java
  29. +8 −0 SpringGrannyMVC/src/test/resources/com/osintegrators/example/TestAddressService-context.xml
  30. +41 −0 SpringGrannyMVC/src/test/resources/log4j.xml
View
3 .gitignore
@@ -4,3 +4,6 @@
*.jar
*.war
*.ear
+
+.svn/
+target/
View
14 SpringGrannyMVC/.classpath
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
View
50 SpringGrannyMVC/.project
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>SpringGrannyMVC</name>
+ <comment></comment>
+ <projects>
+ <project>Servers</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.ajdt.core.ajbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.springframework.ide.eclipse.core.springbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.ajdt.ui.ajnature</nature>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ <nature>org.springframework.ide.eclipse.core.springnature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
View
2 SpringGrannyMVC/.settings/com.springsource.server.ide.jdt.core.xml
@@ -0,0 +1,2 @@
+<classpath>
+</classpath>
View
12 SpringGrannyMVC/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Tue Mar 17 10:00:21 EDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
View
3 SpringGrannyMVC/.settings/org.eclipse.jst.common.project.facet.core.prefs
@@ -0,0 +1,3 @@
+#Tue Mar 17 09:59:19 EDT 2009
+classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.launching.macosx.MacOSXType\:\:JVM\ 1.5.0\ (MacOS\ X\ Default)/owners=jst.java\:5.0
+eclipse.preferences.version=1
View
10 SpringGrannyMVC/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="SpringGrannyMVC">
+ <wb-resource deploy-path="/" source-path="/src/main/webapp"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
+ <property name="java-output-path" value="target/classes"/>
+ <property name="context-root" value="SpringGrannyMVC"/>
+ </wb-module>
+</project-modules>
View
7 SpringGrannyMVC/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="jst.web"/>
+ <fixed facet="jst.java"/>
+ <installed facet="jst.java" version="5.0"/>
+ <installed facet="jst.web" version="2.5"/>
+</faceted-project>
View
6 SpringGrannyMVC/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,6 @@
+#Fri Jun 06 17:00:12 BST 2008
+DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator\=org.eclipse.wst.wsdl.validation.internal.eclipse.Validator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator\=org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator;
+USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.jst.jsf.validation.internal.JSPSemanticsValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.wst.common.componentcore.internal.ModuleCoreValidator;org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidator;org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator;org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;
+USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.jst.jsf.validation.internal.JSPSemanticsValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.wst.common.componentcore.internal.ModuleCoreValidator;org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidator;org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator;org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;
+USER_PREFERENCE=overrideGlobalPreferencesfalse
+eclipse.preferences.version=1
View
9 SpringGrannyMVC/.settings/org.maven.ide.eclipse.prefs
@@ -0,0 +1,9 @@
+#Tue Mar 17 14:28:16 EDT 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
View
78 SpringGrannyMVC/.settings/org.springframework.ide.eclipse.beans.core.prefs
@@ -0,0 +1,78 @@
+#Mon Oct 18 12:37:52 EDT 2010
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.osgi.org/xmlns/blueprint/v1.0.0=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/aop=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/batch=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/beans=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/context=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/faces=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/flex=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/file=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/http=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/httpinvoker=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/ip=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/jdbc=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/jms=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/jmx=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/mail=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/rmi=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/security=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/stream=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/ws=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/integration/xml=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jdbc=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jee=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jms=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/lang=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/mvc=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/osgi=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/osgi-compendium=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/oxm=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/p=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/security=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/task=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/tx=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/util=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/web-services=
+//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/webflow-config=
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.osgi.org/xmlns/blueprint/v1.0.0=bp
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/aop=aop
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/batch=batch
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/beans=beans
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/context=context
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/faces=faces
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/flex=flex
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration=int
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/file=int-file
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/http=int-http
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/httpinvoker=int-httpinvoker
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/ip=int-ip
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/jdbc=int-jdbc
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/jms=int-jms
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/jmx=int-jmx
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/mail=int-mail
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/rmi=int-rmi
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/security=int-security
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/stream=int-stream
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/ws=int-ws
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/integration/xml=int-xml
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/jdbc=jdbc
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/jee=jee
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/jms=jms
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/lang=lang
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/mvc=mvc
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/osgi=osgi
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/osgi-compendium=osgix
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/oxm=oxm
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/p=p
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/security=sec
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/task=task
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/tx=tx
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/util=util
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/web-services=ws
+//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/webflow-config=flow
+eclipse.preferences.version=1
+org.springframework.ide.eclipse.beans.core.default.version.check.classpath=true
+org.springframework.ide.eclipse.beans.core.enable.project.preferences=false
+org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false
+org.springframework.ide.eclipse.beans.core.loadNamespaceHandlerFromClasspath=false
View
69 SpringGrannyMVC/.settings/org.springframework.ide.eclipse.core.prefs
@@ -0,0 +1,69 @@
+#Tue Apr 20 16:59:06 EDT 2010
+eclipse.preferences.version=1
+org.springframework.ide.eclipse.core.builders.enable.aopreferencemodelbuilder=true
+org.springframework.ide.eclipse.core.builders.enable.beanmetadatabuilder=true
+org.springframework.ide.eclipse.core.builders.enable.osgibundleupdater=false
+org.springframework.ide.eclipse.core.enable.project.preferences=false
+org.springframework.ide.eclipse.core.validator.enable.com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.enable.com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.enable.com.springsource.sts.server.quickfix.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.core.springvalidator=false
+org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.applicationSymbolicNameRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.applicationVersionRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleActivationPolicyRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleActivatorRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleManifestVersionRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleNameRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleSymbolicNameRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleVersionRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.exportPackageRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.importRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.parsingProblemsRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.requireBundleRule-com.springsource.server.ide.manifest.core.manifestvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.AvoidDriverManagerDataSource-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.ImportElementsAtTopRulee-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.ParentBeanSpecifiesAbstractClassRule-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.RefElementRule-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.TooManyBeansInFileRule-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.UnnecessaryValueElementRule-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.UseBeanInheritance-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.legacyxmlusage.jndiobjectfactory-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.server.quickfix.importBundleVersionRule-com.springsource.sts.server.quickfix.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.server.quickfix.importLibraryVersionRule-com.springsource.sts.server.quickfix.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.server.quickfix.importPackageVersionRule-com.springsource.sts.server.quickfix.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.server.quickfix.requireBundleVersionRule-com.springsource.sts.server.quickfix.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.autowire.autowire-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanAlias-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanClass-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanConstructorArgument-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinition-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinitionHolder-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanFactory-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanInitDestroyMethod-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanReference-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.methodOverride-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.parsingProblems-org.springframework.ide.eclipse.beans.core.beansvalidator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.requiredProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.toolAnnotation-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.core.springClasspath-org.springframework.ide.eclipse.core.springvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.action-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.actionstate-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attribute-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attributemapper-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.beanaction-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationaction-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationresult-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.exceptionhandler-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.import-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.inputattribute-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.mapping-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.outputattribute-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.set-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.state-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.subflowstate-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.transition-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.variable-org.springframework.ide.eclipse.webflow.core.validator=true
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.webflowstate-org.springframework.ide.eclipse.webflow.core.validator=true
View
13 SpringGrannyMVC/.springBeans
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+ <version>1</version>
+ <pluginVersion><![CDATA[2.5.0.201010141000-RC1]]></pluginVersion>
+ <configSuffixes>
+ <configSuffix><![CDATA[xml]]></configSuffix>
+ </configSuffixes>
+ <enableImports><![CDATA[true]]></enableImports>
+ <configs>
+ </configs>
+ <configSets>
+ </configSets>
+</beansProjectDescription>
View
210 SpringGrannyMVC/pom.xml
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.osintegrators</groupId>
+ <artifactId>example</artifactId>
+ <name>abc</name>
+ <packaging>war</packaging>
+ <version>1.0.0-BUILD-SNAPSHOT</version>
+ <properties>
+ <java-version>1.6</java-version>
+ <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
+ <org.springframework.data-version>1.0.3.RELEASE</org.springframework.data-version>
+ <org.hibernate.version>3.6.0.Final</org.hibernate.version>
+ <tomcat.jdbc.pool.version>1.0.9.3</tomcat.jdbc.pool.version>
+ <org.hsqldb-version>2.2.8</org.hsqldb-version>
+ <org.aspectj-version>1.6.9</org.aspectj-version>
+ <org.slf4j-version>1.5.10</org.slf4j-version>
+ </properties>
+ <repositories>
+ <repository>
+ <id>repository.springframework.maven.release</id>
+ <name>Spring Framework Maven Release Repository</name>
+ <url>http://maven.springframework.org/release</url>
+ </repository>
+ <repository>
+ <id>com.springsource.repository.bundles.external</id>
+ <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
+ <url>http://repository.springsource.com/maven/bundles/external</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <!-- Spring -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${org.springframework-version}</version>
+ <exclusions>
+ <!-- Exclude Commons Logging in favor of SLF4j -->
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${org.springframework-version}</version>
+ </dependency>
+
+ <!-- added by OSIL -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${org.springframework-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.data</groupId>
+ <artifactId>spring-data-jpa</artifactId>
+ <version>${org.springframework.data-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>${org.hibernate.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>com.springsource.org.apache.tomcat.jdbc</artifactId>
+ <version>${tomcat.jdbc.pool.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>${org.hsqldb-version}</version>
+ </dependency>
+
+ <!-- added by OSIL -->
+
+ <!-- AspectJ -->
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>${org.aspectj-version}</version>
+ </dependency>
+
+ <!-- Logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${org.slf4j-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${org.slf4j-version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${org.slf4j-version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.15</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jdmk</groupId>
+ <artifactId>jmxtools</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jmx</groupId>
+ <artifactId>jmxri</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- @Inject -->
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+
+ <!-- Servlet -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <!-- Test -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${java-version}</source>
+ <target>${java-version}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <warName>abc</warName>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>install</id>
+ <phase>install</phase>
+ <goals>
+ <goal>sources</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
View
70 SpringGrannyMVC/src/main/java/com/osintegrators/example/Address.java
@@ -0,0 +1,70 @@
+package com.osintegrators.example;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+
+@Entity
+@NamedQueries({@NamedQuery(name="Address.findAll",query="select a from Address a"),
+ @NamedQuery(name="Address.findByName",query="select a from Address a where a.name = ?1")})
+public class Address {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private Long id;
+
+
+ private String name;
+ private String email;
+ private String phone;
+ private String address;
+
+ public Address() {}
+
+ public Address(String name, String address, String phone, String email) {
+ this.name = name;
+ this.address=address;
+ this.phone=phone;
+ this.email=email;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setName(String name) {
+ this.name=name;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+}
View
13 SpringGrannyMVC/src/main/java/com/osintegrators/example/AddressRepository.java
@@ -0,0 +1,13 @@
+package com.osintegrators.example;
+
+import java.util.List;
+
+import org.springframework.data.repository.CrudRepository;
+
+
+public interface AddressRepository extends CrudRepository<Address, Long> {
+
+ List<Address> findAll();
+ Address findByName(String name);
+
+}
View
15 SpringGrannyMVC/src/main/java/com/osintegrators/example/AddressService.java
@@ -0,0 +1,15 @@
+package com.osintegrators.example;
+
+import java.util.List;
+
+public interface AddressService {
+
+ void createAddress(Address address);
+
+ Address getAddressByName(String expectedName);
+
+ void deleteAddress(Address result);
+
+ List<Address> getAllAddresses();
+
+}
View
33 SpringGrannyMVC/src/main/java/com/osintegrators/example/AddressServiceImpl.java
@@ -0,0 +1,33 @@
+package com.osintegrators.example;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AddressServiceImpl implements AddressService {
+
+ @Autowired
+ AddressRepository repository;
+
+
+ public void createAddress(Address address) {
+ repository.save(address);
+
+ }
+
+ public Address getAddressByName(String expectedName) {
+ Address address = repository.findByName(expectedName);
+ return address;
+ }
+
+ public void deleteAddress(Address address) {
+ repository.delete(address);
+ }
+
+ public List<Address> getAllAddresses() {
+ return repository.findAll();
+ }
+
+}
View
94 SpringGrannyMVC/src/main/java/com/osintegrators/example/HomeController.java
@@ -0,0 +1,94 @@
+package com.osintegrators.example;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * Handles requests for the application home page.
+ */
+@Controller
+public class HomeController {
+
+ private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
+
+ @Autowired
+ AddressService service;
+
+ /**
+ * Simply selects the home view to render by returning its name.
+ */
+ @RequestMapping(value = "/", method = RequestMethod.GET)
+ public String home(Model model) {
+ logger.debug("in home method");
+
+ addModelElements(model);
+ return "home";
+ }
+
+ @RequestMapping(value = "/get", method = RequestMethod.POST)
+ public String get(Model model, @RequestParam String oldName, @RequestParam String selectedIndex) {
+ logger.debug("in get method");
+
+ Address address = service.getAddressByName(oldName);
+
+ model.addAttribute("selectedIndex",selectedIndex);
+ model.addAttribute("address", address);
+ addModelElements(model);
+ return "home";
+ }
+
+
+ @RequestMapping(value = "/save", method = RequestMethod.POST)
+ public String save(Model model, @RequestParam String oldName, @RequestParam String name, @RequestParam String address, @RequestParam String phone, @RequestParam String email) {
+ logger.debug("in save method");
+
+ Address old = service.getAddressByName(oldName);
+
+ if (old != null) {
+ old.setName(name);
+ old.setAddress(address);
+ old.setPhone(phone);
+ old.setEmail(email);
+ }
+
+ logger.debug(old == null ? "old -= null" : "old != null");
+
+ Address add = old != null ? old : new Address(name, address, phone, email);
+ service.createAddress(add);
+
+ addModelElements(model);
+ model.addAttribute("status","created");
+
+ return "home";
+ }
+
+
+ @RequestMapping(value = "/delete", method = RequestMethod.POST)
+ public String delete(Model model, @RequestParam String name) {
+ logger.debug("in delete method");
+
+ Address add = service.getAddressByName(name);
+ service.deleteAddress(add);
+
+ addModelElements(model);
+
+ model.addAttribute("status","deleted");
+
+ return "home";
+ }
+
+ private void addModelElements(Model model) {
+ List<Address> addresses = service.getAllAddresses();
+ model.addAttribute("addresses", addresses);
+ }
+
+
+}
View
14 SpringGrannyMVC/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,14 @@
+<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="application" transaction-type="RESOURCE_LOCAL">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <properties>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hbm2ddl.auto" value="create-drop"/>
+ </properties>
+ </persistence-unit>
+</persistence>
View
43 SpringGrannyMVC/src/main/resources/META-INF/spring/app-context.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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"
+ 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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
+ http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
+ ">
+
+ <context:component-scan base-package="com.osintegrators.example" />
+
+ <!-- Directory to scan for repository classes -->
+ <jpa:repositories
+ base-package="com.osintegrators.example" />
+
+ <bean class="org.springframework.orm.jpa.JpaTransactionManager"
+ id="transactionManager">
+ <property name="entityManagerFactory"
+ ref="entityManagerFactory" />
+ <property name="jpaDialect">
+ <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
+ </property>
+ </bean>
+
+ <bean id="entityManagerFactory"
+ class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="dataSource" ref="dataSource" />
+ <property name="jpaVendorAdapter">
+ <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
+ <property name="generateDdl" value="true" />
+ <property name="database" value="HSQL" />
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close">
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:mem:granny" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+</beans>
View
41 SpringGrannyMVC/src/main/resources/log4j.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Application Loggers -->
+ <logger name="com.osintegrators.example">
+ <level value="info" />
+ </logger>
+
+ <!-- 3rdparty Loggers -->
+ <logger name="org.springframework.core">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.beans">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.context">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.web">
+ <level value="info" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="warn" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
View
28 SpringGrannyMVC/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/mvc"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
+ <beans:import resource="classpath:/META-INF/spring/app-context.xml"/>
+ <!-- Enables the Spring MVC @Controller programming model -->
+ <annotation-driven />
+
+ <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
+ <resources mapping="/resources/**" location="/resources/" />
+
+ <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
+ <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+ <beans:property name="prefix" value="/WEB-INF/views/" />
+ <beans:property name="suffix" value=".jsp" />
+ </beans:bean>
+
+ <context:component-scan base-package="com.osintegrators.example" />
+
+
+
+</beans:beans>
View
8 SpringGrannyMVC/src/main/webapp/WEB-INF/spring/root-context.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+ <!-- Root Context: defines shared resources visible to all other web components -->
+
+</beans>
View
96 SpringGrannyMVC/src/main/webapp/WEB-INF/views/home.jsp
@@ -0,0 +1,96 @@
+<%@page import="java.util.List"%>
+<%@page import="com.osintegrators.example.Address"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ page session="false" %>
+<html>
+<head>
+ <title>Granny's Addressbook</title>
+
+<link type="text/css" rel="stylesheet" href="resources/grannystyle.css">
+</head>
+<%
+ Address address = (Address) request.getAttribute("address");
+ String nameValue = address != null ? address.getName() : "";
+ String addressValue = address != null ? address.getAddress() : "";
+ String phoneValue = address != null ? address.getPhone() : "";
+ String emailValue = address != null ? address.getEmail() : "";
+ int selectedIndex = request.getAttribute("selectedIndex") != null ? Integer.parseInt((String)request.getAttribute("selectedIndex")) : -1;
+ List<Address> addressList = (List<Address>) request.getAttribute("addresses");
+%>
+<body>
+ <script type="text/javascript">
+ function granny_save() {
+ if (addressList.selectedIndex != -1) {
+ document.getElementById("oldNameField").value = addressList.options[addressList.selectedIndex].value;
+ document.getElementById("selectedIndexField").value=addressList.selectedIndex;
+ }
+ document.addressForm.action = 'save';
+ document.addressForm.submit();
+ }
+
+ function granny_delete() {
+ document.addressForm.action = 'delete';
+ document.addressForm.submit();
+ }
+
+ function granny_get() {
+ var addressList = document.getElementById("addressList");
+ document.getElementById("oldNameField").value = addressList.options[addressList.selectedIndex].value;
+ document.getElementById("selectedIndexField").value=addressList.selectedIndex;
+ document.addressForm.action = 'get';
+ document.addressForm.submit();
+ }
+ </script>
+<div id="outer">
+<div id="inner">
+<h2>
+ Granny's Addressbook
+</h2>
+
+
+
+<div id="content">
+ <form id="addressForm" name="addressForm" method="POST" action="">
+ <input id="selectedIndexField" name="selectedIndex" type="hidden" value=""/>
+ <input id="oldNameField" name="oldName" type="hidden" value=""/>
+ <div id="nameEntry">
+ <div id="nameLabel" class="label">Name</div><input id="nameField" name="name" type="text" value="<%=nameValue%>"/>
+ </div>
+ <div id="addressEntry">
+ <div id="addressLabel" class="label">Address</div><input id="addressField" name="address" type="text" value="<%=addressValue%>"/>
+ </div>
+ <div id="phoneEntry">
+ <div id="phoneLabel" class="label">Phone</div><input id="phoneField" name="phone" type="text" value="<%=phoneValue%>"/>
+ </div>
+ <div id="emailEntry">
+ <div id="emailLabel" class="label">Email</div><input id="emailField" name="email" type="text" value="<%=emailValue%>"/>
+ </div>
+ <div id="saveEntry">
+ <input id="saveButton" value="Save" onClick="granny_save()" type="button"/>
+ </div>
+ <div id="listEntry">
+ <div id="list">
+ <select size="10" id="addressList" name="addressList" onChange="granny_get()">
+ <option value=""/>
+ <%
+ for (int i = 0; i < addressList.size(); i++) {
+ Address addressOption = addressList.get(i);
+ System.out.println("selectedIndex "+selectedIndex+" selected index == i "+(i == selectedIndex-1)+" "+i);
+ %>
+ <option name="<%=addressOption.getName()%>" value="<%= addressOption.getName() %>" <%= i == selectedIndex-1 ? "selected" : ""%>><%=addressOption.getName()%></option>
+ <%
+ }
+ %>
+ </select>
+ </div>
+ </div>
+ <div id="deleteEntry">
+ <input id="deleteButton" value="Delete" onClick="granny_delete()" type="button"/>
+ </div>
+ </form>
+
+</div><!-- end content-->
+</div><!-- end inner -->
+</div><!-- end outer -->
+</body>
+</html>
View
33 SpringGrannyMVC/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/spring/root-context.xml</param-value>
+ </context-param>
+
+ <!-- Creates the Spring Container shared by all Servlets and Filters -->
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+
+ <!-- Processes application requests -->
+ <servlet>
+ <servlet-name>appServlet</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <init-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>appServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+</web-app>
View
65 SpringGrannyMVC/src/main/webapp/resources/grannystyle.css
@@ -0,0 +1,65 @@
+body {
+ font-family: Arial, Helvetica;
+ }
+#outer {
+ background-color:#aaa;
+ position:absolute;
+ top:0px;
+ left:0px;
+ height:100%;
+ width:100%;
+}
+
+#inner {
+ position:relative;
+ margin-left:auto;
+ margin-right:auto;
+ margin-top:10px;
+ width:800px;
+ height:500px;
+ background-color:#eee;
+ border:1px solid #666;
+ box-shadow: .1em .1em .2em #666;
+ padding-left:50px;
+ padding-right:50px;
+}
+#inner h2 {
+
+ text-align:center;
+}
+#nameEntry, #addressEntry, #phoneEntry, #emailEntry {
+ font-weight:bold;
+ position:relative;
+ left:50px;
+ margin-top:30px;
+}
+#nameField, #addressField, #phoneField, #emailField {
+ position:relative;
+ left:100px;
+ top:-20px;
+ width:300px;
+}
+#listEntry{
+ position:absolute;
+ right:50px;
+ top:90px;
+ width:300px;
+}
+#addressList {
+ background-color:white;
+ width:300px;
+ height:250px;
+}
+#saveEntry{
+ position:absolute;
+ bottom:50px;
+ left:300px;
+}
+#saveButton,#deleteButton{
+ width:100px;
+}
+#deleteEntry{
+ position:absolute;
+ bottom:50px;
+ right:50px;
+}
View
102 SpringGrannyMVC/src/test/java/com/osintegrators/example/TestAddressService.java
@@ -0,0 +1,102 @@
+/**
+ *
+ */
+package com.osintegrators.example;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author acoliver
+ *
+ */
+@ContextConfiguration
+@RunWith(SpringJUnit4ClassRunner.class)
+public class TestAddressService {
+ @Autowired
+ AddressService addressService;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testCreateAddress() {
+ String expectedName = "John Doe";
+ String expectedAddress = "345 West Main St\nDurham, NC";
+ String expectedPhone = "+1.919.321.0119";
+ String expectedEmail = "spam@osintegrators.com";
+ Address address = createAddressObject(expectedName, expectedAddress, expectedPhone,expectedEmail);
+ addressService.createAddress(address);
+ Address result = addressService.getAddressByName(expectedName);
+
+ assertEquals(expectedName, result.getName());
+ assertEquals(expectedAddress,result.getAddress());
+ assertEquals(expectedPhone,result.getPhone());
+ assertEquals(expectedEmail,result.getEmail()); }
+
+ @Test
+ public void testGetAllAddresses() {
+ String[] expectedName = {"John Doe","Sarah Palin", "John Edwards", "Joe Lieberman", "Jack Kemp", "Dan Quayle"};
+ String[] expectedAddress = {"345 West Main St\nDurham, NC","Overlooking Russia\nJuneau","123 not at my house\nRaleigh, NC", "321 Not at my Party,\nHartford, CT", "545 Soccer is for Socialists,\nNY, NY", "62 You Say Tomato, I say Tomatoe,\nIndianapolis, IN"};
+ String[] expectedPhone = {"+1.919.321.0119","999-9999", "199-9999", "991-9999", "999-9998", "113-1548"};
+ String[] expectedEmail = {"spam@osintegrators.com","sarah@gop.org", "john@nowhere.com", "joe@nowhere.com", "jack@gop.org", "dan@gop.org"};
+
+ for(int i = 1; i < expectedName.length; i++) { //ignore john doe for create
+ Address address = createAddressObject(expectedName[i], expectedAddress[i], expectedPhone[i],expectedEmail[i]);
+ addressService.createAddress(address);
+ }
+
+ List<Address> addresses = addressService.getAllAddresses();
+
+ for(int i = 0; i < addresses.size(); i++) {
+ Address address = addressService.getAddressByName(expectedName[i]);
+ assertEquals(expectedName[i], address.getName());
+ assertEquals(expectedAddress[i],address.getAddress());
+ assertEquals(expectedPhone[i],address.getPhone());
+ assertEquals(expectedEmail[i],address.getEmail());
+ }
+ assertEquals("there should be equal number of addresses as there are expectedName array entries", expectedName.length,addresses.size());
+ }
+
+ @Test
+ public void testDeleteAddress() {
+ String expectedName = "Lloyd Bentsen";
+ String expectedAddress = "123 Mission way\nHidalgo, TX";
+ String expectedPhone = "+1.999.999.9999";
+ String expectedEmail = "lloyd@dnc.org";
+ Address address = createAddressObject(expectedName, expectedAddress, expectedPhone,expectedEmail);
+ addressService.createAddress(address);
+ Address result = addressService.getAddressByName(expectedName);
+ addressService.deleteAddress(result);
+ result = addressService.getAddressByName(expectedName);
+ assertNull("there should be no Lloyd Bentsen after the delete", result);
+
+ }
+
+ private Address createAddressObject(String name, String address,
+ String phone, String email) {
+ Address entity = new Address(name,address,phone,email);
+ return entity;
+ }
+
+}
View
8 SpringGrannyMVC/src/test/resources/com/osintegrators/example/TestAddressService-context.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <import resource="classpath:/META-INF/spring/app-context.xml"/>
+
+</beans>
View
41 SpringGrannyMVC/src/test/resources/log4j.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Application Loggers -->
+ <logger name="com.osintegrators.example">
+ <level value="info" />
+ </logger>
+
+ <!-- 3rdparty Loggers -->
+ <logger name="org.springframework.core">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.beans">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.context">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.web">
+ <level value="info" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>

0 comments on commit 91932fd

Please sign in to comment.