package scalascriptengine
- Alphabetic
- Public
- All
Type Members
-
trait
CodeVersion
extends AnyRef
the script engine works by keeping 1 version of the compiled source directories.
the script engine works by keeping 1 version of the compiled source directories. Every time a script changes, a new compilation is triggered (called a "refresh") and done the current version is replaced by the new version.
-
case class
CodeVersionImpl
(version: Int, files: List[SourceFile], classLoader: ScalaClassLoader, sourceFiles: Map[File, SourceFile]) extends CodeVersion with Product with Serializable
- Attributes
- protected
- class CompilationStatus extends AnyRef
- class CompilationStopped extends RuntimeException
-
case class
Config
(sourcePaths: List[SourcePath], compilationClassPaths: Set[File] = ScalaScriptEngine.currentClassPath, classLoadingClassPaths: Set[File] = Set.empty, classLoaderConfig: ClassLoaderConfig = ClassLoaderConfig.Default, compilationListeners: List[(CodeVersion) ⇒ Unit] = Nil, parentClassLoader: ClassLoader = getClass.getClassLoader) extends Product with Serializable
this holds the configuration for the script engine.
this holds the configuration for the script engine. Source and output paths, compilation class paths, classloading classpaths . In the future it will hold scala compiler settings, error reporters and so on.
-
class
Constructors
[T] extends AnyRef
provides easy access to instance construction
-
trait
DevUseIDECompiledClassesOnly
extends ScalaScriptEngine
this is useful during development.
this is useful during development. If your IDE compiles the classes (and recompiles them), then there is no need for the script engine to recompile those. Just mixin this trait and don't call refresh (if refresh is called then it falls back to normal operation)
Note: don't use this on production or stress tests as it will reload the classes over and over again until java runs out of PermGen space.
-
trait
EvalCode
[T] extends AnyRef
a scala-code evaluator
-
trait
FromClasspathFirst
extends ScalaScriptEngine
if no code version is ready, tries to find the classes from the classpath initially.
if no code version is ready, tries to find the classes from the classpath initially. If that fails, it then goes the route of finding/compiling a scala class from the source classpaths.
If a codeversion is ready, it just uses the codeversion
This can come handy i.e. during development if your IDE compiles the dynamic scala classes and you wouldn't like to wait for the classes to be recompiled.
-
trait
Logging
extends AnyRef
logging is done via slf4j
logging is done via slf4j
- Attributes
- protected
-
trait
OnChangeRefresh
extends ScalaScriptEngine
checks scala files for modification and if yes it recompiles the changed sources.
checks scala files for modification and if yes it recompiles the changed sources. This is not to be used by client code but rather be used by the rest of the refresh policy traits.
recheckEveryMillis should be provided. If <=0 then for every request for a class, the source file of the class is checked for modifications. If >0 then maximum 1 check will be performed every recheckEveryMillis milliseconds. A sensible value might be 1000 millis if code changes frequently (i.e. during dev) and 30000 millis if code doesn't change that often (i.e. production)
- Attributes
- protected
-
trait
RefreshAsynchronously
extends ScalaScriptEngine with OnChangeRefresh
makes sure the refresh is run only once at a time.
makes sure the refresh is run only once at a time. All calls to refresh return straight away with the current code version but a compilation will be triggered if the source code changed. The compilation will occur in the background and when done, the new compiled version of the code will be used.
-
trait
RefreshSynchronously
extends ScalaScriptEngine with OnChangeRefresh
refresh as soon as a modification is detected.
refresh as soon as a modification is detected. The first thread that actually does the refresh will do the compilation and the rest of the threads will wait. All threads will get an up to date compiled version of the source code.
This is blocking during compilation and is not recommended to be used by web servers. RefreshAsynchronously offers a much better alternative.
- class SSESecurityManager extends SecurityManager
-
class
ScalaScriptEngine
extends Logging
The implementation of the script engine.
The implementation of the script engine.
The engine works by refreshing the codeVersion. This means that, when the refresh() function is called and provided that the source files have changed, a compilation will be triggered. When the compilation is complete, a new codeVersion will be created and will be used till the next refresh.
This can be initialized standalone or by mixing in a refresh policy trait. If standalone, then refresh() should be manually invoked every time a change occurs in the source code.
If mixed in with a refresh policy, then the policy takes care of scanning the source code for changes and refreshing. Please check RefreshPolicies.scala
Typically this class will not be instantiated using 'new' but rather using one of the factory methods of the companion object. Instantiation offers the full amount of options that can be used by mixing in the various refresh policies and enhancers.
val sse = new ScalaScriptEngine(Config( Set(sourceDir), compilationClassPath, runtimeClasspath, outputDir)) with RefreshAsynchronously with FromClasspathFirst { val recheckEveryMillis: Long = 1000 // each file will only be checked maximum once per second }))
- case class SourceFile (file: File) extends Product with Serializable
-
case class
SourcePath
(sources: Set[File], targetDir: File = ScalaScriptEngine.tmpOutputFolder) extends Product with Serializable
scala source folder along with the destination class folder
scala source folder along with the destination class folder
- sources
root folders of scala sources or scala files
- targetDir
root folder of generated class files
-
trait
TimedRefresh
extends AnyRef
periodically scans the source directories and if a file changed, it recompiles and creates a new CodeVersion (changes will be visible as soon as compilation completes)
Value Members
- object CompilationStatus
- object EvalCode
-
object
ScalaScriptEngine
the companion object provides a lot of useful factory methods to create a script engine with sensible defaults.
- object SourcePath extends Serializable