Ugly!

No, not me.

I’m working on a database project with mrw. For lots of reasons, we’re doing it in Java. (ok, two reasons. JDBC exists; and Swing works on both OSX and Unix.) From time to time, I’ll probably post interesting design tidbits as I flesh out the basics.

Today’s design bit: Ugly has a core package, which deals with database abstractions and will also handle threading and query execution. The primary class is called UglyCore, which extends URLClassLoader, and it simply loads a property file to dynamically extend the classpath. This means we can load jdbc drivers using a more sensible model than “modify the startup script to include your driver jars in the classpath”. The only complicating factor is that classes from one classloader can’t talk to the other. So your startup class has to pass its name into UglyCore, and UglyCore loads that class using itself and calls newInstance(), casts the result to Runnable and calls .run().

For now this is a swing JFrame descendant, but you could implement pretty much any UI model you wanted. The only catch is that you can’t really pass args into it. For this I’ll probably need to create my own interface that does more than Runnable. You can’t just store stuff in a static member because it’s a different class object. Classloaders are a pain, but in this case the flexibility is worth it.

I’m kinda rambling here so I’ll wrap this up. Tomorrow I’ll talk about the driver abstraction model.

This entry was posted in tech. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>