Accessing classes defined in a script

View: New views
1 Messages — Rating Filter:   Alert me  

Accessing classes defined in a script

by Mirko Leschikar-3 :: Rate this Message:

| View Threaded | Show Only this Message

Hi,

I am pretty new to BSF and I ran into a problem.
I have a java class "JavaClassA" and I want to extend it in a script,
Groovy or BeanShell.

...
public class BSHClassA extends JavaClassA {
    public run() {
       ...
    }
}

Without BSF and with Beanshell only, I was able to "source" the script
and access the class BSHClassA  via Beanshells' classmanager and
instantiate it in Java like this:
...
beanShell.source(scriptFile);
classLoader = beanShell.getClassManager();
Class clazz = classLoader.classForName( bshClass );
bshObj = (JavaClassA) clazz.newInstance();

How do I instantiate a class defined in a script language via BSF?
I don't know what to do after:

theBsfManager.exec(scriptLang, scriptFile, 0, 0,
IOUtils.getStringFromReader(scriptFileReader));

Thanks in advance

Mirko




---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-user-unsubscribe@...
For additional commands, e-mail: bsf-user-help@...