|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.norther.tammi.core.base.Adaptee
org.norther.tammi.core.base.DefaultObjectFactory
org.norther.tammi.core.scripter.DefaultScripter
public class DefaultScripter
A default implementation of Scripter.
| Field Summary |
|---|
| Fields inherited from class org.norther.tammi.core.base.Adaptee |
|---|
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS |
| Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate |
|---|
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE |
| Constructor Summary | |
|---|---|
DefaultScripter()
Constructs a new scripter. |
|
| Method Summary | |
|---|---|
Object |
apply(File file,
List paramNames,
List arguments)
Applies a function. |
Object |
apply(String path,
List paramNames,
List arguments)
Applies a function. |
Object |
apply(String lang,
String source,
InputStream input,
List paramNames,
List arguments)
Applies a function. |
Object |
apply(String lang,
String source,
int lineNo,
int columnNo,
Object funcBody,
List paramNames,
List arguments)
Applies the given anonymous function of the given language to the given parameters and returns the resulting value. |
Object |
apply(String key,
String path,
List paramNames,
List arguments)
Applies a function. |
Object |
apply(String lang,
String source,
Reader reader,
List paramNames,
List arguments)
Applies a function. |
Object |
apply(URL url,
List paramNames,
List arguments)
Applies a function. |
void |
compileApply(String lang,
String source,
int lineNo,
int columnNo,
Object funcBody,
List paramNames,
List arguments,
ScriptCodeBuffer cb)
Compiles the application of the given anonymous function of the given language to the given parameters into the given code buffer. |
void |
compileExpr(String lang,
String source,
int lineNo,
int columnNo,
Object expr,
ScriptCodeBuffer cb)
Compiles the given expression of the given language into the given code buffer. |
void |
compileScript(String lang,
String source,
int lineNo,
int columnNo,
Object script,
ScriptCodeBuffer cb)
Compiles the given script of the given language into the given code buffer. |
void |
declareBean(String beanName,
Object bean,
Class type)
Declares a bean. |
Object |
evaluate(File file)
Evaluates an expression. |
Object |
evaluate(String path)
Evaluates an expression. |
Object |
evaluate(String key,
String path)
Evaluates an expression. |
Object |
evaluate(String lang,
String source,
InputStream input)
Evaluates an expression. |
Object |
evaluate(String lang,
String source,
int lineNo,
int columnNo,
Object expr)
Evaluates the given expression in the given language and returns the resulting value. |
Object |
evaluate(String lang,
String source,
Reader reader)
Evaluates an expression. |
Object |
evaluate(URL url)
Evaluates an expression. |
void |
execute(File file)
Executes a script. |
void |
execute(String path)
Executes a script. |
void |
execute(String key,
String path)
Executes a script. |
void |
execute(String lang,
String source,
InputStream input)
Executes a script. |
void |
execute(String lang,
String source,
int lineNo,
int columnNo,
Object script)
Executes the given script in the given language. |
void |
execute(String lang,
String source,
Reader reader)
Executes a script. |
void |
execute(URL url)
Executes a script. |
ClassLoader |
getClassLoader()
Gets the class loader. |
String |
getClassPath()
Gets the classpath. |
String |
getDefaultLanguage()
Gets the default script language. |
Object |
getInstance(String className,
ObjectName loader,
Object[] params,
String[] signature)
Gets an instance of a named class using a specified class loader. |
String |
getLangFromFilename(String fileName)
Determines the language of a script file by looking at the file extension. |
protected org.norther.tammi.core.scripter.DefaultScripter.InternalManager |
getManager()
Gets the implementation of the manager. |
ScriptObjectRegistry |
getObjectRegistry()
Returns the current object registry of the manager. |
String |
getScriptKey()
Gets the path finder key for resolving script paths. |
String |
getTempDir()
Gets the temporary directory. |
boolean |
isLanguageLoadable(String lang)
Checks whether a scripting engine for the specified language is registered and loadable. |
boolean |
isLanguageRegistered(String lang)
Determines whether a language is registered. |
org.apache.bsf.BSFEngine |
loadScriptingEngine(String lang)
Loads a scripting engine based on the lang string identifying it. |
Object |
lookupBean(String beanName)
Returns a handle to a declared MBean. |
void |
postmanaged()
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time. |
void |
registerBean(String beanName,
Object bean)
Registers a bean allowing a scripting engine or the application to access that bean by name and to manipulate it. |
void |
registerScriptingEngine(String lang,
String engineClassName,
String[] extensions)
Registers a scripting engine in the static registry of the BSFManager. |
void |
reinitialize()
Reinitializes all engines ignoring exceptions. |
void |
reinitialize(String lang)
Reinitializes an engine of the specified language. |
void |
setClassLoader(ClassLoader classLoader)
Sets the class loader for those that need to use it. |
void |
setClassPath(String classPath)
Sets the classpath for those that need to use it. |
void |
setDefaultLanguage(String lang)
Sets the default script language. |
void |
setObjectRegistry(ScriptObjectRegistry objectRegistry)
Sets the object registry used by this manager. |
void |
setScriptKey(String key)
Sets the path finder key for resolving script paths. |
void |
setTempDir(String tempDir)
Sets the temporary directory to put stuff into (for those who need to). |
void |
terminate()
Gracefully terminates all engines |
void |
undeclareBean(String beanName)
Undeclares a previously declared bean. |
void |
unmanaged()
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time. |
void |
unregisterBean(String beanName)
Unregisters a previously registered bean. |
| Methods inherited from class org.norther.tammi.core.base.DefaultObjectFactory |
|---|
getInstance, getInstance, getInstance, isLoaderSupported |
| Methods inherited from class org.norther.tammi.core.base.Adaptee |
|---|
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.norther.tammi.core.base.ObjectFactory |
|---|
getInstance, getInstance, getInstance, isLoaderSupported |
| Constructor Detail |
|---|
public DefaultScripter()
| Method Detail |
|---|
public void postmanaged()
Manageable
postmanaged in interface Manageablepostmanaged in class Adaptee
public void unmanaged()
throws Exception
Manageable
unmanaged in interface Manageableunmanaged in class AdapteeException - if the adaptee refused to be unmanaged.public String getScriptKey()
Scripter
getScriptKey in interface Scripterpublic void setScriptKey(String key)
Scripter
setScriptKey in interface Scripterkey - the path finder key.public String getDefaultLanguage()
Scripter
getDefaultLanguage in interface Scripterpublic void setDefaultLanguage(String lang)
Scripter
setDefaultLanguage in interface Scripterlang - the default language.
public void compileApply(String lang,
String source,
int lineNo,
int columnNo,
Object funcBody,
List paramNames,
List arguments,
ScriptCodeBuffer cb)
throws LogException
Scripter
compileApply in interface Scripterlang - the language.source - the source.lineNo - the line number.columnNo - the column number.funcBody - the body of the function.paramNames - the names of parameters.arguments - the values of parameters.cb - a code buffer.
LogException - on errors.
public void compileExpr(String lang,
String source,
int lineNo,
int columnNo,
Object expr,
ScriptCodeBuffer cb)
throws LogException
Scripter
compileExpr in interface Scripterlang - the language.source - the source.lineNo - the line number.columnNo - the column number.expr - the expression.cb - a code buffer.
LogException - on errors.
public void compileScript(String lang,
String source,
int lineNo,
int columnNo,
Object script,
ScriptCodeBuffer cb)
throws LogException
Scripter
compileScript in interface Scripterlang - the language.source - the source.lineNo - the line number.columnNo - the column number.script - the script.cb - a code buffer.
LogException - on errors.
public Object apply(String path,
List paramNames,
List arguments)
throws LogException
Scripter
apply in interface Scripterpath - a path to a file or to folder of files to apply.paramNames - the names of parameters.arguments - the values of parameters.
LogException - on errors.
public Object apply(String key,
String path,
List paramNames,
List arguments)
throws LogException
Scripter
apply in interface Scripterkey - a path finder key.path - a path to a file or to folder of files to apply.paramNames - the names of parameters.arguments - the values of parameters.
LogException - on errors.
public Object apply(File file,
List paramNames,
List arguments)
throws LogException
Scripter
apply in interface Scripterfile - a file or folder of files to evaluate.paramNames - the names of parameters.arguments - the values of parameters.
LogException - on errors.
public Object apply(URL url,
List paramNames,
List arguments)
throws LogException
Scripter
apply in interface Scripterurl - a URL to evaluate.paramNames - the names of parameters.arguments - the values of parameters.
LogException - on errors.
public Object apply(String lang,
String source,
InputStream input,
List paramNames,
List arguments)
throws LogException
Scripter
apply in interface Scripterlang - the language of the stream.source - the source of the stream.input - a stream to apply.paramNames - the names of parameters.arguments - the values of parameters.
LogException - on errors.
public Object apply(String lang,
String source,
Reader reader,
List paramNames,
List arguments)
throws LogException
Scripter
apply in interface Scripterlang - the language of the reader.source - the source of the reader.reader - a reader to apply.paramNames - the names of parameters.arguments - the values of parameters.
LogException - on errors.
public Object apply(String lang,
String source,
int lineNo,
int columnNo,
Object funcBody,
List paramNames,
List arguments)
throws LogException
Scripter
apply in interface Scripterlang - the language.source - the source.lineNo - the line number.columnNo - the column number.funcBody - the body of the function.paramNames - the names of parameters.arguments - the values of parameters.
LogException - on errors.
public Object evaluate(String path)
throws LogException
Scripter
evaluate in interface Scripterpath - a path to a file or to folder of files to evaluate.
LogException - on errors.
public Object evaluate(String key,
String path)
throws LogException
Scripter
evaluate in interface Scripterkey - a path finder key.path - a path to a file or to folder of files to evaluate.
LogException - on errors.
public Object evaluate(File file)
throws LogException
Scripter
evaluate in interface Scripterfile - a file or folder of files to evaluate.
LogException - on errors.
public Object evaluate(URL url)
throws LogException
Scripter
evaluate in interface Scripterurl - a URL to evaluate.
LogException - on errors.
public Object evaluate(String lang,
String source,
InputStream input)
throws LogException
Scripter
evaluate in interface Scripterlang - the language of the stream.source - the source of the stream.input - a stream to evaluate.
LogException - on errors.
public Object evaluate(String lang,
String source,
Reader reader)
throws LogException
Scripter
evaluate in interface Scripterlang - the language of the reader.source - the source of the reader.reader - a reader to evaluate.
LogException - on errors.
public Object evaluate(String lang,
String source,
int lineNo,
int columnNo,
Object expr)
throws LogException
Scripter
evaluate in interface Scripterlang - the language.source - the source.lineNo - the line number.columnNo - the column number.expr - the expression.
LogException - on errors.
public void execute(String path)
throws LogException
Scripter
execute in interface Scripterpath - a path to a file or to folder of files to execute.
LogException - on errors.
public void execute(String key,
String path)
throws LogException
Scripter
execute in interface Scripterkey - a path finder key.path - a path to a file or to folder of files to execute.
LogException - on errors.
public void execute(File file)
throws LogException
Scripter
execute in interface Scripterfile - a file or folder of files to execute.
LogException - on errors.
public void execute(URL url)
throws LogException
Scripter
execute in interface Scripterurl - a URL to execute.
LogException - on errors.
public void execute(String lang,
String source,
InputStream input)
throws LogException
Scripter
execute in interface Scripterlang - the language of the stream.source - the source of the stream.input - a stream to execute.
LogException - on errors.
public void execute(String lang,
String source,
Reader reader)
throws LogException
Scripter
execute in interface Scripterlang - the language of the reader.source - the source of the reader.reader - a reader to execute.
LogException - on errors.
public void execute(String lang,
String source,
int lineNo,
int columnNo,
Object script)
throws LogException
Scripter
execute in interface Scripterlang - the language.source - the source.lineNo - the line number.columnNo - the column number.script - the script.
LogException - on errors.public ClassLoader getClassLoader()
Scripter
getClassLoader in interface Scripterpublic void setClassLoader(ClassLoader classLoader)
Scripter
setClassLoader in interface ScripterclassLoader - the class loader.public String getClassPath()
Scripter
getClassPath in interface Scripterpublic void setClassPath(String classPath)
Scripter
setClassPath in interface ScripterclassPath - the class path.public ScriptObjectRegistry getObjectRegistry()
Scripter
getObjectRegistry in interface Scripterpublic void setObjectRegistry(ScriptObjectRegistry objectRegistry)
Scripter
setObjectRegistry in interface ScripterobjectRegistry - the object registry.public String getTempDir()
Scripter
getTempDir in interface Scripterpublic void setTempDir(String tempDir)
Scripter
setTempDir in interface ScriptertempDir - the temp directory.public String getLangFromFilename(String fileName)
Scripter
getLangFromFilename in interface ScripterfileName - the name of the file.
public boolean isLanguageRegistered(String lang)
Scripter
isLanguageRegistered in interface Scripterlang - the language.
public void registerScriptingEngine(String lang,
String engineClassName,
String[] extensions)
Scripter
registerScriptingEngine in interface Scripterlang - the language.engineClassName - the engine class name.extensions - an array of extensions.public boolean isLanguageLoadable(String lang)
Scripter
isLanguageLoadable in interface Scripterlang - the language.
public org.apache.bsf.BSFEngine loadScriptingEngine(String lang)
throws LogException
Scripter
loadScriptingEngine in interface Scripterlang - the language.
LogException - on errors.public Object lookupBean(String beanName)
Scripter
lookupBean in interface ScripterbeanName - the name of the MBean.
public void registerBean(String beanName,
Object bean)
Scripter
registerBean in interface ScripterbeanName - the name of the bean.bean - the bean object.public void unregisterBean(String beanName)
Scripter
unregisterBean in interface ScripterbeanName - the name of the bean.
public void declareBean(String beanName,
Object bean,
Class type)
throws LogException
ScripterDeclared beans are also registered.
declareBean in interface ScripterbeanName - the name of the bean.bean - the bean object.type - the class.
LogException - on errors.public void undeclareBean(String be