More permanent stuff at http://www.dusbabek.org/~garyd

24 August 2005

ooweb

I've been working more on Tagfriendly latehttp://www.blogger.com/img/gl.link.gifly. I've decided that account maintenance will be handled via a simple website. From past experience, I know that Tomcat or any use of J2EE is simply overkill. So I went looking.

And I came across , which was refreshingly simple. In fact, it was this simple:


import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import net.sf.ooweb.Configuration;
import net.sf.ooweb.Server;

public class Main {
private static final ClassLoader loader = Main.class.getClassLoader();

public static void main(String[] args) {
Configuration conf = new Configuration(getProps("ooweb.properties"));
Server s = new Server(conf);
s.register("/",new FileUrl(getUrl("html/index.html")));
s.register("/create_user/", new CreateUser(getUrl("html/create_user_form.html")));
s.register("/resend_password/", new Resend(getUrl("html/resend_form.html")));
s.register("/search/", new WebSearch(getUrl("html/search_form.html")));
s.listen();
}

// two utility methods to fetch resources from a file or jar have not been included.

}



The classes implementing the logic (FileUrl, Createuser, Resend,and WebSearch) are POJOs. If CreateUser has a method called doCreate(), it is accessed by calling the URL: /create_user/doCreate. Very simple. I violate MVC and separation of logic and presentation, but hey: I just want to get it working first.

Best part: NO FREEEEEKIN' XML WAS REQUIRED.

Which reminds me of a sig I see every once in a while: "XML is like violence: if it doesn't solve your problem, you aren't using enough of it." It turns out that ooweb was inspired by cherrypy. Figures. The reasons to learn and become proficient in Python are becoming clearer and more convincing every day.

0 comments: