|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.core.base.Adaptee org.norther.tammi.core.base.DefaultObjectFactory<org.apache.bsf.BSFEngine> 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 |
Constructor Summary | |
---|---|
DefaultScripter()
Constructs a new scripter. |
Method Summary | |
---|---|
Object |
apply(File file,
List<String> paramNames,
List<Object> arguments)
Applies a function. |
Object |
apply(String path,
List<String> paramNames,
List<Object> arguments)
Applies a function. |
Object |
apply(String lang,
String source,
InputStream input,
List<String> paramNames,
List<Object> arguments)
Applies a function. |
Object |
apply(String lang,
String source,
int lineNo,
int columnNo,
Object funcBody,
List<String> paramNames,
List<Object> 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<String> paramNames,
List<Object> arguments)
Applies a function. |
Object |
apply(String lang,
String source,
Reader reader,
List<String> paramNames,
List<Object> arguments)
Applies a function. |
Object |
apply(URL url,
List<String> paramNames,
List<Object> arguments)
Applies a function. |
void |
compileApply(String lang,
String source,
int lineNo,
int columnNo,
Object funcBody,
List<String> paramNames,
List<Object> 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. |
org.apache.bsf.BSFEngine |
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 ScriptManager |
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 Manageable
postmanaged
in class Adaptee
public void unmanaged() throws Exception
Manageable
unmanaged
in interface Manageable
unmanaged
in class Adaptee
Exception
- if the adaptee refused to be unmanaged.public String getScriptKey()
Scripter
getScriptKey
in interface Scripter
public void setScriptKey(String key)
Scripter
setScriptKey
in interface Scripter
key
- the path finder key.public String getDefaultLanguage()
Scripter
getDefaultLanguage
in interface Scripter
public void setDefaultLanguage(String lang)
Scripter
setDefaultLanguage
in interface Scripter
lang
- the default language.public void compileApply(String lang, String source, int lineNo, int columnNo, Object funcBody, List<String> paramNames, List<Object> arguments, ScriptCodeBuffer cb) throws LogException
Scripter
compileApply
in interface Scripter
lang
- 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 Scripter
lang
- 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 Scripter
lang
- 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<String> paramNames, List<Object> arguments) throws LogException
Scripter
apply
in interface Scripter
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(String key, String path, List<String> paramNames, List<Object> arguments) throws LogException
Scripter
apply
in interface Scripter
key
- 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<String> paramNames, List<Object> arguments) throws LogException
Scripter
apply
in interface Scripter
file
- 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<String> paramNames, List<Object> arguments) throws LogException
Scripter
apply
in interface Scripter
url
- 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<String> paramNames, List<Object> arguments) throws LogException
Scripter
apply
in interface Scripter
lang
- 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<String> paramNames, List<Object> arguments) throws LogException
Scripter
apply
in interface Scripter
lang
- 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<String> paramNames, List<Object> arguments) throws LogException
Scripter
apply
in interface Scripter
lang
- 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 Scripter
path
- 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 Scripter
key
- 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 Scripter
file
- a file or folder of files to evaluate.
LogException
- on errors.public Object evaluate(URL url) throws LogException
Scripter
evaluate
in interface Scripter
url
- a URL to evaluate.
LogException
- on errors.public Object evaluate(String lang, String source, InputStream input) throws LogException
Scripter
evaluate
in interface Scripter
lang
- 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 Scripter
lang
- 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 Scripter
lang
- 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 Scripter
path
- 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 Scripter
key
- 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 Scripter
file
- a file or folder of files to execute.
LogException
- on errors.public void execute(URL url) throws LogException
Scripter
execute
in interface Scripter
url
- a URL to execute.
LogException
- on errors.public void execute(String lang, String source, InputStream input) throws LogException
Scripter
execute
in interface Scripter
lang
- 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 Scripter
lang
- 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 Scripter
lang
- 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 Scripter
public void setClassLoader(ClassLoader classLoader)
Scripter
setClassLoader
in interface Scripter
classLoader
- the class loader.public String getClassPath()
Scripter
getClassPath
in interface Scripter
public void setClassPath(String classPath)
Scripter
setClassPath
in interface Scripter
classPath
- the class path.public ScriptObjectRegistry getObjectRegistry()
Scripter
getObjectRegistry
in interface Scripter
public void setObjectRegistry(ScriptObjectRegistry objectRegistry)
Scripter
setObjectRegistry
in interface Scripter
objectRegistry
- the object registry.public String getTempDir()
Scripter
getTempDir
in interface Scripter
public void setTempDir(String tempDir)
Scripter
setTempDir
in interface Scripter
tempDir
- the temp directory.public String getLangFromFilename(String fileName)
Scripter
getLangFromFilename
in interface Scripter
fileName
- the name of the file.
public boolean isLanguageRegistered(String lang)
Scripter
isLanguageRegistered
in interface Scripter
lang
- the language.
public void registerScriptingEngine(String lang, String engineClassName, String[] extensions)
Scripter
registerScriptingEngine
in interface Scripter
lang
- the language.engineClassName
- the engine class name.extensions
- an array of extensions.public boolean isLanguageLoadable(String lang)
Scripter
isLanguageLoadable
in interface Scripter
lang
- the language.
public org.apache.bsf.BSFEngine loadScriptingEngine(String lang) throws LogException
Scripter
loadScriptingEngine
in interface Scripter
lang
- the language.
LogException
- on errors.public Object lookupBean(String beanName)
Scripter
lookupBean
in interface Scripter
beanName
- the name of the MBean.
public void registerBean(String beanName, Object bean)
Scripter
registerBean
in interface Scripter
beanName
- the name of the bean.bean
- the bean object.public void unregisterBean(String beanName)
Scripter
unregisterBean
in interface Scripter
beanName
- the name of the bean.public void declareBean(String beanName, Object bean, Class<?> type) throws LogException
Scripter
Declared beans are also registered.
declareBean
in interface Scripter
beanName
- the name of the bean.bean
- the bean object.type
- the class.
LogException
- on errors.public void undeclareBean(String beanName) throws LogException
Scripter
undeclareBean
in interface Scripter
beanName
- the name of the bean.
LogException
- on errors.public void reinitialize(String lang)
Scripter
reinitialize
in interface Scripter
lang
- the language.public void reinitialize()
Scripter
reinitialize
in interface Scripter
public void terminate()
Scripter
terminate
in interface Scripter
public org.apache.bsf.BSFEngine getInstance(String className, ObjectName loader, Object[] params, String[] signature) throws ConstructionException
ObjectFactory
Class loaders are supported only if the isLoaderSupported method returns true. Otherwise the loader parameter is ignored.
getInstance
in interface ObjectFactory<org.apache.bsf.BSFEngine>
getInstance
in class DefaultObjectFactory<org.apache.bsf.BSFEngine>
className
- the name of the class.loader
- the class loader.params
- an array containing the parameters of the constructor.signature
- an array containing the signature of the constructor.
ConstructionException
- if construction fails.protected ScriptManager getManager()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |