Welcome to the nsjava homepage.
SourceForge Logo

The nsjava Project


Project

SF Project page
Status
CVS

Documentation

Java Classes
Aolserver Tcl Commands
Simple Install Guide
JDBC setup

Related info

OpenACS
Aolserver.
TCL Java
PostgreSQL
 

Introduction

nsjava is a loadable c-module for aolserver that embeds a java virtual machine in process and takes advantage of aolservers adavanced features such as multi-threading and database connection pooling. nsjava has been extended to support many of the features of Tclblend. Some of the code was re-used from Tclblend, but the core funtionality has been rewritten to work better within aolserver. This was necessary, since the Tclblend architecture necessitated the use of a nasty hack to handle thread detach. Scripts written for use with Tclblend will not be compatible with nsjava, but since the application spaces are so different, I don't think that should be a problem. If there were popular demand for Tclblend compatiblity, I could probably accomodate that at some future date. Since nsjava now supports most of Tclblend's important features, nsjavablend will no longer be supported.

Features

  • Full access to aolserver database api from within user-defined java classes.
  • Create instances of Java objects from Tcl.
  • Invoke instance methods on a Java object from Tcl.
  • Invoke methods on array objects.
  • Invoke static Java methods from Tcl.
  • Get and Set Java Field values from Tcl.
  • Determine if a Tcl object is an instance of a Java Class.
  • Introspect Java Objects from Tcl.
  • Throw and Catch Java exceptions from Tcl.
  • Lock and Unlock Java objects so that they aren't garbage collected.
  • Import and un-import java classes.

Limitations

This module is currently limited to one tcl interpreter per aolserver thread. Tclblend users are used to creating additional interpreters, but doing so in nsjava/aolserver will cause unpredictable results, and it will probably crash the server. Using multiple Tcl interpreters within a single thread is not a common practice in Aolserver, so I don't see this as a big limitation.

db queries in user-defined java methods are not yet supported in the startup thread. This is due to Aolserver blocking signals in the startup thread, which makes it necessary to run the JVM in a separate thread. I think I have a work-around for this problem, but I need to look at aolserver internals more closely to make sure the change is worth the effort. Once this change is made, nsjava will pretty much be feature complete. nsjava does not affect the normal operation of Aolserver, so it is still possible to perform db queries from Tcl in the startup thread.

Motivation

nsjava was initially developed to support the porting of java packages to openacs, but since openacs 4 no longer makes much use of java, that is not a priority. Instead, nsjava is intended as a general web development tool for extending Aolserver's capablities.

TODO

  • Add db support for java methods in startup thread (Use JDBC as a work-around for now)
  • Compatiblity testing - ensure that nsjava builds and runs on same platforms that are supported by Aolserver.
  • Load testing
  • Extend test harness for more comprehensive testing coverage. (Done)
  • Add support for passing binary data to/from java via Tcl
  • Add db support for oracle (Should be able to use JDBC for now)

Applications

  • I've created a web-services package for OpenACS 4 using apache Axis. This package is still experimental, so it may change significantly in the future, but if you want to try it out, you can download the package here

dcwickstrom@earthlink.net

News

Version 1.0.5 Released