diff --git a/pom.xml b/pom.xml
index 93a4e6bf2a..1b2e9ec0f7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-479-SNAPSHOT
pom
Spring Data MongoDB
diff --git a/spring-data-mongodb-cross-store/pom.xml b/spring-data-mongodb-cross-store/pom.xml
index c7610beee4..e5b1c5698a 100644
--- a/spring-data-mongodb-cross-store/pom.xml
+++ b/spring-data-mongodb-cross-store/pom.xml
@@ -6,7 +6,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-479-SNAPSHOT
../pom.xml
@@ -48,7 +48,7 @@
org.springframework.data
spring-data-mongodb
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-479-SNAPSHOT
diff --git a/spring-data-mongodb-distribution/pom.xml b/spring-data-mongodb-distribution/pom.xml
index 13110137b6..11cd8642a3 100644
--- a/spring-data-mongodb-distribution/pom.xml
+++ b/spring-data-mongodb-distribution/pom.xml
@@ -13,7 +13,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-479-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb-log4j/pom.xml b/spring-data-mongodb-log4j/pom.xml
index 6ff09e4577..d2fbaba86c 100644
--- a/spring-data-mongodb-log4j/pom.xml
+++ b/spring-data-mongodb-log4j/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-479-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml
index 7c2d818c42..58ad80e3ba 100644
--- a/spring-data-mongodb/pom.xml
+++ b/spring-data-mongodb/pom.xml
@@ -11,7 +11,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-479-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultScriptOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultScriptOperations.java
new file mode 100644
index 0000000000..44bf3a70c6
--- /dev/null
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultScriptOperations.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2014 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.data.mongodb.core;
+
+import static java.util.UUID.*;
+import static org.springframework.data.mongodb.core.query.Criteria.*;
+import static org.springframework.data.mongodb.core.query.Query.*;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.bson.types.ObjectId;
+import org.springframework.dao.DataAccessException;
+import org.springframework.data.mongodb.core.script.CallableMongoScript;
+import org.springframework.data.mongodb.core.script.ServerSideJavaScript;
+import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
+
+import com.mongodb.DB;
+import com.mongodb.MongoException;
+
+/**
+ * Default implementation of {@link ScriptOperations} capable of saving and executing {@link ServerSideJavaScript}.
+ *
+ * @author Christoph Strobl
+ * @since 1.7
+ */
+public class DefaultScriptOperations implements ScriptOperations {
+
+ private static final String SCRIPT_COLLECTION_NAME = "system.js";
+ private static final String SCRIPT_NAME_PREFIX = "func_";
+ private final MongoOperations mongoOperations;
+
+ /**
+ * Creates new {@link DefaultScriptOperations} using given {@link MongoOperations}.
+ *
+ * @param mongoOperations must not be {@literal null}.
+ */
+ public DefaultScriptOperations(MongoOperations mongoOperations) {
+
+ Assert.notNull(mongoOperations, "MongoOperations must not be null!");
+
+ this.mongoOperations = mongoOperations;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.mongodb.core.ScriptOperations#save(org.springframework.data.mongodb.core.script.MongoScript)
+ */
+ @Override
+ public CallableMongoScript register(ServerSideJavaScript script) {
+
+ Assert.notNull(script, "Script must not be null!");
+
+ CallableMongoScript callableScript = (script instanceof CallableMongoScript) ? (CallableMongoScript) script
+ : new CallableMongoScript(generateScriptName(), script);
+ mongoOperations.save(callableScript, SCRIPT_COLLECTION_NAME);
+ return callableScript;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.mongodb.core.ScriptOperations#execute(org.springframework.data.mongodb.core.script.MongoScript, java.lang.Object[])
+ */
+ @Override
+ public Object execute(final ServerSideJavaScript script, final Object... args) {
+
+ Assert.notNull(script, "Script must not be null!");
+
+ if (script instanceof CallableMongoScript) {
+ return call(((CallableMongoScript) script).getName(), args);
+ }
+
+ return mongoOperations.execute(new DbCallback