public class ScriptContextImpl extends Object implements ScriptContext
ScriptContext| Constructor and Description |
|---|
ScriptContextImpl(File root)
Creates new scriptcontext with given root file
|
ScriptContextImpl(File root,
ScriptContext parent)
Creates new ScriptContext with given file as root and another
ScriptContext as parent
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChildScriptContext(ScriptContext context)
Adds child contexts to this context.
|
boolean |
equals(Object obj)
Tests if this ScriptContext is equal to another ScriptContext.
|
void |
finalize()
This method overrides finalization to ensure that active script context
will not be collected by GC.
|
Collection<ScriptContext> |
getChildScriptContexts()
Returns list of child contexts or null if no contextes present
|
ClassListener |
getClassListener()
Returns class listener associated with this ScriptContext.
|
CompilationResult |
getCompilationResult()
Returns compilation result of this script context
|
String |
getCompilerClassName()
Returns compiler class name that will be used for this script context.
|
Iterable<File> |
getLibraries()
Returns list of files that are used as libraries for this script context
|
ScriptContext |
getParentScriptContext()
Returns parent script context of this context.
|
File |
getRoot()
Returns the root directory for script engine.
|
int |
hashCode()
Returns hashCoded of this ScriptContext.
|
void |
init()
Initializes script context.
|
protected ScriptCompiler |
instantiateCompiler()
Creates new instance of ScriptCompiler that should be used with this
ScriptContext
|
boolean |
isInitialized()
Returns true if this script context is loaded
|
void |
reload()
Invokes
ScriptContext.shutdown(), after that invokes ScriptContext.init(). |
void |
setClassListener(ClassListener cl)
Sets the class listener for this script context.
|
void |
setCompilerClassName(String className)
Sets compiler class name for this script context.
|
void |
setLibraries(Iterable<File> files)
Sets files that represents jar files, they will be used as libraries
|
void |
shutdown()
Notifies all script classes that they must save their data and release
resources to prevent memory leaks.
|
public ScriptContextImpl(File root)
root - file that represents root directory of this script contextNullPointerException - if root is nullIllegalArgumentException - if root directory doesn't exists or is not a directorypublic ScriptContextImpl(File root, ScriptContext parent)
root - file that represents root directory of this script contextparent - parent ScriptContex. It's classes and libraries will be
accessible for this script contextNullPointerException - if root is nullIllegalArgumentException - if root directory doesn't exists or is not a directorypublic void init()
OnClassLoad are invokedinit in interface ScriptContextpublic void shutdown()
OnClassUnload annotationshutdown in interface ScriptContextpublic void reload()
ScriptContext.shutdown(), after that invokes ScriptContext.init(). Root
folder remains the same, but new compiler and classloader are used.reload in interface ScriptContextpublic File getRoot()
getRoot in interface ScriptContextpublic CompilationResult getCompilationResult()
getCompilationResult in interface ScriptContextpublic boolean isInitialized()
isInitialized in interface ScriptContextpublic void setLibraries(Iterable<File> files)
setLibraries in interface ScriptContextfiles - that points to jar file, will be used as librariespublic Iterable<File> getLibraries()
getLibraries in interface ScriptContextpublic ScriptContext getParentScriptContext()
getParentScriptContext in interface ScriptContextpublic Collection<ScriptContext> getChildScriptContexts()
getChildScriptContexts in interface ScriptContextpublic void addChildScriptContext(ScriptContext context)
ScriptContext.init() would be
called. Duplicated child contexts are not allowed, in such case child
will be ignoredaddChildScriptContext in interface ScriptContextcontext - child contextpublic void setClassListener(ClassListener cl)
setClassListener in interface ScriptContextcl - class listenerpublic ClassListener getClassListener()
AggregatedClassListener acl = new AggregatedClassListener(); acl.addClassListener(new OnClassLoadUnloadListener()); acl.addClassListener(new ScheduledTaskClassListener());
getClassListener in interface ScriptContextAggregatedClassListener,
ScheduledTaskClassListenerpublic void setCompilerClassName(String className)
setCompilerClassName in interface ScriptContextclassName - compiler class namepublic String getCompilerClassName()
getCompilerClassName in interface ScriptContextprotected ScriptCompiler instantiateCompiler() throws RuntimeException
RuntimeException - if failed to create instancepublic boolean equals(Object obj)
equals in interface ScriptContextequals in class Objectobj - object to compare withpublic int hashCode()
hashCode in interface ScriptContexthashCode in class Objectpublic void finalize()
throws Throwable
ScriptContext.shutdown() is called to ensure that resources were released.finalize in interface ScriptContextfinalize in class ObjectThrowable - if something goes wrong during finalizationCopyright © 2014–2015. All rights reserved.