Accomplished a few things today … I finally figured out how to create an externalized mapping of commands to classes. I was reading a chapter in the book JavaServer Pages by Oreilly. They described a popular technique of creating an Action Interface and then extending this interface to give you a mapping of actions to class names. This is the code snippet they show:
So I made an action interface, made an action class (has to be serializable) and tried writing this Hashtable to a file with ObjectOutputStream and then I viewed it. The file was in binary format and wouldn’t be maintainable because I need a flat text file that I can easily edit. My goal is to have a controller that I don’t have to touch when I add functionality. Something maintainable. I realized that this method might be good for writing objects to files, but wouldn’t help me here.
So then I tried this:
And all I have to have in /tmp/testme.txt is the following line: post = net.fuzzylemon.acronym.action.PostAction.
Here’s my action interface:
And here’s my PostAction class:
Of course, all this still needs to be cleaned up and implemented in a servlet, but it’s progress.