Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Big update with new code, tests, abstractions.

  • Loading branch information...
commit 7ec2d56b4a8681d72897adb033888b73432f341d 1 parent cff171a
@jbrisbin jbrisbin authored
Showing with 1,119 additions and 30 deletions.
  1. +3 −4 build.gradle
  2. +17 −0 exporter-core/build.gradle
  3. +239 −0 exporter-core/exporter-core.iml
  4. +39 −0 exporter-core/src/main/java/org/springframework/data/services/BeanPropertyResolver.java
  5. +48 −0 exporter-core/src/main/java/org/springframework/data/services/DelegatingResolver.java
  6. +14 −0 exporter-core/src/main/java/org/springframework/data/services/Link.java
  7. +26 −0 exporter-core/src/main/java/org/springframework/data/services/ListResolver.java
  8. +19 −0 exporter-core/src/main/java/org/springframework/data/services/MapResolver.java
  9. +14 −0 exporter-core/src/main/java/org/springframework/data/services/Resolver.java
  10. +14 −0 exporter-core/src/main/java/org/springframework/data/services/Resource.java
  11. +10 −0 exporter-core/src/main/java/org/springframework/data/services/ResourceExporter.java
  12. +19 −0 exporter-core/src/main/java/org/springframework/data/services/ResourceOperations.java
  13. +25 −0 exporter-core/src/main/java/org/springframework/data/services/SimpleResource.java
  14. +47 −0 exporter-core/src/main/java/org/springframework/data/services/context/ApplicationContextResolver.java
  15. +78 −0 exporter-core/src/main/java/org/springframework/data/services/repository/JpaRepositoryEntityResolver.java
  16. +110 −0 exporter-core/src/main/java/org/springframework/data/services/repository/JpaRepositoryMetadata.java
  17. +96 −0 exporter-core/src/main/java/org/springframework/data/services/util/UriUtils.java
  18. +59 −0 exporter-core/src/test/groovy/org/springframework/data/services/ResolverSpec.groovy
  19. +48 −0 exporter-core/src/test/groovy/org/springframework/data/services/UriUtilsSpec.groovy
  20. +74 −0 ...er-core/src/test/groovy/org/springframework/data/services/repository/JpaRepositoryEntityResolverSpec.groovy
  21. +9 −0 exporter-core/src/test/java/org/springframework/data/services/repository/SimpleEntityRepository.java
  22. +40 −0 exporter-core/src/test/resources/JpaRepositoryEntityResolver-test.xml
  23. +14 −0 exporter-core/src/test/resources/META-INF/persistence.xml
  24. +10 −0 exporter-core/src/test/resources/Resolver-test.xml
  25. +1 −0  exporter-web/exporter-web.iml
  26. +26 −0 exporter-web/src/main/java/org/springframework/data/services/web/JsonView.java
  27. +2 −25 exporter-web/src/main/webapp/WEB-INF/exporter-servlet.xml
  28. +9 −0 exporter-web/src/test/groovy/org/springframework/data/services/web/WebResourceSpec.groovy
  29. +1 −0  gradle.properties
  30. +8 −1 spring-data-services.ipr
View
7 build.gradle
@@ -1,7 +1,6 @@
apply plugin: "base"
allprojects {
- apply plugin: "groovy"
apply plugin: "idea"
group = "org.springframework.data.services"
@@ -19,9 +18,6 @@ allprojects {
exclude module: "groovy-all", version: "1.8.0-beta-3-SNAPSHOT"
}
- dependencies {
- groovy "org.codehaus.groovy:groovy:$groovyVersion"
- }
}
subprojects {
@@ -37,10 +33,12 @@ subprojects {
}
apply plugin: "java"
+ apply plugin: "groovy"
[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:-serial", "-Xlint:-unchecked"]
dependencies {
+ groovy "org.codehaus.groovy:groovy:$groovyVersion"
// Logging
compile "org.slf4j:slf4j-api:$slf4jVersion"
@@ -64,6 +62,7 @@ subprojects {
testCompile "org.hamcrest:hamcrest-all:1.1"
testCompile "org.springframework:spring-test:$springVersion"
testRuntime "org.springframework:spring-context-support:$springVersion"
+
}
}
View
17 exporter-core/build.gradle
@@ -1,7 +1,24 @@
dependencies {
+ // Google Guava
+ compile "com.google.guava:guava:10.0.1"
+
// Spring
+ compile "org.springframework:spring-orm:$springVersion"
compile "org.springframework:spring-oxm:$springVersion"
compile "org.springframework:spring-tx:$springVersion"
+ // JPA
+ compile "org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final"
+
+ // Spring Data
+ compile "org.springframework.data:spring-data-commons-core:$sdCommonsVersion"
+ compile "org.springframework.data:spring-data-jpa:$sdJpaVersion"
+ compile "org.springframework.data:spring-data-mongodb:$sdMongoVersion"
+
+ // Testing
+ testCompile "org.hibernate:hibernate-entitymanager:$hibernateVersion"
+ testCompile "org.hsqldb:hsqldb:1.8.0.10"
+ testRuntime "org.mongodb:mongo-java-driver:$mongoDriverVersion"
+
}
View
239 exporter-core/exporter-core.iml
@@ -8,6 +8,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/groovy" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
@@ -93,6 +94,17 @@
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/com.google.guava/guava/10.0.1/jar/292c96f9cb18231528cac4b0bf17d28149d14809/guava-10.0.1.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/com.google.guava/guava/10.0.1/source/50c3953eaac12b8067111030ffdb8e44f80f5a79/guava-10.0.1-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework/spring-oxm/3.1.0.RELEASE/jar/c8f8e7429596094008d0c395020e157d4e8ca432/spring-oxm-3.1.0.RELEASE.jar!/" />
</CLASSES>
<JAVADOC />
@@ -115,6 +127,50 @@
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hibernate.javax.persistence/hibernate-jpa-2.0-api/1.0.1.Final/jar/3306a165afa81938fc3d8a0948e891de9f6b192b/hibernate-jpa-2.0-api-1.0.1.Final.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hibernate.javax.persistence/hibernate-jpa-2.0-api/1.0.1.Final/source/574f65373b46a038332eb1a14acc3142bd9e9810/hibernate-jpa-2.0-api-1.0.1.Final-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework.data/spring-data-commons-core/1.2.0.RELEASE/jar/dbc606a35154cdca44fdfe84668dcf0a77fb88f1/spring-data-commons-core-1.2.0.RELEASE.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework.data/spring-data-commons-core/1.2.0.RELEASE/source/5d5b7179a8d6a11b0817001108ef4f7a9cf5db8a/spring-data-commons-core-1.2.0.RELEASE-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework.data/spring-data-jpa/1.0.1.RELEASE/jar/6ef96e39ca5a58df359c03e450dc2264c5eb53ad/spring-data-jpa-1.0.1.RELEASE.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework.data/spring-data-jpa/1.0.1.RELEASE/source/cc07eb9e907691190cbf85fb904b2507f81ad1a7/spring-data-jpa-1.0.1.RELEASE-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework.data/spring-data-mongodb/1.0.0.M5/jar/b92a06ccc48386c0eb1adffd447164af5ab64e81/spring-data-mongodb-1.0.0.M5.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework.data/spring-data-mongodb/1.0.0.M5/source/ed9b68c1cbd2aed287cebe9cb8f30afa9a02158/spring-data-mongodb-1.0.0.M5-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.codehaus.groovy/groovy/1.8.4/jar/344c49f07cf37471935d5103b6cbe7c5aaa09445/groovy-1.8.4.jar!/" />
</CLASSES>
<JAVADOC />
@@ -203,6 +259,15 @@
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/com.google.code.findbugs/jsr305/1.3.9/jar/40719ea6961c0cb6afaeb6a921eaa1f6afd4cfdf/jsr305-1.3.9.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/commons-lang/commons-lang/2.5/jar/b0236b252e86419eef20c31a44579d2aee2f0a69/commons-lang-2.5.jar!/" />
</CLASSES>
<JAVADOC />
@@ -214,6 +279,50 @@
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework/spring-jdbc/3.0.5.RELEASE/jar/2af0bad1d8d681ed2e014b684287acc448ab30cb/spring-jdbc-3.0.5.RELEASE.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework/spring-jdbc/3.0.5.RELEASE/source/c8ac8ff6f389f6d249f51ed0a266fd811537af9f/spring-jdbc-3.0.5.RELEASE-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework/spring-orm/3.0.5.RELEASE/jar/cff2c955d1a510bab6e1eb2d1ced309f6ec37ce9/spring-orm-3.0.5.RELEASE.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework/spring-orm/3.0.5.RELEASE/source/7514e501c926fc793fb0214c7d4567021091e77d/spring-orm-3.0.5.RELEASE-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.slf4j/jcl-over-slf4j/1.6.1/jar/99c61095a14dfc9e47a086068033c286bf236475/jcl-over-slf4j-1.6.1.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.slf4j/jcl-over-slf4j/1.6.1/source/dbc80dfd897e3bc528199ff97e29e44a0ac4b462/jcl-over-slf4j-1.6.1-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.aspectj/aspectjrt/1.6.8/jar/8c234df6a43dd5ba355803122e33caa7ccd11011/aspectjrt-1.6.8.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.aspectj/aspectjrt/1.6.8/source/2e399f32ac7388ecbb042017df2ff1bc1ca8c16/aspectjrt-1.6.8-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/antlr/antlr/2.7.7/jar/83cd2cd674a217ade95a4bb83a8a14f351f48bd0/antlr-2.7.7.jar!/" />
</CLASSES>
<JAVADOC />
@@ -334,6 +443,26 @@
<orderEntry type="module-library" scope="TEST">
<library>
<CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hibernate/hibernate-entitymanager/3.5.6-Final/jar/f0d8ef059798a9fe8f84532e6aed27f9a25934f4/hibernate-entitymanager-3.5.6-Final.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hibernate/hibernate-entitymanager/3.5.6-Final/source/7dcc6a85b33456f480b9713d161d78f86c31d52e/hibernate-entitymanager-3.5.6-Final-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hsqldb/hsqldb/1.8.0.10/jar/7e9978fdb754bce5fcd5161133e7734ecb683036/hsqldb-1.8.0.10.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework/spring-context-support/3.1.0.RELEASE/jar/379bb71a6eb9f1a965cd7d6d94524deab2a3da07/spring-context-support-3.1.0.RELEASE.jar!/" />
</CLASSES>
<JAVADOC />
@@ -345,6 +474,17 @@
<orderEntry type="module-library" scope="TEST">
<library>
<CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.mongodb/mongo-java-driver/2.6.5/jar/e33bb494ca9023cbce92f230b5fb4ee9c478e5fe/mongo-java-driver-2.6.5.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.mongodb/mongo-java-driver/2.6.5/source/f752cf1dfa68e102b6433d452d18eb3cfe06d9a3/mongo-java-driver-2.6.5-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hamcrest/hamcrest-core/1.2/jar/44d12ff84e43c7d0539131f75c92f2f88dba6549/hamcrest-core-1.2.jar!/" />
</CLASSES>
<JAVADOC />
@@ -364,6 +504,105 @@
</SOURCES>
</library>
</orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/commons-collections/commons-collections/3.1/jar/40fb048097caeacdb11dbb33b5755854d89efdeb/commons-collections-3.1.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/commons-collections/commons-collections/3.1/source/a48ca211fd2a564425c2cb9b90cb0f9158cfce52/commons-collections-3.1-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/xml-apis/xml-apis/1.0.b2/jar/3136ca936f64c9d68529f048c2618bd356bf85c9/xml-apis-1.0.b2.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/xml-apis/xml-apis/1.0.b2/source/d8525661c5a0a05702fa41873d250d135031ec25/xml-apis-1.0.b2-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/dom4j/dom4j/1.6.1/jar/5d3ccc056b6f056dbf0dddfdf43894b9065a8f94/dom4j-1.6.1.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/dom4j/dom4j/1.6.1/source/a8e7149359255f43e0e5e3b1837948f9ed5861fb/dom4j-1.6.1-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/javax.transaction/jta/1.1/jar/2ca09f0b36ca7d71b762e14ea2ff09d5eac57558/jta-1.1.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/javax.transaction/jta/1.1/source/d5dad66d06246bd2e1e369cebff27faa9beb065a/jta-1.1-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hibernate/hibernate-core/3.5.6-Final/jar/2fbc11d2892b5d80c67b69ec2ef9ca31b0e71080/hibernate-core-3.5.6-Final.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hibernate/hibernate-core/3.5.6-Final/source/f2c55868786673d18db29e8561390174fb2d1a70/hibernate-core-3.5.6-Final-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hibernate/hibernate-commons-annotations/3.2.0.Final/jar/ce990611448fc2865469e3b68d2fe76b050e3c4f/hibernate-commons-annotations-3.2.0.Final.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hibernate/hibernate-commons-annotations/3.2.0.Final/source/6afdc971f4d4dbe7650dbc5ea4a67101779ca001/hibernate-commons-annotations-3.2.0.Final-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hibernate/hibernate-annotations/3.5.6-Final/jar/a07cb36d5485927f925f941ab6dd61f8ffb4b935/hibernate-annotations-3.5.6-Final.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.hibernate/hibernate-annotations/3.5.6-Final/source/a85990aa646fa4e97796be89a7e1d36430036b9b/hibernate-annotations-3.5.6-Final-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/cglib/cglib/2.2/jar/97d03461dc1c04ffc636dcb2579aae7724a78ef2/cglib-2.2.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/cglib/cglib/2.2/source/962f2bbd66901a9d67b0bb3c8c4a64ce6de0a8c4/cglib-2.2-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/javassist/javassist/3.9.0.GA/jar/832df7a8f329ff1285a11576046847a38b749d45/javassist-3.9.0.GA.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.gradle/caches/artifacts-8/filestore/javassist/javassist/3.9.0.GA/source/32539a80ce6e71fa150dcd7c76586fb1ae11cfa7/javassist-3.9.0.GA-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
</component>
</module>
View
39 exporter-core/src/main/java/org/springframework/data/services/BeanPropertyResolver.java
@@ -0,0 +1,39 @@
+package org.springframework.data.services;
+
+import java.lang.reflect.Field;
+import java.net.URI;
+
+import org.springframework.core.convert.support.ConfigurableConversionService;
+import org.springframework.util.ReflectionUtils;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public class BeanPropertyResolver implements Resolver {
+
+ protected ConfigurableConversionService conversionService;
+
+ public BeanPropertyResolver(ConfigurableConversionService conversionService) {
+ this.conversionService = conversionService;
+ }
+
+ @Override public boolean supports(URI uri, Object target) {
+ return (null != uri.getFragment() && null != target);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Override public Object resolve(URI uri, Object target) {
+ String name = uri.getFragment();
+ if (null != name) {
+ Field field = ReflectionUtils.findField(target.getClass(), name);
+ ReflectionUtils.makeAccessible(field);
+ try {
+ return field.get(target);
+ } catch (IllegalAccessException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return null;
+ }
+
+}
View
48 exporter-core/src/main/java/org/springframework/data/services/DelegatingResolver.java
@@ -0,0 +1,48 @@
+package org.springframework.data.services;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public class DelegatingResolver implements Resolver {
+
+ private List<Resolver> resolvers = new ArrayList<Resolver>();
+
+ public DelegatingResolver() {
+ }
+
+ public DelegatingResolver(List<Resolver> resolvers) {
+ this.resolvers = resolvers;
+ }
+
+ public List<Resolver> resolvers() {
+ return resolvers;
+ }
+
+ public DelegatingResolver resolvers(List<Resolver> resolvers) {
+ this.resolvers = resolvers;
+ return this;
+ }
+
+ @Override public boolean supports(URI uri, Object target) {
+ for (Resolver r : resolvers) {
+ if (r.supports(uri, target)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override public Object resolve(URI uri, Object target) {
+ for (Resolver r : resolvers) {
+ if (r.supports(uri, target)) {
+ return r.resolve(uri, target);
+ }
+ }
+ return null;
+ }
+
+}
View
14 exporter-core/src/main/java/org/springframework/data/services/Link.java
@@ -0,0 +1,14 @@
+package org.springframework.data.services;
+
+import java.net.URI;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public interface Link {
+
+ String type();
+
+ URI uri();
+
+}
View
26 exporter-core/src/main/java/org/springframework/data/services/ListResolver.java
@@ -0,0 +1,26 @@
+package org.springframework.data.services;
+
+import java.net.URI;
+import java.util.List;
+
+import org.springframework.data.services.util.UriUtils;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public class ListResolver implements Resolver<List> {
+
+ @Override public boolean supports(URI uri, Object target) {
+ return (null != uri.getFragment() && target instanceof List);
+ }
+
+ @Override public Object resolve(URI uri, List target) {
+ int i = UriUtils.fragmentToInt(uri);
+ if (i > -1) {
+ return target.get(i);
+ } else {
+ return null;
+ }
+ }
+
+}
View
19 exporter-core/src/main/java/org/springframework/data/services/MapResolver.java
@@ -0,0 +1,19 @@
+package org.springframework.data.services;
+
+import java.net.URI;
+import java.util.Map;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public class MapResolver implements Resolver<Map> {
+
+ @Override public boolean supports(URI uri, Object target) {
+ return (null != uri.getFragment() && target instanceof Map);
+ }
+
+ @Override public Object resolve(URI uri, Map target) {
+ return target.get(uri.getFragment());
+ }
+
+}
View
14 exporter-core/src/main/java/org/springframework/data/services/Resolver.java
@@ -0,0 +1,14 @@
+package org.springframework.data.services;
+
+import java.net.URI;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public interface Resolver<T> {
+
+ boolean supports(URI uri, Object target);
+
+ Object resolve(URI uri, T target);
+
+}
View
14 exporter-core/src/main/java/org/springframework/data/services/Resource.java
@@ -0,0 +1,14 @@
+package org.springframework.data.services;
+
+import java.net.URI;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public interface Resource<T> {
+
+ URI uri();
+
+ T target();
+
+}
View
10 exporter-core/src/main/java/org/springframework/data/services/ResourceExporter.java
@@ -0,0 +1,10 @@
+package org.springframework.data.services;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public interface ResourceExporter extends Resource {
+
+ ResourceOperations operations(Resource resource);
+
+}
View
19 exporter-core/src/main/java/org/springframework/data/services/ResourceOperations.java
@@ -0,0 +1,19 @@
+package org.springframework.data.services;
+
+import java.net.URI;
+import java.util.Map;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public interface ResourceOperations {
+
+ Resource create(Resource resource, Map<String, Object> model);
+
+ Resource retrieve(URI uri);
+
+ Resource update(Resource resource, Map<String, Object> model);
+
+ Resource delete(URI uri);
+
+}
View
25 exporter-core/src/main/java/org/springframework/data/services/SimpleResource.java
@@ -0,0 +1,25 @@
+package org.springframework.data.services;
+
+import java.net.URI;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public class SimpleResource implements Resource {
+
+ private URI uri;
+ private Object entity;
+
+ private SimpleResource(URI uri, Object entity) {
+ this.uri = uri;
+ this.entity = entity;
+ }
+
+ @Override public URI uri() {
+ return uri;
+ }
+
+ @Override public Object target() {
+ return entity;
+ }
+}
View
47 exporter-core/src/main/java/org/springframework/data/services/context/ApplicationContextResolver.java
@@ -0,0 +1,47 @@
+package org.springframework.data.services.context;
+
+import java.net.URI;
+import java.util.List;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.data.services.Resolver;
+import org.springframework.data.services.util.UriUtils;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public class ApplicationContextResolver implements Resolver<Class<?>>, ApplicationContextAware {
+
+ private ApplicationContext applicationContext;
+ private URI baseUri;
+
+ public ApplicationContextResolver(URI baseUri) {
+ this.baseUri = baseUri;
+ }
+
+ @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
+
+ @Override public boolean supports(URI uri, Object target) {
+ if (null == target) {
+ return false;
+ }
+
+ if (uri.isAbsolute()) {
+ List<URI> uris = UriUtils.explode(baseUri, uri);
+ if (uris.size() > 0) {
+ uri = uris.get(uris.size() - 1);
+ }
+ }
+
+ return (null != uri.getPath() && target instanceof Class);
+ }
+
+ @Override public Object resolve(URI uri, Class<?> target) {
+ return applicationContext.getBean(uri.getPath(), target);
+ }
+
+}
View
78 exporter-core/src/main/java/org/springframework/data/services/repository/JpaRepositoryEntityResolver.java
@@ -0,0 +1,78 @@
+package org.springframework.data.services.repository;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.core.EntityInformation;
+import org.springframework.data.services.Resolver;
+import org.springframework.data.services.util.UriUtils;
+import org.springframework.util.ClassUtils;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public class JpaRepositoryEntityResolver implements Resolver<CrudRepository> {
+
+ @Autowired
+ private JpaRepositoryMetadata repositoryMetadata;
+ @Autowired
+ private ConversionService conversionService;
+ private URI baseUri;
+
+ public JpaRepositoryEntityResolver(URI baseUri) {
+ this.baseUri = baseUri;
+ }
+
+ public JpaRepositoryEntityResolver(URI baseUri, ConversionService conversionService) {
+ this.baseUri = baseUri;
+ this.conversionService = conversionService;
+ }
+
+ public JpaRepositoryEntityResolver(URI baseUri, JpaRepositoryMetadata repositoryMetadata, ConversionService conversionService) {
+ this.baseUri = baseUri;
+ this.repositoryMetadata = repositoryMetadata;
+ this.conversionService = conversionService;
+ }
+
+ @Override public boolean supports(URI uri, Object target) {
+ if (null == target) {
+ return false;
+ }
+ if (uri.isAbsolute() && target instanceof CrudRepository) {
+ CrudRepository repository = (CrudRepository) target;
+ List<URI> uris = UriUtils.explode(baseUri, uri);
+ if (uris.size() > 1) {
+ URI repoUri = uris.get(uris.size() - 2);
+ return repoUri.getPath().equals(repositoryMetadata.repositoryNameFor(repository));
+ }
+ }
+ if (target instanceof CrudRepository) {
+ return (null != repositoryMetadata.entityInfoFor((CrudRepository) target));
+ } else {
+ return false;
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Override public Object resolve(URI uri, CrudRepository repository) {
+ EntityInformation entityInfo = repositoryMetadata.entityInfoFor(repository);
+ if (uri.isAbsolute()) {
+ List<URI> uris = UriUtils.explode(baseUri, uri);
+ if (uris.size() > 1) {
+ uri = uris.get(uris.size() - 1);
+ }
+ }
+ String sid = uri.getPath();
+ Class<? extends Serializable> idType = entityInfo.getIdType();
+ return repository.findOne(
+ !ClassUtils.isAssignable(idType, String.class)
+ ? conversionService.convert(sid, idType)
+ : sid
+ );
+ }
+
+}
View
110 exporter-core/src/main/java/org/springframework/data/services/repository/JpaRepositoryMetadata.java
@@ -0,0 +1,110 @@
+package org.springframework.data.services.repository;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.aop.support.AopUtils;
+import org.springframework.aop.target.SingletonTargetSource;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.core.EntityInformation;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.util.StringUtils;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public class JpaRepositoryMetadata implements InitializingBean, ApplicationContextAware {
+
+ private ApplicationContext applicationContext;
+ private Map<Class<?>, RepositoryCacheEntry> repositories = new HashMap<Class<?>, RepositoryCacheEntry>();
+
+ public CrudRepository repositoryFor(Class<?> domainClass) {
+ RepositoryCacheEntry entry = repositories.get(domainClass);
+ if (null != entry) {
+ return entry.repository;
+ }
+ return null;
+ }
+
+ public EntityInformation entityInfoFor(Class<?> domainClass) {
+ RepositoryCacheEntry entry = repositories.get(domainClass);
+ if (null != entry) {
+ return entry.entityInfo;
+ }
+ return null;
+ }
+
+ public EntityInformation entityInfoFor(CrudRepository repository) {
+ for (Map.Entry<Class<?>, RepositoryCacheEntry> entry : repositories.entrySet()) {
+ if (entry.getValue().repository == repository) {
+ return entry.getValue().entityInfo;
+ }
+ }
+ return null;
+ }
+
+ public String repositoryNameFor(Class<?> domainClass) {
+ RepositoryCacheEntry entry = repositories.get(domainClass);
+ if (null != entry) {
+ return entry.name;
+ }
+ return null;
+ }
+
+ public String repositoryNameFor(CrudRepository repository) {
+ for (Map.Entry<Class<?>, RepositoryCacheEntry> entry : repositories.entrySet()) {
+ if (entry.getValue().repository == repository) {
+ return entry.getValue().name;
+ }
+ }
+ return null;
+ }
+
+ @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
+
+ public void setRepositories(Collection<CrudRepository> repositories) {
+ for (CrudRepository repository : repositories) {
+ Class<?> repoClass = AopUtils.getTargetClass(repository);
+ Field infoField = ReflectionUtils.findField(repoClass, "entityInformation");
+ ReflectionUtils.makeAccessible(infoField);
+ Method m = ReflectionUtils.findMethod(repository.getClass(), "getTargetSource");
+ ReflectionUtils.makeAccessible(m);
+ try {
+ SingletonTargetSource targetRepo = (SingletonTargetSource) m.invoke(repository);
+ EntityInformation entityInfo = (EntityInformation) infoField.get(targetRepo.getTarget());
+ String name = StringUtils.uncapitalize(repoClass.getSimpleName().replaceAll("Repository", ""));
+ this.repositories.put(entityInfo.getJavaType(), new RepositoryCacheEntry(name, repository, entityInfo));
+ } catch (Throwable t) {
+ throw new IllegalStateException(t);
+ }
+ }
+ }
+
+ @Override public void afterPropertiesSet() throws Exception {
+ if (this.repositories.isEmpty()) {
+ setRepositories(applicationContext.getBeansOfType(CrudRepository.class).values());
+ }
+ }
+
+ private class RepositoryCacheEntry {
+ String name;
+ CrudRepository repository;
+ EntityInformation entityInfo;
+
+ private RepositoryCacheEntry(String name, CrudRepository repository, EntityInformation entityInfo) {
+ this.name = name;
+ this.repository = repository;
+ this.entityInfo = entityInfo;
+ }
+ }
+
+}
View
96 exporter-core/src/main/java/org/springframework/data/services/util/UriUtils.java
@@ -0,0 +1,96 @@
+package org.springframework.data.services.util;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.util.StringUtils;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public abstract class UriUtils {
+
+ public static List<URI> explode(URI baseUri, URI uri) {
+ List<URI> uris = new ArrayList<URI>();
+ URI relativeUri = baseUri.relativize(uri);
+ try {
+ for (String part : relativeUri.getPath().split("/")) {
+ uris.add(new URI(part));
+ }
+ if (StringUtils.hasText(relativeUri.getFragment())) {
+ uris.add(new URI("#" + relativeUri.getFragment()));
+ }
+ } catch (URISyntaxException e) {
+ throw new IllegalStateException(e);
+ }
+ return uris;
+ }
+
+ public static URI merge(URI baseUri, URI... uris) {
+ StringBuilder query = new StringBuilder();
+
+ UriComponentsBuilder ub = UriComponentsBuilder.fromUri(baseUri);
+ for (URI uri : uris) {
+ String s = uri.getScheme();
+ if (null != s) {
+ ub.scheme(s);
+ }
+
+ s = uri.getUserInfo();
+ if (null != s) {
+ ub.userInfo(s);
+ }
+
+ s = uri.getHost();
+ if (null != s) {
+ ub.host(s);
+ }
+
+ int i = uri.getPort();
+ if (i > 0) {
+ ub.port(i);
+ }
+
+ s = uri.getPath();
+ if (null != s) {
+ if (!uri.isAbsolute() && StringUtils.hasText(s)) {
+ ub.pathSegment(s);
+ } else {
+ ub.path(s);
+ }
+ }
+
+ s = uri.getQuery();
+ if (null != s) {
+ if (query.length() > 0) {
+ query.append("&");
+ }
+ query.append(s);
+ }
+
+ s = uri.getFragment();
+ if (null != s) {
+ ub.fragment(s);
+ }
+ }
+
+ if (query.length() > 0) {
+ ub.query(query.toString());
+ }
+
+ return ub.build().toUri();
+ }
+
+ public static int fragmentToInt(URI uri) {
+ String s = uri.getFragment();
+ if (null != s) {
+ return Integer.parseInt(s);
+ } else {
+ return -1;
+ }
+ }
+
+}
View
59 exporter-core/src/test/groovy/org/springframework/data/services/ResolverSpec.groovy
@@ -0,0 +1,59 @@
+package org.springframework.data.services
+
+import org.springframework.context.support.ClassPathXmlApplicationContext
+import org.springframework.data.services.context.ApplicationContextResolver
+import spock.lang.Specification
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+class ResolverSpec extends Specification {
+
+ def "resolves simple properties based on the fragment"() {
+
+ given:
+ def resolver = new DelegatingResolver()
+ resolver.resolvers().add(new ListResolver())
+ resolver.resolvers().add(new MapResolver())
+ resolver.resolvers().add(new BeanPropertyResolver())
+ def list = ["first", "second", "third"]
+ def map = ["first": "first", "second": "second", "third": "third"]
+ def bean = new SimpleBean("third")
+
+ when:
+ def first = resolver.resolve(new URI("#0"), list)
+ def second = resolver.resolve(new URI("#second"), map)
+ def name = resolver.resolve(new URI("#name"), bean)
+
+ then:
+ first == "first"
+ second == "second"
+ name == "third"
+
+ }
+
+ def "resolves beans from the ApplicationContext"() {
+
+ given:
+ def baseUri = new URI("http://localhost:8080/data")
+ def appCtx = new ClassPathXmlApplicationContext("Resolver-test.xml")
+ def resolver = new ApplicationContextResolver(baseUri)
+ resolver.setApplicationContext(appCtx)
+
+ when:
+ SimpleBean bean = resolver.resolve(new URI("simpleBean"), SimpleBean)
+
+ then:
+ bean.name == "John Doe"
+
+ }
+
+}
+
+class SimpleBean {
+ String name
+
+ SimpleBean(String name) {
+ this.name = name
+ }
+}
View
48 exporter-core/src/test/groovy/org/springframework/data/services/UriUtilsSpec.groovy
@@ -0,0 +1,48 @@
+package org.springframework.data.services
+
+import org.springframework.data.services.util.UriUtils
+import spock.lang.Specification
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+class UriUtilsSpec extends Specification {
+
+ def "merges URIs correctly"() {
+
+ given:
+ // (absolute) URI of the base resource
+ def baseUri = new URI("http://localhost:8080/baseUrl")
+ // (relative) URI of the top-level Resource
+ def uri2 = new URI("resource")
+ // (relative) URI of the second-level Resource
+ def uri3 = new URI("1")
+ // (fragment) URI of the bottom-level Resource
+ def uri4 = new URI("#count")
+
+ when:
+ def uri5 = UriUtils.merge(baseUri, uri2, uri3, uri4)
+
+ then:
+ uri5.toString() == "http://localhost:8080/baseUrl/resource/1#count"
+
+ }
+
+ def "explodes URIs correctly"() {
+
+ given:
+ // (absolute) URI of the base resource
+ def baseUri = new URI("http://localhost:8080/baseUrl")
+ // (absolute) URI of the full resource to get a path to
+ def resourceUri = new URI("http://localhost:8080/baseUrl/resource/1#property")
+
+ when:
+ def uris = UriUtils.explode(baseUri, resourceUri)
+
+ then:
+ uris.size() == 3
+ uris[2].fragment == "property"
+
+ }
+
+}
View
74 ...core/src/test/groovy/org/springframework/data/services/repository/JpaRepositoryEntityResolverSpec.groovy
@@ -0,0 +1,74 @@
+package org.springframework.data.services.repository
+
+import javax.persistence.Entity
+import javax.persistence.GeneratedValue
+import javax.persistence.GenerationType
+import javax.persistence.Id
+import org.springframework.context.ApplicationContext
+import org.springframework.context.support.ClassPathXmlApplicationContext
+import org.springframework.data.services.util.UriUtils
+import spock.lang.Specification
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+class JpaRepositoryEntityResolverSpec extends Specification {
+
+ ApplicationContext appCtx
+ SimpleEntityRepository repository
+ JpaRepositoryEntityResolver resolver
+
+ def setup() {
+ appCtx = new ClassPathXmlApplicationContext("JpaRepositoryEntityResolver-test.xml")
+ repository = appCtx.getBean(SimpleEntityRepository)
+ resolver = appCtx.getBean(JpaRepositoryEntityResolver)
+ }
+
+ def "resolves an entity using findOne"() {
+
+ when:
+ def entity = new SimpleEntity(name: "John Doe")
+ repository.save(entity)
+ def id = entity.id
+ def entity2 = resolver.resolve(new URI(id.toString()), repository)
+
+ then:
+ entity.equals(entity2)
+
+ }
+
+ def "resolves an entity using findOne and an absolute URI"() {
+
+ given:
+ def baseUri = new URI("http://localhost:8080/data/simpleEntity")
+
+ when:
+ def entity = new SimpleEntity(name: "John Doe")
+ repository.save(entity)
+ def id = entity.id
+ def entity2 = resolver.resolve(UriUtils.merge(baseUri, new URI(id.toString())), repository)
+
+ then:
+ entity.equals(entity2)
+
+ }
+
+}
+
+@Entity
+class SimpleEntity {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ Long id
+ String name
+
+ @Override boolean equals(Object o) {
+ if (o instanceof SimpleEntity) {
+ SimpleEntity se = (SimpleEntity) o
+ return se.id.equals(id) && se.name.equals(name)
+ }
+ return super.equals(o)
+ }
+
+
+}
View
9 exporter-core/src/test/java/org/springframework/data/services/repository/SimpleEntityRepository.java
@@ -0,0 +1,9 @@
+package org.springframework.data.services.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public interface SimpleEntityRepository extends CrudRepository<SimpleEntity, String> {
+}
View
40 exporter-core/src/test/resources/JpaRepositoryEntityResolver-test.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:jdbc="http://www.springframework.org/schema/jdbc"
+ xmlns:jpa="http://www.springframework.org/schema/data/jpa"
+ 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
+ http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
+ http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
+
+ <jdbc:embedded-database id="dataSource" type="HSQL"/>
+
+ <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>
+ <property name="persistenceUnitName" value="jpa.sample"/>
+ </bean>
+ <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
+ <property name="entityManagerFactory" ref="entityManagerFactory"/>
+ </bean>
+
+ <jpa:repositories base-package="org.springframework.data.services.repository"/>
+
+ <bean id="baseUri" class="java.net.URI">
+ <constructor-arg value="http://localhost:8080/data"/>
+ </bean>
+ <bean id="jpaRepositoryMetadata" class="org.springframework.data.services.repository.JpaRepositoryMetadata"/>
+ <bean id="conversionService" class="org.springframework.core.convert.support.DefaultConversionService"/>
+
+ <bean class="org.springframework.data.services.repository.JpaRepositoryEntityResolver">
+ <constructor-arg ref="baseUri"/>
+ <constructor-arg ref="jpaRepositoryMetadata"/>
+ <constructor-arg ref="conversionService"/>
+ </bean>
+
+</beans>
View
14 exporter-core/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+ <persistence-unit name="jpa.sample">
+ <class>org.springframework.data.services.repository.SimpleEntity</class>
+ <properties>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:spring"/>
+ <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
+ <property name="hibernate.connection.username" value="sa"/>
+ <property name="hibernate.connection.password" value=""/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ </properties>
+ </persistence-unit>
+</persistence>
View
10 exporter-core/src/test/resources/Resolver-test.xml
@@ -0,0 +1,10 @@
+<?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">
+
+ <bean id="simpleBean" class="org.springframework.data.services.SimpleBean">
+ <constructor-arg value="John Doe"/>
+ </bean>
+
+</beans>
View
1  exporter-web/exporter-web.iml
@@ -40,6 +40,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/groovy" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
View
26 exporter-web/src/main/java/org/springframework/data/services/web/JsonView.java
@@ -0,0 +1,26 @@
+package org.springframework.data.services.web;
+
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.http.MediaType;
+import org.springframework.web.servlet.view.AbstractView;
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+public class JsonView extends AbstractView {
+
+ public JsonView() {
+ setContentType(MediaType.APPLICATION_JSON.toString());
+ }
+
+ @Override
+ protected void renderMergedOutputModel(Map<String, Object> model,
+ HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ }
+
+}
View
27 exporter-web/src/main/webapp/WEB-INF/exporter-servlet.xml
@@ -26,28 +26,7 @@
<jdbc:embedded-database id="dataSource" type="HSQL"/>
- <jpa:repositories base-package="org.springframework.data.services.exporter.repository"/>
-
- <bean id="personRepositoryExporter" class="org.springframework.data.services.exporter.rest.RestExporter">
- <property name="allowedMethods">
- <list>
- <value type="org.springframework.http.HttpMethod">GET</value>
- <value type="org.springframework.http.HttpMethod">POST</value>
- <value type="org.springframework.http.HttpMethod">PUT</value>
- </list>
- </property>
- <property name="baseUrl" value="/spring-data-services-exporter"/>
- <property name="repository" ref="personRepository"/>
- </bean>
- <bean id="profileRepositoryExporter" class="org.springframework.data.services.exporter.rest.RestExporter">
- <property name="allowedMethods">
- <list>
- <value type="org.springframework.http.HttpMethod">GET</value>
- </list>
- </property>
- <property name="baseUrl" value="/spring-data-services-exporter"/>
- <property name="repository" ref="profileRepository"/>
- </bean>
+ <jpa:repositories base-package="org.springframework.data.services.web.repository"/>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
@@ -62,11 +41,9 @@
<property name="defaultContentType" value="application/json"/>
<property name="defaultViews">
<list>
- <bean id="json" class="org.springframework.data.services.exporter.rest.JsonView"/>
+ <bean id="json" class="org.springframework.data.services.web.JsonView"/>
</list>
</property>
</bean>
- <context:component-scan base-package="org.springframework.data.services.exporter.rest"/>
-
</beans>
View
9 exporter-web/src/test/groovy/org/springframework/data/services/web/WebResourceSpec.groovy
@@ -0,0 +1,9 @@
+package org.springframework.data.services.web
+
+import spock.lang.Specification
+
+/**
+ * @author Jon Brisbin <jon@jbrisbin.com>
+ */
+class WebResourceSpec extends Specification {
+}
View
1  gradle.properties
@@ -10,6 +10,7 @@ cglibVersion = 2.2
groovyVersion = 1.8.4
# Supporting libraries
+sdCommonsVersion = 1.2.0.RELEASE
sdMongoVersion = 1.0.0.M5
sdJpaVersion = 1.0.1.RELEASE
mongoDriverVersion = 2.6.5
View
9 spring-data-services.ipr
@@ -64,6 +64,7 @@
<element id="file-copy" path="$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.slf4j/jcl-over-slf4j/1.6.1/jar/99c61095a14dfc9e47a086068033c286bf236475/jcl-over-slf4j-1.6.1.jar" />
<element id="file-copy" path="$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.aspectj/aspectjrt/1.6.8/jar/8c234df6a43dd5ba355803122e33caa7ccd11011/aspectjrt-1.6.8.jar" />
<element id="file-copy" path="$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.mongodb/mongo-java-driver/2.6.5/jar/e33bb494ca9023cbce92f230b5fb4ee9c478e5fe/mongo-java-driver-2.6.5.jar" />
+ <element id="file-copy" path="$USER_HOME$/.gradle/caches/artifacts-8/filestore/org.springframework.data/spring-data-commons-core/1.2.0.RELEASE/jar/dbc606a35154cdca44fdfe84668dcf0a77fb88f1/spring-data-commons-core-1.2.0.RELEASE.jar" />
</element>
</element>
</root>
@@ -93,6 +94,9 @@
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+ <component name="EntryPointsManager">
+ <entry_points version="2.0" />
+ </component>
<component name="FrameworkDetectionExcludesConfiguration">
<file type="jpa" url="file://$PROJECT_DIR$/exporter-2012-01-10/build/artifacts/spring_data_services_exporter_Web_exploded/WEB-INF/classes/META-INF/persistence.xml" />
<file type="jpa" url="file://$PROJECT_DIR$/exporter-2012-01-10/build/classes/test/META-INF/persistence.xml" />
@@ -137,6 +141,9 @@
<setting name="root" />
</component>
<component name="IdProvider" IDEtalkID="11DA1DB66DD62DDA1ED602B7079FE97C" />
+ <component name="JavacSettings">
+ <option name="ADDITIONAL_OPTIONS_STRING" value="-Xlint:unchecked" />
+ </component>
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" />
<option name="OPTION_SCOPE" value="protected" />
@@ -164,7 +171,7 @@
<component name="ProjectResources">
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
</component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="OpenJDK 1.7" project-jdk-type="JavaSDK">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build" />
</component>
<component name="SvnBranchConfigurationManager">
Please sign in to comment.
Something went wrong with that request. Please try again.