commit
eca4edc1af
8 changed files with 283 additions and 0 deletions
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
<classpath> |
||||
<classpathentry kind="src" path="src/main/java"/> |
||||
<classpathentry kind="output" path="target/classes"/> |
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar" sourcepath="M2_REPO/org/aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0-sources.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.0/jcl-over-slf4j-1.6.0.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/junit/junit/4.8.1/junit-4.8.1.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.15/log4j-1.2.15.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/mongodb/mongo-java-driver/1.4/mongo-java-driver-1.4.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/springframework/org.springframework.aop/3.0.0.RELEASE/org.springframework.aop-3.0.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/org.springframework.aop/3.0.0.RELEASE/org.springframework.aop-3.0.0.RELEASE-sources.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/springframework/org.springframework.asm/3.0.0.RELEASE/org.springframework.asm-3.0.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/org.springframework.asm/3.0.0.RELEASE/org.springframework.asm-3.0.0.RELEASE-sources.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/springframework/org.springframework.beans/3.0.0.RELEASE/org.springframework.beans-3.0.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/org.springframework.beans/3.0.0.RELEASE/org.springframework.beans-3.0.0.RELEASE-sources.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/springframework/org.springframework.context/3.0.0.RELEASE/org.springframework.context-3.0.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/org.springframework.context/3.0.0.RELEASE/org.springframework.context-3.0.0.RELEASE-sources.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/springframework/org.springframework.core/3.0.0.RELEASE/org.springframework.core-3.0.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/org.springframework.core/3.0.0.RELEASE/org.springframework.core-3.0.0.RELEASE-sources.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/springframework/org.springframework.expression/3.0.0.RELEASE/org.springframework.expression-3.0.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/org.springframework.expression/3.0.0.RELEASE/org.springframework.expression-3.0.0.RELEASE-sources.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/springframework/org.springframework.test/3.0.0.RELEASE/org.springframework.test-3.0.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/org.springframework.test/3.0.0.RELEASE/org.springframework.test-3.0.0.RELEASE-sources.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/springframework/org.springframework.transaction/3.0.0.RELEASE/org.springframework.transaction-3.0.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/org.springframework.transaction/3.0.0.RELEASE/org.springframework.transaction-3.0.0.RELEASE-sources.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.0/slf4j-api-1.6.0.jar"/> |
||||
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.0/slf4j-log4j12-1.6.0.jar"/> |
||||
</classpath> |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
<projectDescription> |
||||
<name>datastore-document</name> |
||||
<comment/> |
||||
<projects/> |
||||
<buildSpec> |
||||
<buildCommand> |
||||
<name>org.eclipse.jdt.core.javabuilder</name> |
||||
</buildCommand> |
||||
</buildSpec> |
||||
<natures> |
||||
<nature>org.eclipse.jdt.core.javanature</nature> |
||||
</natures> |
||||
</projectDescription> |
||||
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
#Wed Jul 14 14:36:01 EDT 2010 |
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 |
||||
eclipse.preferences.version=1 |
||||
org.eclipse.jdt.core.compiler.source=1.5 |
||||
org.eclipse.jdt.core.compiler.compliance=1.5 |
||||
@ -0,0 +1,111 @@
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<groupId>org.springframework.datastore.document</groupId> |
||||
<artifactId>datastore-document</artifactId> |
||||
<name>Spring Datastore Document</name> |
||||
<packaging>jar</packaging> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
|
||||
<properties> |
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
<spring.version>3.0.0.RELEASE</spring.version> |
||||
<slf4j.version>1.6.0</slf4j.version> |
||||
</properties> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>junit</groupId> |
||||
<artifactId>junit</artifactId> |
||||
<version>4.8.1</version> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>log4j</groupId> |
||||
<artifactId>log4j</artifactId> |
||||
<version>1.2.15</version> |
||||
<!-- Exclusions only required for version 1.2.15 of log4j --> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>javax.mail</groupId> |
||||
<artifactId>mail</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>javax.jms</groupId> |
||||
<artifactId>jms</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>com.sun.jdmk</groupId> |
||||
<artifactId>jmxtools</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>com.sun.jmx</groupId> |
||||
<artifactId>jmxri</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.slf4j</groupId> |
||||
<artifactId>slf4j-api</artifactId> |
||||
<version>${slf4j.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.slf4j</groupId> |
||||
<artifactId>jcl-over-slf4j</artifactId> |
||||
<version>${slf4j.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.slf4j</groupId> |
||||
<artifactId>slf4j-log4j12</artifactId> |
||||
<version>${slf4j.version}</version> |
||||
</dependency> |
||||
|
||||
<!-- MongoDB dependencies --> |
||||
<dependency> |
||||
<groupId>org.mongodb</groupId> |
||||
<artifactId>mongo-java-driver</artifactId> |
||||
<version>1.4</version> |
||||
</dependency> |
||||
|
||||
<!-- Spring dependencies --> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>org.springframework.core</artifactId> |
||||
<version>${spring.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>org.springframework.test</artifactId> |
||||
<version>${spring.version}</version> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>org.springframework.context</artifactId> |
||||
<version>${spring.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>org.springframework.transaction</artifactId> |
||||
<version>${spring.version}</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<version>2.0.2</version> |
||||
<configuration> |
||||
<source>1.5</source> |
||||
<target>1.5</target> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
||||
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
/* |
||||
* 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.document; |
||||
|
||||
/** |
||||
* Class used to map a Document to a business object. |
||||
* |
||||
* @author Thomas Risberg |
||||
* @since 1.0 |
||||
*/ |
||||
public interface DocumentMapper<D, T> { |
||||
|
||||
T mapDocument(D document); |
||||
|
||||
} |
||||
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
/* |
||||
* 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.document; |
||||
|
||||
/** |
||||
* Class used to map a business object to an object providing the source data for a Document. |
||||
* |
||||
* @author Thomas Risberg |
||||
* @since 1.0 |
||||
*/ |
||||
public interface DocumentSource<D, T> { |
||||
|
||||
D getDocument(T source); |
||||
|
||||
} |
||||
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
/* |
||||
* 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.document.mongodb; |
||||
|
||||
import org.springframework.beans.factory.FactoryBean; |
||||
import org.springframework.beans.factory.InitializingBean; |
||||
|
||||
import com.mongodb.DB; |
||||
import com.mongodb.Mongo; |
||||
|
||||
import org.apache.commons.logging.Log; |
||||
import org.apache.commons.logging.LogFactory; |
||||
|
||||
/** |
||||
* Convenient factory for configuring MongoDB. |
||||
* |
||||
* @author Thomas Risberg |
||||
* @since 1.0 |
||||
*/ |
||||
public class MongoDbFactoryBean implements FactoryBean<DB>, InitializingBean { |
||||
|
||||
/** |
||||
* Logger, available to subclasses. |
||||
*/ |
||||
protected final Log logger = LogFactory.getLog(getClass()); |
||||
|
||||
private Mongo mongo; |
||||
private String databaseName; |
||||
|
||||
public void setMongo(Mongo mongo) { |
||||
this.mongo = mongo; |
||||
} |
||||
|
||||
public void setDatabaseName(String databaseName) { |
||||
this.databaseName = databaseName; |
||||
} |
||||
|
||||
public DB getObject() throws Exception { |
||||
return mongo.getDB(databaseName); |
||||
} |
||||
|
||||
public Class<? extends DB> getObjectType() { |
||||
return DB.class; |
||||
} |
||||
|
||||
public boolean isSingleton() { |
||||
return false; |
||||
} |
||||
|
||||
public void afterPropertiesSet() throws Exception { |
||||
if (databaseName == null) { |
||||
logger.warn("Property databaseName not specified. Using default name 'test'"); |
||||
databaseName = "test"; |
||||
} |
||||
if (mongo == null) { |
||||
logger.warn("Property mongo not specified. Using default configuration"); |
||||
mongo = new Mongo(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue