public class WorkoutScriptFile
This class runs a Jython script in a file. (Currently there's no
other way to run Jython other than in a file. I could run a string,
I guess, but I've never needed to.) Right now, by design, each
script gets its own Jython iterpreter. I don't think it would be a
good idea to share an interpreter. I don't think it would be thread
safe. This requires more research, but it isn't important when I
can throw 16GB at the problem. Warning: Right now, the python
module path to our interpreter is hard-coded. This isn't a good
thing, but I can fix it later. (Technically, the filename doesn't
have to end in .py, but the multi-threaded interpreter enforces
that. And technically, any Jython code can be run by the
multi-threaded driver, not just workout code.)
public WorkoutScriptFile(java.lang.String their_script)
The constructor takes the user's script file name.
their_script - The filename of the script to run.
public void setConnection(java.sql.Connection their_con)
Sets the database connection for the interpreter. The user can
pass us a connection they already set up if that is
desirable. Or, the script can make it's own connection. Either
one works. The situations where you want to pass a connection
are either when you're running a script in J2EE and want to
make the connection with JNDI and not have that dependency in
the script itself, or when you don't want to make a specific
database connection in the script and keep it
database-independent by lettin the outer layer make the
connection for you. Or, you want to use the connection pool
everyone else is using. Anyhow, it's a lot easier in Jython to
use workout_con and workout_db than roll your own connection,
so this is convenient.
their_con - The user's database connection.
public void setDatabase(java.lang.String their_db)
Sets the database string so we know which database we're
using. This is used in connection with setting the database
connection, but provides a string so scripts can make decisions
if they need to, or pass the string to other parts of workout.