General information

General information
Expand Twiff

Twiff is short for Trajano Web Imaginary Framework. Trajano being my last name.

Why imaginary?

Because if it ever gets out of my workstation, something is seriously wrong with the universe. Seriously, I don't forsee me finishing this anytime in the next decade if ever. I am just doing this to learn about J2EE 5.0 template stuff.

What's the extra F for?

Whatever you heart desires it to be. Just keep it clean if you're around children.

Why build another web framework? Tapestry and Wicket already do what you want.

For me to learn. No one is forcing you to use this framework (I hope). But I wanted to see how far I can take things. This is also something like a blog for me as well.

Also there isn't really anything out there that can just take an HTML site with a directory structure and convert it into a web application while preserving the structure.

Design questions

Design questions
What are your inspirations?

The following projects gave me ideas on how I want twiff to end up.

  • Tapestry - the concept of putting in attributes rather than tags so we can utilize HTML developers.
  • Wicket - Tapestry with less XML configuration files.
  • NanoWeb - using picocontainer to store components.
  • Struts - what I don't want to end up with.

Whether something will come out of it or not is a big maybe.

Where is there so much stuff in the web.xml? Struts is just one action

I am trying to put as much of the application configuration data into web.xml since its part of the J2EE spec itself. Struts if you would notice has its own struts-config.xml file which can get quite unweildly. Anyway I hope to at least make it easier eventually by providing a template application in the end.

Why are you using Hibernate if you only have one table?
I wanted to learn Hibernate 3.0 and Java 5.0 Annotations.
Why did you not store Hibernate session factories in the picocontainer?
Since there was basically only one place that it would occur, it was just less of a headache to just use the HibernateUtil code snippet from Hibernate In Action.
Spring provides transaction support so you can use things without an EJB container. Why doesn't twiff have one?
The primary purpose of twiff was to create just the user interface layer, not the backend which I think should still be done behind Stateless Session EJBs. However, I may change my mind later.
Why are you developing for J2SE 5.0? Its not popular yet nor is it supported by current application servers.

This framework is an exercise for me to learn about templates in J2SE 5.0. I also want to keep the code base a small and clean as possible. Anyway if this does get out of my workstation 5.0 would be either mainstream or legacy by then.

Some of the things you are doing are already done by nanocontainer

Nanocontainer is good. But I want to simplify it more by removing the capability of doing scriptable container creation. I wanted to keep it simple and just use Java code to populate the container so I can reduce the number of XML data sets in the application core.

And like I said before this project is meant as an exercise for me. I just want to see what I can do.

Why did you make your own web.xml or .hbm.xml file rather than using XDoclet to generate one for you?

I tried, but the version of XDoclet I am using 1.2.1 is quite buggy and won't do context parameters and Servlet API 2.4. It also does not support J2SE 5.0 constructs, so I decided to hold off on it for now.

Also I have tried using Hibernate Annotations and I find it good, but getting things in sync with the EJB 3.0 JAR which is not allowed in the Maven repositories because of Sun's licensing restrictions.

Can I use schemaupdate to generate the tables used by the framework?

It is possible, but not recommended. There is only one table that needs to be created namely SessionToken. This table also needs to have the SessionId and tokenId indexed for efficiency. Hibernate's tools do not put in the index automatically and without it, it will run really slowly.

The following commands create the necessary index for DB2.

create index sessiontoken on sessiontoken(sessionid,tokenid)
create index sessionid on sessiontoken(sessionid)
Why did you not test with Cactus or HttpUnit/ServletUnit?

I tried, but it seems to hang on Tomcat 5.5.7. Haven't checked much into it yet. Also HttpUnit/ServletUnit does not support Servlet API 2.4 listeners as of yet, but I sent a feature request already, but the project has a lot feature requests already so I won't hold my breath on it, for the mean time, I faked my own listener calls in one of my test cases.

Why use multiple servlets? Other frameworks just rely on one controller servlet.

Having multiple servlets allows for a bit better profiling for some application servers than one single uber servlet, I guess. Also its still just a few servlets to deal with: ViewServlet, RedirectServlet, ActionServlet and AttachmentServlet.

I think its better to keep using as much of the standard technology as possible rather than reinventing the wheel over and over again like the Struts plugin system when there are load-on-startup servlet supported. If someone can't handle doing this they shouldn't be working on J2EE apps I think.

What is the purpose of the listener?

The listener creates the PicoContainers used in the context, session and request levels.

The listener also prepares and cleans up any required objects to handle request tokens.

In theory if the listener is split into two, the PicoContainer population logic can be excluded. But the token data management is still required to handle the forms.

What is the purpose of the filter?

The filter parses the URI to extract the locale information requested. So the browser does not need to be configured to have a specific locale.

It was implemented this way in order to remove locale logic from the servlet level.

The filter itself is optional and may be excluded from the web.xml file, but it would not allow URL based locale selection.


Why aren't you using checkstyle to check the style of your code?

There is no maven checkstyle plugin that supports Java 5.0 constructs yet. A version of checkstyle that supports Java 5.0 exists in the CVS version, but I will fix those errors later. I don't think I do anything really weird except for the license and line length.


After a while, the SessionToken management code runs slowly?

The table might not have been indexed. The SessionId and tokenId indexed for efficiency. See schemaupdate.