Hi all,

I'm currently working out design details for a new project, and I've
discovered a few constraints in Turbine that I'd like to discuss.

As it stands right now, the doGet method in Turbine does a lot
of stuff, and it isn't easy to override or enhance the behavior
(although the capability to alter the SessionValidator, login
process, etc. is quite nice).  Specifically I need to do two things
in my application that are a bit difficult with Turbine as it stands now.

1. I want to be able to do some general bookkeeping/logging for
each request before any other processing is done.

2. I need to do some generic initialization on each HttpSession
object after it is created.

Of course I could extend Turbine, override doGet, copy the
doGet code into my subclass and modify it as necessary,
but then I wouldn't pick up changes to doGet in Turbine.

Here's what I'd like to propose:

1. Add a method called something like preHandleRequest to
Turbine that would get called like this (code modified from
Turbine.java):

            // check to make sure that we started up properly
            if (initFailureMessage != null)
            {
                throw new Exception ( initFailureMessage );
            }

            preHandleRequest(req, res);

            // get general RunData here...

The default implementation of preHandleRequest wouldn't do
anything, but a Turbine subclass could override it as desired.

2. Add a method called initializeSession that looks like this

void initializeSession(RunData data)
{
    String[] names = data.getSession().getValueNames();
    if (names != null)
    {
        for (int i=0; i< names.length; i++)
        {
            data.getSession().removeValue(names[i]);
        }
    }
}

initializeSession would then get called from two places in doGet:

            // perform turbine specific initialization below
            data = RunDataFactory.getRunData( req, res,
getServletConfig() );
            initializeSession(data);

            ...

            if ( data.hasAction() &&
                data.getAction().equalsIgnoreCase(TurbineResources

.getString("action.login")) )
            {
                initializeSession(data);
                ActionLoader.getInstance().exec ( data, data.getAction() );


Now I could override initializeSession in my subclass, call the default
implementation, and then perform my own custom initialization.

What does everyone think about this?

As a side question, does it make things easier for everyone if I
submit suggestions for comment in this way, or is it easier if I
just make my proposed changes and submit a patch for review?
Turbine is already one of the nicest web application frameworks that
I've seen yet, and I hope that my comments (and ultimately code
submissions) will make it even better.

-Jon




------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to