JavaTools

Hosted at Sourceforge: http://sourceforge.net/projects/javatools/.

Written by Chris Bitmead.

Javadoc is found here Javadoc.

USE THE VERSION IN CVS FOR REAL DEVELOPMENT, BECAUSE OFFICIAL RELEASES ARE MADE RARELY, AND THE CVS VERSION IS THE MOST STABLE

JavaTools is a grab bag of lots of Java code that I've personally found useful. Most of the code is well written and some is quite extensively documented with javadoc. However, there does still need more doco written.

The source is released as a .tgz file (gzipped tar). On Windows, this can be extracted using WinZip.

The javadoc is online here. Many packages have a javadoc package summary so be sure to click on the "Description".

The highlights include:

Database Interface Classes

These classes are designed to provide a nicer, higher level interface to the database than than provided by raw JDBC. This much more fun than JDBC! It especially makes it easier to make dynamically generated queries. The design is somewhat modeled on the Rogue Wave Source Pro DB C++ class library (formally known as DBTools.h++). If you are left wondering "why is it so", reading the online Rogue-Wave Source Pro DB docs may provide philosophical answers.

Cron Implementation

This is an implementation of Unix Cron written in Java.

This implementation distinguishes itself from some others in the following ways...

  • It doesn't wake up every minute when there is nothing to do. It sleeps until the next event is scheduled to occur, no more no less.
  • Because of (1) scheduling can be done at millisecond resolution. There is an optional extended file format that supports milliseconds, seconds and years.
  • While the package contains an implementation of Unix style crontabs, the Cron class itself doesn't care if it is a class which schedules according to Unix style events, or the phases of the moon or the movements of the planets or whatever. Cron only wants to know (a) when is the next event and (b) what to do when that event occurs. This allows custom event generators.
  • Supports text names like MON,TUE,WED and JAN,FEB,MAR etc.
  • Extended formating. e.g. JAN-JUN/2,DEC is valid syntax.
  • A reverse parser. i.e. It can convert from a bitmap of events into a quite optimised string representation. This is very useful for certain styles of Gui editor implementations.
  • The beginnings of a Java Swing gui and an applet that can edit Crontab Entries both graphically and with Unix style syntax.
  • It is unnecessary for your task to inherit a special class. At present I support two types of objects: Calling a static main() method in a class, and calling a class that implements java.lang.Runnable, while passing the arguments to the constructor. Optionally your class may implement another interface "Server" in which case it can implement "shutdown()".
  • I make it easy to do something custom when an event happens if that's what you want. e.g. you may want to instead start processes or take some other action when a Cron event occurs.
  • Designed to make it easy to store your crontabs in strange places. e.g. I need to store mine in an SQL database with single fields for each time interval.

    Servlet utilities

    A couple of small servlet base classes that make it nice when working with the db classes. In particular committing and rolling back as appropriate.

    HttpCommander

    If you attach this class to your own class it allows you to call your methods via a http socket. e.g. write a method Foo.bar(HttpWriter w) and you can telnet to a port, enter "GET /bar" and it will execute that method. Great for conveniently controlling servers remotely with a web browser.

    Compile tools

    Makes it convenient to compile java code from within a Java app. The possibilities of dynamically compiled and loaded classes are endless.

    Logging classes and Assertion class

    Yet another file logging class. Nothing special, but it does provide multiple levels of logging, configurable with a properties file.