You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bsf-user@jakarta.apache.org by Rainer Hahnekamp <ra...@aon.at> on 2004/10/30 23:44:41 UTC

general questions

Hello everybody,

I am about to write an application, which core's functionality depends on BSF. 
The app uses a lot of different libraries and thats where the problem begins:
-As far as I know, your only chance to access some objects within the Java 
scope you have to instantiate these objects and register them to the 
BSFManager. But what should I do, if I have here a class with static methods 
that cannot be instantiated like the System class in java.lang??
-In my application the script code needs access to the OpenOffice API, which 
has - as you can surely imagine - a lot of classes. Must I really instantiate 
and register all of them (they will certainly be needed in some cases) or is 
there another way? If not I think that there should be a mechanism in BSF 
where the script has access to all libraries in the CLASSPATH of the host app 
without needing to register them.

I hope you can give me some answers and thank you in advance.

Greetings,
-Rainer Hahnekamp

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


Re: general questions

Posted by Rainer Hahnekamp <ra...@aon.at>.
Thank you very very much. That was the solution.

Greetings,
-Rainer Hahnekamp

Am Sonntag, 31. Oktober 2004 14:34 schrieb Ulf Dittmer:
> You need to use the syntax "new Packages.org.jdom.input.SAXBuilder()"
> instead. The ScriptingJava.html page of the Rhino documentation
> explains why. Only the java.* hierarchy can be accessed w/o the
> "Packages." prefix. All classes in your classpath should be accessible
> in this way.

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


Re: general questions

Posted by Ulf Dittmer <ul...@ulfdittmer.com>.
You need to use the syntax "new Packages.org.jdom.input.SAXBuilder()" 
instead. The ScriptingJava.html page of the Rhino documentation 
explains why. Only the java.* hierarchy can be accessed w/o the 
"Packages." prefix. All classes in your classpath should be accessible 
in this way.

Ulf


On 31.10.2004, at 02:02, Rainer Hahnekamp wrote:

> Hi,
> thank you very much for your quick answer.
>
> Unfortunately I think, that you misunderstood me a little bit. So let 
> me try
> to explain my problem in more detail with following example:
> I want to make use of the jdom-library in my script code. So the first 
> row of
> the javascript-code would be:
>
> sax = new org.jdom.input.SAXBuilder();
>
> By executing this code I get the error message: 
> "org.apache.bsf.BSFException:
> JavaScript Error: Internal Error: undefined: "org" is not defined."
>
> I assume that I can only access the standard java api as you did in 
> your
> mentioned example scripedui with the AWT Objects. But if I want to use 
> some
> functionality of an external library I have to do the 
> instantiate&register
> process, which would be - in my case (OpenOffice API & jdom) - an 
> impossible
> work.
>
> Greetings,
> -Rainer Hahnekamp


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


Re: general questions

Posted by Rainer Hahnekamp <ra...@aon.at>.
Hi,
thank you very much for your quick answer.

Unfortunately I think, that you misunderstood me a little bit. So let me try 
to explain my problem in more detail with following example:
I want to make use of the jdom-library in my script code. So the first row of 
the javascript-code would be:

sax = new org.jdom.input.SAXBuilder();

By executing this code I get the error message: "org.apache.bsf.BSFException: 
JavaScript Error: Internal Error: undefined: "org" is not defined."

I assume that I can only access the standard java api as you did in your 
mentioned example scripedui with the AWT Objects. But if I want to use some 
functionality of an external library I have to do the instantiate&register 
process, which would be - in my case (OpenOffice API & jdom) - an impossible 
work.

Greetings,
-Rainer Hahnekamp

On Sunday, 31. October 2004 00:49 Ulf Dittmer wrote:
> Hi-
>
> Maybe I misunderstand what you're trying to accomplish, but the
> instantiation and registering should only be necessary if the host app
> wants to make particular objects -which originate in the host-
> available to the script. If the objects don't have to originate in the
> host (because the host needn't access them), you should be able to
> create them in your script. How exacly that's done depends a bit on
> which scripting language you're using. Take a look at the "scriptedui"
> example that comes with BSF: the Java host registers a bean, but
> several more Java objects -which the host needn't care about- are
> instantiated in the script (e.g., ui.js for JavaScript).
>
> Hope this helps.
>
> Ulf
>

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


Re: general questions

Posted by Ulf Dittmer <ul...@ulfdittmer.com>.
Hi-

Maybe I misunderstand what you're trying to accomplish, but the 
instantiation and registering should only be necessary if the host app 
wants to make particular objects -which originate in the host- 
available to the script. If the objects don't have to originate in the 
host (because the host needn't access them), you should be able to 
create them in your script. How exacly that's done depends a bit on 
which scripting language you're using. Take a look at the "scriptedui" 
example that comes with BSF: the Java host registers a bean, but 
several more Java objects -which the host needn't care about- are 
instantiated in the script (e.g., ui.js for JavaScript).

Hope this helps.

Ulf

On 30.10.2004, at 23:44, Rainer Hahnekamp wrote:

> Hello everybody,
>
> I am about to write an application, which core's functionality depends 
> on BSF.
> The app uses a lot of different libraries and thats where the problem 
> begins:
> -As far as I know, your only chance to access some objects within the 
> Java
> scope you have to instantiate these objects and register them to the
> BSFManager. But what should I do, if I have here a class with static 
> methods
> that cannot be instantiated like the System class in java.lang??
> -In my application the script code needs access to the OpenOffice API, 
> which
> has - as you can surely imagine - a lot of classes. Must I really 
> instantiate
> and register all of them (they will certainly be needed in some cases) 
> or is
> there another way? If not I think that there should be a mechanism in 
> BSF
> where the script has access to all libraries in the CLASSPATH of the 
> host app
> without needing to register them.
>
> I hope you can give me some answers and thank you in advance.
>
> Greetings,
> -Rainer Hahnekamp


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