I've been investigating porting some of the java stuff coming out of
aD, and as a test case I decided to port webmail which relies heavily
on oracles sqlj java implementation. I'm to the point where I can now
able to send and receive emails without attachments using the webmail
interface. Attachments dont' work yet, since I'm only able to pull lob
data out of the database, but with a little more work, I should be
able to get it so I can put lob data back into the database through
the java JDBC interface to postgres.
The webmail module consists of two main parts that execute java code
inside of oracle. One is a message parser that reads in messages from
qmail performs mime decoding, and the other is a message composer that
performs mime encoding.
I was able to reuse most of the java code without modification. The
only exception being that sql statements that are declared using a
c-preprocessor looking syntax that starts each sql statement with
#sql. Why oracle chose to do it that way is beyond me. Why not for
instance, just extend the java sql classes that are already specified
in the product api? The postgres JDBC interface is handled this way,
and the result is much cleaner.
The acs implementation of message composition went as follows:
- Stuff message headers and body into the database.
- Call java function to perform mime encoding.
- Pull mime encoded message out of the database and send it using
qmail-inject.
The ported implementation works as follows:
- Stuff message headers and body into the database.
- Call java function to perform mime encoding via exec function in
tcl. java talks to postgres using JDBC interface.
- Pull mime encoded message out of the database and send using
qmail-inject.
The message parsing transformation is similar. The oracle/acs
implementation is as follows:
- Oracle schedules java process to check the qmail rx queue once a
minute.
- New messages are mime decoded and stuffed into the database when
scheduled process runs.
- User sees new messages when /webmail url is reloaded.
The ported version works as follows:
- Aolserver schedules process to check qmail queue once every two
minutes.
- New messages are mime decoded and stuffed into the database using
JDBC interface when scheduled process is run.
- User sees new messages when /webmail url is reloaded.
Java is definitely not suited for web development. I've never been a
big fan of TCL, but I now find it to be a dream compared to doing this
stuff in java. I found that when writing java code, I spent half my
time scanning the api library docs trying to figure out to do
something that I would have easily done in TCL.
Tclblend seems to be a non-starter as it requires the tcl library to
be compiled as a shared library, and aolserver compiles tcl as a
static library. I'm guessing that aolserver uses static libraries for
reasons of thread safety and speed, and I wouldn't want to start
messing with custom compilations of either aolserver or tclblend.
Given that aolserver and java both are multi-threaded and have good
support for sockets, a better approach might be to start up a
standalone java application that talks to postgres through JDBC, and
is controlled by aolserver via a socket connection. Doing it this way
would be more portable and easier for users to install. The only
extra requirement being that the user install java and compile the
JDBC interface.
Of course, if aD gets too carried away with this java inside of oracle
thing we'll just have to fork from acs, and provide similar
functionality using tcl/postgres.