Skip to content

Commit

Permalink
DATAGRAPH-9 Updated documentation for xml-namespace config
Browse files Browse the repository at this point in the history
  • Loading branch information
jexp committed Feb 7, 2011
1 parent 938f462 commit d91f441
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 250 deletions.
38 changes: 26 additions & 12 deletions README.md
Expand Up @@ -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 {
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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
">

@Override
public boolean isUsingCrossStorePersistence() {
return false;
}
<context:annotation-config/>
<datagraph:config storeDirectory="target/config-test"/>

@Override
public GraphDatabaseService graphDatabaseService() {
return new EmbeddedGraphDatabase("target/neo4j-db");
}
}
</beans>

* 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)

<context:annotation-config/>

<bean class="org.springframework.data.graph.neo4j.config.Neo4jConfiguration"/>

<bean class="org.springframework.context.annotation.ConfigurationClassPostProcessor"/>

<bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase" destroy-method="shutdown">
<constructor-arg index="0" value="target/config-test"/>
</bean>

* 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:

Expand Down
2 changes: 0 additions & 2 deletions README.txt

This file was deleted.

182 changes: 0 additions & 182 deletions spring-data-neo4j/README.txt

This file was deleted.

Expand Up @@ -7,14 +7,13 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
">

<context:annotation-config/>
<context:annotation-config/>

<bean class="org.springframework.data.graph.neo4j.config.Neo4jConfiguration"/>

<bean class="org.springframework.context.annotation.ConfigurationClassPostProcessor"/>

<bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase"
destroy-method="shutdown" scope="singleton">
<bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase" destroy-method="shutdown">
<constructor-arg index="0" value="target/config-test"/>
</bean>

Expand Down
Expand Up @@ -9,8 +9,6 @@
http://www.springframework.org/schema/data/graph http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd
">

<!--context:component-scan base-package="org.springframework.data.graph.neo4j"/-->

<context:annotation-config/>
<datagraph:config storeDirectory="target/config-test"/>
<bean id="config" class="org.springframework.data.graph.neo4j.config.DataGraphNamespaceHandlerTest$Config"/>
Expand Down
Expand Up @@ -13,7 +13,7 @@

<bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase"
destroy-method="shutdown" scope="singleton">
<constructor-arg index="0" value="target/config-test" />
<constructor-arg value="target/config-test" />
</bean>

<datagraph:config graphDatabaseService="graphDatabaseService"/>
Expand Down
Expand Up @@ -61,7 +61,7 @@
-->
<context:component-scan base-package="org.springframework.data.graph.neo4j">
<context:exclude-filter expression=".*_Roo_.*" type="regex"/>
<context:exclude-filter expression="org.springframework.data.graph.neo4j.config.AbstractNeo4jConfiguration" type="regex"/>
<context:exclude-filter expression="org.springframework.data.graph.neo4j.config.Neo4jConfiguration" type="regex"/>
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>

Expand Down
41 changes: 20 additions & 21 deletions src/docbkx/cross-store.xml
Expand Up @@ -111,29 +111,28 @@
<section>
<title>Configuring cross-store persistence</title>
<para>
Configuring cross-store persistence is done similarly to the default DATAGRAPH operations. The concise Spring Java Config configuration class
already contains a method <code>isUsingCrossStorePersistence</code>that 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 <code>entityManagerFactory</code> in the xml-namespace it is set up for cross-store persistence.
</para>
<programlisting lang="JAVA" ><![CDATA[
public class MyRestaurantConfig extends AbstractNeo4jConfiguration {
@Override
public boolean isUsingCrossStorePersistence() {
return true;
}
@Bean(destroyMethod = "shutDown")
public GraphDatabaseService graphDatabaseService() {
return new EmbeddedGraphDatabase("target/myrestaurant-social");
}
} ]]></programlisting>
<programlisting lang="XML" ><![CDATA[
<beans>
...
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
<bean class="com.springone.myrestaurants.config.MyRestaurantConfig"/>
<bean class="org.springframework.context.annotation.ConfigurationClassPostProcessor"/>
...
<beans xmlns="http://www.springframework.org/schema/beans"
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
">
<context:annotation-config/>
<datagraph:config storeDirectory="target/config-test" entityManagerFactory="entityManagerFactory"/>
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml"/>
</bean>
</beans>
]]></programlisting>

Expand Down
4 changes: 2 additions & 2 deletions src/docbkx/programming-model.xml
Expand Up @@ -208,8 +208,8 @@ Iterable<Person> 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.
</para>
in the Spring Java config class <code>Neo4jConfiguration</code>.
</para>
<para>
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
Expand Down

0 comments on commit d91f441

Please sign in to comment.