2005-03-03
Axt Design Choices
So what was I thinking? There's few things the world needs less than a new template engine. Here's my feature list that made me roll my own anyway:
- A template ist editable in an xml editor. Don't give me the <a href='<c:url value="..."/>'> mess. A template is at least be well-formed xml. This rules out #velocity.hashmichtot#, too.
- A template is previewable. A design with template annotations applied stills look exactly the same in a browser. This means you can keep your "blindtext" (placeholder text) around.
- A template is fed with a binding of names to (java) objects accessed through an easy yet powerful expression language (OGNL).
- A template garantuees well-formed xml output. It does so by generating output to a SAX ContentHandler, not a Writer.
- A template is extendable with plugins that can manipulate their body content. Just as a JSP 2.0 SimpleTag can evaluate its body on a custom Writer and apply filtering, ... an axt template can evaluate its body to a custom ContentHandler and perform any manipulation it likes.
- Axt is easily embeddable. There are no dependencies on the filesystem, a compiler, a servlet engine. The only requirements are DOM, SAX, OGNL.
- Of course, it must be fast. Templates and OGNL expressions are pre-parsed and thread-safe. The OGNL interpreter is also thread-safe and caches its introspection results. I've been able to churn out 1300 (small) pages per second (about 5MB/s) from an 8 processor Sun using Axt to render pages in Tomcat 5. And it scales wonderfully to many clients.
- It's simple. 28 files, 1200 LOC. Apache Jasper is 30 times that big. Small things rule.