On Wed, 8 Nov 2000, Sai Geetha M N wrote:
> Hi
>
> I am trying to run a JACL script inside an EJB (Enterprise JavaBean). I pass
> the name of the script as an input paramater. Then the EJB reads that file
> and runs it using the Interp.evalFile Command. So Far, so good
> However, I want to be able to pass a Java Object (or may be a TclObject) to
> that script and the script should work on that object. Basically, the object
> would contain name-value pairs, which are the arguments for the script to
> work on.
It sounds like you want to take some Java info and wrap it up
in a TclList. You would then set a variable in Tcl to this
TclList.
> 1. Is this kind of a scenario implementable in JACL?
Sure.
> 2. If so, will any JACL script be able to understand Java Collection Objects
> or should I convert them into TclObjects? Is this possible and how?
You would want to take the data out of a Java vector and put it
into a TclList. You Java code would just allocate a TclList object
and then loop over the Java elements adding them to the TclList.
Something like (this is just off the top of my head):
TclObject to = TclList.newInstance()
Vector v = ...
while (! done) {
TclObject str = TclList.newInstance((String) v.elementAt(i) );
TclList.append(interp, list, str);
}
> 3. Once I convert it to a TclObject, how do I make the JACL script access
> this object? CAn I pass it as a parameter to the script?
Set a variable in the interp. See the interp.setVar() command docs.
These docs live in tcljava/docs/TclJavaLib.
It seems clear that we need better "getting started" documentation.
Would you be willing to take notes as you learn this stuff and
help with a short tutorial later?
Mo DeJong
Red Hat Inc
|