Cup a’ joe

After celebrating a couple years of not having to deal with the GridBagLayout, I’m dusting off the JVM to give Java another try. However, I’m not quite ready to leave Emacs for Eclipse (don’t mention the doppelgänger keyboard layout – it’s not the same).

Two features I miss from Eclipse are source code navigation and tight server integration. Especially when familiarizing yourself with a new codebase, jumping around within the source can be an excellent tool.

Back at Google I was a staunch defender of JDEE, but I’ll be the first to admit it isn’t so easy to get running. Coming to the rescue is malabar-mode, sporting:

  • Syntax highlighting (with compilation errors)

  • Movement commands (C-M-f/-b is a winner; so is M-f/-b, especially with c-subword-mode turned on)

  • Tight integration with Maven

  • A Groovy console for rapid prototyping and exploratory programming

  • JUnit integration, both for running tests standalone and through Maven

  • Import help; import one class or all needed classes in the buffer (with prompting if the class name is ambiguous)

  • Extend class / implement interface / override method helpers

  • Simplistic refactorings

Sounds good! Setup was a snap on Emacs 23.3 (which comes already configured with CEDET). Emacs 24 also appeared to work but that is a topic for another day.

The other missing feature is integration with a Geronimo server. For that I had to roll my own. Copy this “ghelper” code to your PATH and it should be a litter easier to navigate starting, cleaning, and redeploying EBAs to the server.

#!/usr/bin/python



import argparse

import subprocess

import shlex



parser = argparse.ArgumentParser(description='Description of your program')

parser.add_argument('-s','--start', help='Start the Geronimo server', action='store_true')

parser.add_argument('-c','--clean', help='Clean the server', action='store_true')

parser.add_argument('-i','--install', help='Compile and install in the supplied directory',)

parser.add_argument('-d','--deploy', help='Deploy an EBA to the server')

parser.add_argument('-r','--redeploy', help='Re-deploy an EBA to the server')

parser.add_argument('-u','--undeploy', help='Un-deploy an EBA from the server')

args = vars(parser.parse_args())



def run_command(cmd):

    subprocess.call(cmd, shell=True)



if args.get('start'):

    run_command('geronimo3/bin/geronimo run --clean')

if args.get('clean'):

    run_command('rm -rf geronimo3/repository/application/* geronimo3/deploy/* geronimo3/hotbundles/*; cp geronimo3/var/config/config.xml.old geronimo3/var/config/config.xml')

elif args.get('install'):

    run_command('cd %s; mvn install' % args.get('install'))

elif args.get('deploy'):

    run_command('geronimo3/bin/deploy --user system --password manager deploy %s' % args.get('deploy'))

elif args.get('redeploy'):

    run_command('geronimo3/bin/deploy --user system --password manager redeploy %s' % args.get('redeploy'))

elif args.get('undeploy'):

    run_command('geronimo3/bin/deploy --user system --password manager undeploy %s' % args.get('redeploy')) 

With the passing of time comes better tools. While I’d rather pick Python any day, is is nice to be able to stay in Emacs world.