velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guido Sohne <gu...@sohne.net>
Subject OT Re: Integrated Velocity ForumDemo with Prevayler
Date Wed, 02 Oct 2002 04:58:20 GMT
I've taken a look at the code - it takes a bit of
getting used to for me :-)

Off the top of my head, I see that you are persisting
List and View commands. That should not be so. Correct
me if I am wrong. You mentioned View should not be
persisted. I think List should also not be persisted.

In your design, I would have subclassed Command and
added a method so that the context could be attached
to a command instead of to the forumDatabase object.

Or maybe not ... it takes some getting used to! If
the context was a member of the Command object then
what happens during depersist / recovery when no
context is available. Ouch!

But it's quite cool. Only I don't see necessary
is having Request and Response objects even if transient
in the commands themselves.

Why not explicitly make it part of the constructor ?
Perhaps because it makes it so you don't have to keep
changing the controller code as you develop your business
objects ?

I am interested in how the design could be improved and
what the various designs were. I have not taken a look at
the original ForumDemo code and am used to Turbine unpacking
parameters and handling the servlet issues for me.

So like I said, am still getting used to it ... but it
feels very lightweight and very fast too. 

On Tue, Oct 01, 2002 at 01:03:06AM -0700, Randito wrote:
> 
> Done.
> 
> Location:  
> http://www.randito.com/forumdemo-prevayler.zip
> 
> The ultimate test:
> 
> - Drop the WAR in your webapps directory.
> - Start the server (a local tomcat in my setup)
> - http://127.0.0.1:8080/forumdemo-prevayler
> - Add some entries in the forum.
> - Stop the tomcat server
> - Restart the tomcat server.
> - http://127.0.0.1:8080/forumdemo-prevayler (Click view)
> - The forum entries are there, persisted via Prevayler.
>   You will see some log messages from the prevayler system.
> 
> Things to take note of:
> 
> - Changes from the original ForumDemo and this one are significant.  I
>  would recommend an uber-diff tool. 
> 
> - The modified view command, org.apache.velocity.demo.action.ViewCommand
>  is being persisted by Prevayler, and this is not needed.  It is
>  just a view and does not change data, so it should not go through
>  the prevayler system.
> 
> - All of the ForumDemo commands are now Prevayler Commands.  The good
>  design of the original ForumDemo allowed me to put in the Prevayler
>  system and Commands painlessly.  Good job!
> 
> - I am using the ForumDatabase object model as my PrevaylerSystem.
>  I had to embed the Velocity context in the system, so the existing
>  ForumDemo commands had access to the context.
> 
> - Remove the ForumCommand inheritance, and just (re)implemented in the
>  subclasses.  I was debugging some serialization problems, and just
>  removed the inheritance as a part of that debugging process.  
> 
> - Moved the request parameters in the commands from local variables
>  to instance variables.  During prevayler recovery, the request and 
> response
>  objects were not present, so these variables needed to be part of the
>  serialization of the object.
> 
> - Made request and response references transient in the commands.  They
>  don't (and shouldn't) be serialized.
> 
> - ControllerServlet has most of the Prevayler command goodies:
>    if ( name.equalsIgnoreCase("list") )
>        {
>            c = new ListCommand( req, resp);
>            template = executePrevaylerCommand(context, c);
>        }
> 
> - In the commands, I removed some of the static members and made some
>  members transient, to make the commands more Serializable.
> 
> - All logs go in the /WEB-INF/ForumPrevalence directory
> 
> - The prevayler library (/lib/prevayler.jar) has some System.out.println
>  debug messages in it.
> 
> 
> Problems I had:
> 
> - When prevayler is recovering from a crash, it executes all of your
>  logged serialized commands.  If these commands through an execption,
>  this can cause problems.  The catch clause in the Prevayler code is
>  empty; this can bite you if you if not careful.  Add some log messages
>  during development in this catch area.  See
>  org.prevayler.implementation.CommandLogRecoverer
> 
> 
> 
> 
> 
> 
> 
> 
> >Please do WAR it up and send it out.
> >I've looked at Prevayler before but 
> >have not actually used it ...
> >
> >I am interested in finding out how
> >it would look different than something
> >like Torque.
> >
> >On Sun, Sep 29, 2002 at 04:04:37AM -0700, Randito wrote:
> > 
> >
> >>Velocity newbie here.
> >>
> >>I have integrated the Velocity ForumDemo with the Prevayler persistance 
> >>engine.
> >>(Mostly, to learn Velocity and to learn Prevayler).
> >>
> >>Prevayler (www.prevayler.org) is a light-weight persistance engine, using
> >>serialization and standard java objects for "transparent" persistance.  
> >>
> >>I had to make some mods to the ForumDemo code to get it all working, but
> >>the ForumDemo is now persisting across Tomcat reboots.  It's really kind
> >>of cool.  I can stop Tomcat; restart it; and the ForumDemo posts are all 
> >>there
> >>as if nothing happen.  Very cool.
> >>
> >>Check out the Prevayler demos from www.prevayler.org or from sourceforge.
> >>http://sourceforge.net/project/showfiles.php?group_id=36113
> >>
> >>If anyone wants it, let me know.  I'll clean it up, WAR it, and send it 
> >>out.
> >>
> >>Randy
> >>
> >>
> >>
> >>
> >>
> >>--
> >>To unsubscribe, e-mail:   
> >><mailto:velocity-user-unsubscribe@jakarta.apache.org>
> >>For additional commands, e-mail: 
> >><mailto:velocity-user-help@jakarta.apache.org>
> >>   
> >>
> >
> > 
> >
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:velocity-user-help@jakarta.apache.org>
> 

Mime
View raw message