From 1331232ece28f74ad66e030825141a2df71d452b Mon Sep 17 00:00:00 2001 From: David Montag Date: Tue, 12 Apr 2011 23:07:15 -0700 Subject: [PATCH] Edited setup chapter. Minor edits in foreword. --- src/docbkx/introduction/emil.xml | 13 +- src/docbkx/introduction/rod.xml | 38 ++-- src/docbkx/reference/setup.xml | 371 ++++++++++++++++--------------- 3 files changed, 221 insertions(+), 201 deletions(-) diff --git a/src/docbkx/introduction/emil.xml b/src/docbkx/introduction/emil.xml index 496f47c03..08de66038 100644 --- a/src/docbkx/introduction/emil.xml +++ b/src/docbkx/introduction/emil.xml @@ -1,11 +1,10 @@ - - - Foreword by Emil Eifrem - - Emil Eifrem, CEO of Neo Technology - - + +Foreword by Emil Eifrem + + Emil Eifrem, CEO of Neo Technology + + diff --git a/src/docbkx/introduction/rod.xml b/src/docbkx/introduction/rod.xml index e65036977..708909cd6 100644 --- a/src/docbkx/introduction/rod.xml +++ b/src/docbkx/introduction/rod.xml @@ -1,43 +1,47 @@ - + Foreword by Rod Johnson - - I’m excited about Spring Data Graph for several reasons. - - + + I’m excited about Spring Data Graph for several reasons. + + First, this project is in a very important space. We are in an era of transition. A very few years ago, a relational database was a given for storing nearly all the data in nearly all applications. While relational databases remain important, new application requirements and massive data proliferation have prompted a richer - choice of data stores. Graph databases have some very interesting strengths, and Neo4J is proving itself - valuable in many applications. It’s a choice you should add to your toolbox. - + choice of data stores. Graph databases have some very interesting strengths, and Neo4j is proving itself + valuable in many applications. It's a choice you should add to your toolbox. + + Second, Spring Data Graph is an innovative project, which makes it easy to work with one of the most interesting new data stores. Unfortunately, the proliferation of new data stores has not been matched by innovation in programming models to work with them. Ironically, just after modern ORM mapping made working with relational data in Java relatively easy, the data store disruption occurred, and developers were back to square one: struggling once more with clumsy, low level APIs. Working with most non-relational technologies is overly - complex and imposes too much work on developers. Spring Data Graph makes working with Neo4J amazingly easy, and + complex and imposes too much work on developers. Spring Data Graph makes working with Neo4j amazingly easy, and therefore has the potential to make you more successful as a developer. Its use of AspectJ to eliminate persistence code from your domain model is truly innovative, and on the cutting edge of today’s Java technologies. - - Third, I’m excited about Spring Data Graph for personal reasons. I no longer get to write code as often as I - would like. My initial convictions that Spring and AspectJ could both make building applications with Neo4J + + + Third, I'm excited about Spring Data Graph for personal reasons. I no longer get to write code as often as I + would like. My initial convictions that Spring and AspectJ could both make building applications with Neo4j dramatically easier and cross-store object navigation possible gave me an excuse for a much-needed coding binge early in 2011. This led to a prototype of what became Spring Data Graph — at times written paired with Emil. I’m - sure the vast majority of my code has long since been replaced (probably for the better) by coders who aren’t + sure the vast majority of my code has long since been replaced (probably for the better) by coders who aren't rusty — thanks Michael and Thomas! — but I retain my pleasant memories. - + + Finally, Spring Data Graph is part of the broader Spring Data project: one of the key areas in which Spring is innovating to help meet new application requirements. I encourage you to explore Spring Data, and — better still — become involved in the community and contribute. - + + Enjoy the Spring Data Graph book, and happy coding! - + Rod Johnson, Founder, Spring and SVP, Application Platform, VMware - + diff --git a/src/docbkx/reference/setup.xml b/src/docbkx/reference/setup.xml index 92f9e16b2..8a3abfbad 100644 --- a/src/docbkx/reference/setup.xml +++ b/src/docbkx/reference/setup.xml @@ -2,210 +2,227 @@ Environment setup - To use Spring Data Graph in your application, some setup is required. For building the application the necessary Maven dependencies must be included and - for the AspectJ weaving some extensions of the compile goal are necessary. This chapter also discusses the Spring configuration needed to set up - Spring Data Graph. Examples for this setup can be found in the Spring Data Graph examples. + + Spring Data Graph dramatically simplifies development, but some setup is naturally required. + For building the application, Maven needs to be configured to include the Spring Data Graph dependencies, + and configure the AspectJ weaving. After the build setup is complete, the Spring application needs to be + configured to make use of Spring Data Graph. + + +
- Maven Configuration + Maven configuration - As stated in the requirements chapter, Spring Data Graph projects are easiest to build with Apache Maven. The main dependencies are Spring Data Graph itself, Spring Data Commons, some parts of the Spring Framework and of course the Neo4j graph database. + Spring Data Graph projects are easiest to build with Apache Maven. The main dependencies are: Spring + Data Graph itself, Spring Data Commons, parts of the Spring Framework, and the Neo4j graph database. +
- Repositories + Repositories - The milestone releases of Spring Data Graph are available from the dedicated milestone repository. Neo4j - releases and milestones are available from Maven Central. + The milestone releases of Spring Data Graph are available from the dedicated milestone + repository. Neo4j releases and milestones are available from Maven Central. - - spring-maven-milestone - Springframework Maven Repository - http://maven.springframework.org/milestone + + Spring milestone repository + + spring-maven-milestone + Springframework Maven Repository + http://maven.springframework.org/milestone - ]]> -
-
- Dependencies - The dependency on spring-data-neo4j - should transitively pull in Spring Framework (core, context, aop, - aspects, tx), Aspectj, Neo4j and Spring Data Commons. If you already use these (or different versions of - these) in your project, then include those dependencies on your own. - - - org.springframework.data - spring-data-neo4j - 1.0.0.RC1 - - - - org.aspectj - aspectjrt - 1.6.11.RELEASE - - ]]> - +]]> +
-
- AspectJ build configuration - As Spring Data Graph uses AspectJ for build time aspect weaving of your entities, it is necessary to add the aspectj-plugin to the build phases. The plugin has its own dependencies. You also need to explicitely specifiy libraries containing aspects (spring-aspects and spring-data-neo4j) - - org.codehaus.mojo - aspectj-maven-plugin - 1.0 - - - - org.aspectj - aspectjrt - 1.6.11.RELEASE - - - org.aspectj - aspectjtools - 1.6.11.RELEASE - - - - - - compile - test-compile - - - - - true - - - org.springframework - spring-aspects - - - org.springframework.data - spring-datastore-neo4j - - - 1.6 - 1.6 - - - ]]> -
-
-
- Setting Up Spring Data Graph - Spring Configuration - The concrete configuration for Spring Data Graph is quite verbose as there is no autowiring involved. It sets up the following parts. - - - GraphDatabaseService for the embedded Neo4j storage engine - - - Spring transaction manager, Neo4j transaction manager - - - aspects and instantiators for node and relationship entities - - - EntityState and FieldAccessFactories needed for the different field handling - - - Conversion services - - - Repository support - - - TypeRepresentationStrategies - - - -
- XML-Namespace + Dependencies - To simplify the configuration we provide a xml namespace datagraph that allows configuration of any - Spring Data Graph 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. + The dependency on spring-data-neo4j will transitively pull in the necessary parts of + Spring Framework (core, context, aop, aspects, tx), Aspectj, Neo4j, and Spring Data Commons. If you + already use these (or different versions of these) in your project, then include those dependencies + on your own. - + + Maven dependencies + + org.springframework.data + spring-data-neo4j + 1.0.0.RC1 + + + + org.aspectj + aspectjrt + 1.6.11.RELEASE + +]]> + +
+ +
+ AspectJ build configuration + + Since Spring Data Graph uses AspectJ for build-time aspect weaving of entities, it is necessary to + hook in the AspectJ Maven plugin to the build process. The plugin also has its own dependencies. You + also need to explicitly specify the aspect libraries (spring-aspects and spring-data-neo4j). + + + AspectJ configuration + + org.codehaus.mojo + aspectj-maven-plugin + 1.0 + + + + org.aspectj + aspectjrt + 1.6.11.RELEASE + + + org.aspectj + aspectjtools + 1.6.11.RELEASE + + + + + + compile + test-compile + + + + + true + + + org.springframework + spring-aspects + + + org.springframework.data + spring-datastore-neo4j + + + 1.6 + 1.6 + + +]]> + +
+
+ +
+ Spring configuration + + Users of Spring Data Graph have two ways of very concisely configuring it. Either they can use a + Spring Data Graph XML configuration namespace, or they can use a Java-based bean configuration. + +
+ XML namespace + + The XML namespace can be used to configure Spring Data Graph. The config element + provides an XML-based configuration of Spring Data Graph in one line. It has three attributes. + graphDatabaseService points out the Neo4j instance to use. For convenience, + storeDirectory can be set instead of graphDatabaseService to + point to a directory where a new EmbeddedGraphDatabase will be created. For + cross-store configuration, the entityManagerFactory attribute needs to be + configured. + + + XML configuration with store directory + + xmlns:context="http://www.springframework.org/schema/context" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:datagraph="http://www.springframework.org/schema/data/graph" + xsi:schemaLocation=" + 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 + http://www.springframework.org/schema/data/graph + http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd"> - ]]> - +]]> + + + XML configuration with bean + - - - + + + - - ]]> + +]]> + + + XML configuration with cross-store + - + + + + - - - - - - - ]]> + +]]> +
- Java based Configuration + Java-based bean configuration - You can also configure Spring Data Graph using Java based bean metadata. - For those not familiar with how to configure the Spring - container using Java based bean metadata instead of XML based metadata - see the high level introduction in the reference docs here as well as the detailed documentation here. - - -To help configure Spring Data Graph using Java based bean metadata the class Neo4jConfiguration is registerd with the context either explicitly in the XML config or via classpath scanning for classes that have the @Configuration annotation. The only thing that must be provided in addition is the GraphDatabaseService configured with a datastore directory. The example below shows using XML to register the Neo4jConfiguration @Configuration class as well as Spring's ConfigurationClassPostProcessor that transforms the @Configuration class to bean definitions. - - ... - - - - - - - - - - ... - - ]]> + You can also configure Spring Data Graph using Java-based bean metadata. + + + + For those not familiar with Java-based bean metadata in Spring, we recommend that you + read up on it first. The Spring documentation has a + high-level introduction + as well as + detailed documentation + on it. + + + In order to configure Spring Data Graph with Java-based bean metadata, the class + Neo4jConfiguration is registered with the context. This is either done + explicitly in the context configuration, or via classpath scanning for classes that + have the @Configuration annotation. The only thing that must be provided is the + GraphDatabaseService. The example below shows how to register the + @Configuration Neo4jConfiguration class, as well as Spring's + ConfigurationClassPostProcessor that transforms the + @Configuration class to bean definitions. + + Java-based bean configuration + + ... + + + + + + + + + ... + +]]> + + +