Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix problem of hot-reload

  • Loading branch information...
commit 977aa9ee0cab1c64e0bdc0e61dc7756f8a77b737 1 parent 24f7061
@leodagdag authored
View
4 project/Build.scala
@@ -12,7 +12,7 @@ object Play2MorphiaPluginBuild extends Build {
file("."),
settings = buildSettings ++ Seq(
libraryDependencies := runtime ++ test,
- publishMavenStyle := true,
+ publishMavenStyle := false,
publishTo := Some(githubRepository),
scalacOptions ++= Seq("-Xlint","-deprecation", "-unchecked","-encoding", "utf8"),
javacOptions ++= Seq("-encoding", "utf8", "-g"),
@@ -49,7 +49,7 @@ object Play2MorphiaPluginBuild extends Build {
object BuildSettings {
val buildOrganization = "leodagdag"
- val buildVersion = "0.0.10"
+ val buildVersion = "0.0.11"
val buildScalaVersion = "2.9.1"
val buildSbtVersion = "0.11.3"
val buildSettings = Defaults.defaultSettings ++ Seq (
View
9 src/main/java/leodagdag/play2morphia/MorphiaPlugin.java
@@ -9,10 +9,7 @@
import com.google.code.morphia.validation.MorphiaValidation;
import com.mongodb.*;
import com.mongodb.gridfs.GridFS;
-import leodagdag.play2morphia.utils.ConfigKey;
-import leodagdag.play2morphia.utils.Constants;
-import leodagdag.play2morphia.utils.MorphiaLogger;
-import leodagdag.play2morphia.utils.StringUtils;
+import leodagdag.play2morphia.utils.*;
import play.Application;
import play.Configuration;
import play.Plugin;
@@ -77,6 +74,10 @@ public void onStart() {
}
morphia = new Morphia();
+ // To prevent problem during hot-reload
+ if (application.isDev()) {
+ morphia.getMapper().getOptions().objectFactory = new PlayCreator();
+ }
// Configure validator
MorphiaValidation morphiaValidation = new MorphiaValidation();
morphiaValidation.applyTo(morphia);
View
13 src/main/java/leodagdag/play2morphia/utils/PlayCreator.java
@@ -0,0 +1,13 @@
+package leodagdag.play2morphia.utils;
+
+import com.google.code.morphia.mapping.DefaultCreator;
+import com.mongodb.DBObject;
+import play.Play;
+
+public class PlayCreator extends DefaultCreator {
+
+ @Override
+ protected ClassLoader getClassLoaderForClass(String clazz, DBObject object) {
+ return Play.application().classloader();
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.