Cheri – A Builder Framework

Cheri is a framework for creating builder applications (those that create hierarchical, tree-like, structures). It includes a number of builders based on the framework, as well as a builder-builder tool for easily creating simple builders. Cheri also comes with a demo application, Cheri::JRuby::Explorer, that is built using two of the supplied builders (Cheri::Swing and Cheri::Html).

This version (0.0.5) is an early beta release. Some features are not yet fully developed, in particular the HTML/XML components. On the other hand, Cheri::Swing, which is the successor to JRBuilder (www2.webng.com/bdortch/jrbuilder), is relatively mature, in an adolescent sort of way, though many features could be added.

But do expect some bugs, especially in Cheri::JRuby::Explorer (CJX), which is very much a work in progress. I note some known problems in the section below.

Documentation will be forthcoming over the next couple of days (from this writing, 8 June 2007), so watch the Cheri websites at RubyForge for updates:

http://cheri.rubyforge.org/
http://rubyforge.org/projects/cheri

In the meantime, here is a very brief summary of CJX.

Cheri::JRuby::Explorer (CJX)

CJX is a Swing application written entirely in (J)Ruby using the Cheri::Swing and Cheri::Html builders. It enables you to easily browse classes/modules, configuration/environment settings, and, if ObjectSpace is enabled, any objects in a JRuby instance. A small DRb server component can be installed in other JRuby instances, enabling you to browse them as well. (Note that I have been trying to get the DRb server component working in C/MRI Ruby as well, but have run up against threading/IO conflicts. Suggestions welcome!)

The CJX client requires JRuby 1.0.0RC3 or later. To run it (after installing the Cheri gem):

require 'rubygems'
require 'cheri/jruby/explorer'
Cheri::JRuby::Explorer.run

Alternatively, you can load and run it in one step:

require 'rubygems'
require 'cheri/cjx'

This will take several seconds to load and start – performance will be one area of improvement for versions 0.0.6 and beyond. Once it loads, it should be fairly clear what to do.

Some known issues:

  • Browsing the class hierarchy is very slow right now – this actually slowed down in the past couple of days when I switched from HTML to straight Swing layout, the opposite of what I expected to happen.

  • There are lots of layout issues; neither HTML (JEditorPane) nor BoxLayout provide exactly what I’m looking for. Will probably have to bite the bullet and go to GridBagLayout. Ugh.

  • Global variables are currently shown, um, globally, when many of them should be shown per thread. This will be fixed in 0.0.6, which will include a Thread section with other goodies as well (thread-local vars, status, etc.).

To install the CJX DRb server component in an instance (assuming the Cheri gem is installed):

require 'rubygems'
require 'cheri/explorer'
Cheri::Explorer.start nnnn #=> where nnnn is a port number

Note that for the server, you require ‘cheri/explorer’, not ‘cheri/jruby/explorer’. Also note that the above actually does work in C/MRI Ruby, but requests to the server then hang in CJX, unless you join the thread:

Cheri::Explorer.thread.join

After that, you can browse just fine in CJX, but you can’t do anything more in the C-Ruby instance, so it’s kind of pointless. Again, if anyone with some DRb experience (of which I have none) can offer any suggestions, I’d appreciate it.

The Rest

Please visit the Cheri site for more documentation, I’ll be continually adding to it in the coming days.

Bill Dortch <[email protected]> 10 June 2007