From e71ff751d45b1ad95ea9c2b3e6bb54d054a68799 Mon Sep 17 00:00:00 2001 From: trisberg Date: Fri, 23 Jul 2010 14:09:16 -0400 Subject: [PATCH] beginnig common abstractions for graph db --- .classpath | 44 +++++++-- .project | 38 ++++---- .settings/org.eclipse.jdt.core.prefs | 20 ++-- pom.xml | 91 ++++++++++++++++++- .../neo4j/Neo4jConnectionFactory.java | 61 +++++++++++++ .../neo4j/Neo4jDatastoreTemplate.java | 47 ++++++++++ 6 files changed, 257 insertions(+), 44 deletions(-) create mode 100644 src/main/java/org/springframework/datastore/neo4j/Neo4jConnectionFactory.java create mode 100644 src/main/java/org/springframework/datastore/neo4j/Neo4jDatastoreTemplate.java diff --git a/.classpath b/.classpath index 31cf404a4..87334e81b 100644 --- a/.classpath +++ b/.classpath @@ -1,8 +1,38 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.project b/.project index 89483e612..a9dc0747e 100644 --- a/.project +++ b/.project @@ -1,23 +1,17 @@ - - datastore-graph - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - + datastore-graph + + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + \ No newline at end of file diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 952a512b0..7f90a1fbf 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,13 +1,13 @@ -#Mon May 10 15:26:33 EDT 2010 +#Fri Jul 23 13:12:34 EDT 2010 +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.debug.lineNumber=generate eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -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.source=1.5 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/pom.xml b/pom.xml index 22c017d0a..064d5ea43 100644 --- a/pom.xml +++ b/pom.xml @@ -4,23 +4,104 @@ org.springframework.datastore datastore-graph - 0.0.1-SNAPSHOT + Spring Datastore Key Value jar - - datastore-graph - http://maven.apache.org + 1.0.0.CI-SNAPSHOT UTF-8 + 3.0.0.RELEASE + 1.6.0 junit junit - 4.7 + 4.8.1 test + + + log4j + log4j + 1.2.15 + + + + javax.mail + mail + + + javax.jms + jms + + + com.sun.jdmk + jmxtools + + + com.sun.jmx + jmxri + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + + + + + org.neo4j + neo4j-kernel + 1.0 + + + org.neo4j + neo4j-utils + 1.0 + + + + + org.springframework + org.springframework.core + ${spring.version} + + + org.springframework + org.springframework.test + ${spring.version} + test + + + org.springframework + org.springframework.context + ${spring.version} + + + org.springframework + org.springframework.transaction + ${spring.version} + + + + org.springframework.data + data-commons + 1.0.0.CI-SNAPSHOT + diff --git a/src/main/java/org/springframework/datastore/neo4j/Neo4jConnectionFactory.java b/src/main/java/org/springframework/datastore/neo4j/Neo4jConnectionFactory.java new file mode 100644 index 000000000..b00c8dfdc --- /dev/null +++ b/src/main/java/org/springframework/datastore/neo4j/Neo4jConnectionFactory.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.datastore.neo4j; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.neo4j.graphdb.GraphDatabaseService; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.datastore.core.DatastoreConnectionFactory; +import org.springframework.util.Assert; + +/** + * Convenient factory for configuring Neo4J. + * + * @author Thomas Risberg + * @since 1.0 + */ +public class Neo4jConnectionFactory implements DatastoreConnectionFactory, InitializingBean { + + /** + * Logger, available to subclasses. + */ + protected final Log logger = LogFactory.getLog(getClass()); + + private GraphDatabaseService graphDatabaseService = null; + + public Neo4jConnectionFactory() { + super(); + } + + public Neo4jConnectionFactory(GraphDatabaseService graphDatabaseService) { + super(); + this.graphDatabaseService = graphDatabaseService; + } + + public void afterPropertiesSet() throws Exception { + // apply defaults - convenient when used to configure for tests + // in an application context + Assert.notNull(graphDatabaseService, "GraphDatabaseService must be set"); + } + + public GraphDatabaseService getConnection() { + Assert.notNull(graphDatabaseService, "GraphDatabaseService must be set"); + return graphDatabaseService; + } + +} diff --git a/src/main/java/org/springframework/datastore/neo4j/Neo4jDatastoreTemplate.java b/src/main/java/org/springframework/datastore/neo4j/Neo4jDatastoreTemplate.java new file mode 100644 index 000000000..491eeb964 --- /dev/null +++ b/src/main/java/org/springframework/datastore/neo4j/Neo4jDatastoreTemplate.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.datastore.neo4j; + +import java.util.List; + +import org.springframework.data.core.DataMapper; +import org.springframework.data.core.QueryDefinition; +import org.springframework.datastore.core.AbstractDatastoreTemplate; + +import org.neo4j.graphdb.GraphDatabaseService; + +public class Neo4jDatastoreTemplate extends AbstractDatastoreTemplate { + + + public Neo4jDatastoreTemplate(Neo4jConnectionFactory connectionFactory) { + super(); + setDatastoreConnectionFactory(connectionFactory); + } + + public Neo4jDatastoreTemplate(GraphDatabaseService graphDatabaseService) { + super(); + setDatastoreConnectionFactory(new Neo4jConnectionFactory(graphDatabaseService)); + } + + @Override + public List query(QueryDefinition arg0, DataMapper arg1) { + return null; + } + + + +}