From d91f441ec453efd9bdfb50e85e1ad6b7282dd7cd Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Tue, 8 Feb 2011 00:19:31 +0100 Subject: [PATCH] DATAGRAPH-9 Updated documentation for xml-namespace config --- README.md | 38 ++-- README.txt | 2 - spring-data-neo4j/README.txt | 182 ------------------ ...GraphNamespaceHandlerTest-code-context.xml | 5 +- .../DataGraphNamespaceHandlerTest-context.xml | 2 - ...eHandlerTest-external-embedded-context.xml | 2 +- .../Neo4jGraphPersistenceTest-context.xml | 2 +- src/docbkx/cross-store.xml | 41 ++-- src/docbkx/programming-model.xml | 4 +- src/docbkx/setup.xml | 93 ++++++--- 10 files changed, 121 insertions(+), 250 deletions(-) delete mode 100644 README.txt delete mode 100644 spring-data-neo4j/README.txt diff --git a/README.md b/README.md index d9f66b825..f291483a1 100644 --- a/README.md +++ b/README.md @@ -84,21 +84,35 @@ Configure the Aspect-J maven plugin build & library dependency. Add the followi Spring Configuration: -* Configure Spring Data Graph for Neo4j in your application using Spring 3.0's [Java based bean metadata](http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/new-in-3.html#new-java-configuration) For XML based configuration refer to the User Guide. +* Configure Spring Data Graph for Neo4j in your application using the provided xml namespace. - @Configuration - public class MyConfig extends AbstractNeo4jConfiguration { + + - @Override - public boolean isUsingCrossStorePersistence() { - return false; - } + + - @Override - public GraphDatabaseService graphDatabaseService() { - return new EmbeddedGraphDatabase("target/neo4j-db"); - } - } + + +* You can also use the supplied Java @Configuration in Neo4jConfiguration. [Java based bean metadata](http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/new-in-3.html#new-java-configuration) + + + + + + + + + + * Annotate your entity class. In this case it is a 'World' class that has a relationship to other worlds that are reachable by rocket travel: diff --git a/README.txt b/README.txt deleted file mode 100644 index 225ba8c88..000000000 --- a/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -Spring Data Graph Project - diff --git a/spring-data-neo4j/README.txt b/spring-data-neo4j/README.txt deleted file mode 100644 index 710b0343e..000000000 --- a/spring-data-neo4j/README.txt +++ /dev/null @@ -1,182 +0,0 @@ -Getting started with data-graph-neo4j -===================================== - -It provides an annotation-driven object-graph mapping library. -Data-graph-neo4j is to Neo4j what Hibernate is to an RDBMS. It requires -AspectJ and Spring Framework. - -More examples using data-graph-neo4j can be found in this repository: -http://github.com/SpringSource/spring-data-graph-examples - -Standalone setup of project using data-graph-neo4j -================================================== - - -1. Maven Dependency -------------------- - -Include data-graph-neo4j in your pom.xml: - - - org.springframework.data - spring-data-neo4j - 1.0.0.BUILD-SNAPSHOT - - -2. Aspect-J plugin build & library dependency ---------------------------------------------- - -Add the following plugin XML to your project's config in pom.xml -to hook AspectJ into the build process: - - - org.codehaus.mojo - aspectj-maven-plugin - 1.0 - - true - - - org.springframework - spring-aspects - - - org.springframework.data - spring-data-neo4j - - - 1.6 - 1.6 - - - - - compile - test-compile - - - - - - org.aspectj - aspectjrt - ${aspectj.version} - - - org.aspectj - aspectjtools - ${aspectj.version} - - - - - -3. Spring configuration ------------------------ - -3.1. Spring XML Config ----------------------- - -This is a the full Spring XML context configuration to get started. It creates -all dependencies required by the library. - -A simpler configuration approach is provided below the full config: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -3.2 Spring-Java-Config ----------------------- - -You can also derive from a provided abstract spring configuration class (spring-javaconfig) that already encapsulates all this -configuration and just provide a directory for the graph database: - -public class MyConfig extends AbstractNeo4jConfiguration { - @Override - public boolean isUsingCrossStorePersistence() { - return false; - } - - @Bean(destroyMethod = "shutDown") - public GraphDatabaseService graphDatabaseService() { - return new EmbeddedGraphDatabase("target/neo4j-db"); - } -} - -Then your spring xml configuration file gets much simpler: - -... - - - - -... - - -4. Setup done -------------- - -After this is set up, you can just use the annotated POJOs and they will automatically be backed by Neo4j. -The one thing that the user has to do is wrap any data-graph-neo4j usage in Neo4j transactions. (or just use @Transactional) - -You should now be set up with the AspectJ configuration in your pom.xml, and -the necessary Spring configuration setting up the library with its -dependencies. diff --git a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-code-context.xml b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-code-context.xml index bd03d7901..8225ee6f4 100644 --- a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-code-context.xml +++ b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-code-context.xml @@ -7,14 +7,13 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd "> - + - + diff --git a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-context.xml b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-context.xml index 3ffbfb8d5..27284b5cf 100644 --- a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-context.xml +++ b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-context.xml @@ -9,8 +9,6 @@ http://www.springframework.org/schema/data/graph http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd "> - - diff --git a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-external-embedded-context.xml b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-external-embedded-context.xml index b4772b5fb..da2f1b806 100644 --- a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-external-embedded-context.xml +++ b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest-external-embedded-context.xml @@ -13,7 +13,7 @@ - + diff --git a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml index 9f32b9fca..3cab0f23a 100644 --- a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml +++ b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml @@ -61,7 +61,7 @@ --> - + diff --git a/src/docbkx/cross-store.xml b/src/docbkx/cross-store.xml index 5232af6d6..e03b23e77 100644 --- a/src/docbkx/cross-store.xml +++ b/src/docbkx/cross-store.xml @@ -111,29 +111,28 @@
Configuring cross-store persistence - Configuring cross-store persistence is done similarly to the default DATAGRAPH operations. The concise Spring Java Config configuration class - already contains a method isUsingCrossStorePersistencethat must be implemented by a concrete configuration which controls - the cross-store mode of DATAGRAPH. + Configuring cross-store persistence is done similarly to the default DATAGRAPH operations. As soon as you refer + to an entityManagerFactory in the xml-namespace it is set up for cross-store persistence. - -... - - - -... + + + + + + + + + + ]]> diff --git a/src/docbkx/programming-model.xml b/src/docbkx/programming-model.xml index cb5e0e765..0b35e281b 100644 --- a/src/docbkx/programming-model.xml +++ b/src/docbkx/programming-model.xml @@ -208,8 +208,8 @@ Iterable davesFriends = finder.findAllByTraversal(dave, Neo4j is a transactional datastore which only allows modifications within transaction boundaries and fullfills the ACID properties. Reading from the store is also possible outside of transactions. Neo4j also provides a Spring compliant transaction manager that allows it to participate in Spring managed transactions (also with @Transactional). This transaction manager is already configured - in the Spring Java config, class AbstractNeo4jConfiguration. - + in the Spring Java config class Neo4jConfiguration. + DATAGRAPH is designed to work within transaction boundaries. So entity creation and modification should happen within transactional methods. Due to the usage of POJO entities it is common to create and populate them also outside of a transaction (e.g. in the web layer). That's why diff --git a/src/docbkx/setup.xml b/src/docbkx/setup.xml index ef7e38d9e..2bc5cf4ff 100644 --- a/src/docbkx/setup.xml +++ b/src/docbkx/setup.xml @@ -129,31 +129,76 @@ an appropriate NodeTypeStrategy - That's why DATAGRAPH provides a Spring Java Config class (annotated with @Config) AbstractNeo4jConfiguration that takes care of all that. The only - thing that must be provided in the custom Spring config is the GraphDatabaseService configured with a datastore directory. This can be achieved - by extending that class and implementing the graphDatabaseService method. - - -... + +
+ XML-Namespace + + To simplify the configuration we provide a xml namespace datagraph that allows configuration of any + DATAGRAPH project with a single line of xml code. There are three possible parameters. You can use storeDirectory + or the reference to graphDatabaseService alternatively. For cross-store configuration just refer + to an entityManagerFactory. + + + - - - -... - - ]]> - + + + + + ]]> + + + + + + + + ]]> + + + + + + + + + + ]]> +
+
+ Java based Configuration + + That's why DATAGRAPH provides a Spring Java Config class (annotated with @Config) Neo4jConfiguration that takes care of all that. The only + thing that must be provided in the custom Spring config is the GraphDatabaseService configured with a datastore directory. + + ... + + + + + + + + + + ... + + ]]> + +