@@ -51,16 +51,11 @@ class ScalaVerticleFactory extends VerticleFactory {
51
51
52
52
private var loader : ClassLoader = null
53
53
54
- private var interpreter : ScalaInterpreter = null
55
-
56
54
override def init (jvertx : JVertx , jcontainer : JContainer , aloader : ClassLoader ): Unit = {
57
55
this .loader = aloader
58
56
59
57
vertx = Vertx (jvertx)
60
58
container = new Container (jcontainer)
61
- val settings = interpreterSettings()
62
- interpreter = new ScalaInterpreter (
63
- settings.get, vertx, container, new LogPrintWriter (logger))
64
59
}
65
60
66
61
@ throws(classOf [Exception ])
@@ -91,11 +86,15 @@ class ScalaVerticleFactory extends VerticleFactory {
91
86
}
92
87
93
88
def close (): Unit = {
94
- interpreter.close()
95
89
}
96
90
97
91
private def load (main : String ): Try [Verticle ] = {
98
- runAsScript(main).recoverWith { case _ =>
92
+
93
+ val settings = interpreterSettings()
94
+ val interpreter = new ScalaInterpreter (
95
+ settings.get, vertx, container, new LogPrintWriter (logger))
96
+
97
+ runAsScript(main, interpreter).recoverWith { case _ =>
99
98
// Recover by trying to compile it as a Scala class
100
99
logger.info(s " Script contains compilation errors, or $main is a Scala class (pass -Dvertx.scala.interpreter.verbose=true to find out more) " )
101
100
logger.info(s " Compiling as a Scala class " )
@@ -113,7 +112,7 @@ class ScalaVerticleFactory extends VerticleFactory {
113
112
}
114
113
}
115
114
116
- private def runAsScript (main : String ): Try [Verticle ] = {
115
+ private def runAsScript (main : String , interpreter : ScalaInterpreter ): Try [Verticle ] = {
117
116
logger.info(s " Compiling $main as Scala script " )
118
117
// Try running it as a script
119
118
for {
0 commit comments