I would go for a completely different approach -- add reservedBy and
reservedUntil fields to the table (and entity EJBs).

When reserving an item, check that current date > reservedBy
When accessing the shopping cart, touch reservedUntil fields
When adding an item, update reservedBy and reservedUntil


- Avi
--
This signature intentionally left blank.

> -----Original Message-----
> From: Joel Carklin [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 16, 2001 09:59
> To: [EMAIL PROTECTED]
> Subject: EJB's and Timer Thread
>
>
> Hi ejb-guru's
>
> I have 2 related questions I hope someone can advise me on
> (I'm new to
> EJB's), relating to the java.util.Timer class and EJB's
>
> <Context>
>  I am working on a basic shopping cart system, using a
> stateful-session
> bean to represent the customers shopping process. The
> customer reserves
> items (ie puts them in his cart while continuing to shop),
> then, after a
> specified time, if he has not checked out those items(ie
> moved to payment
> stage) they will automatically be unreserved until such time as he is
> ready to pay (at which time the system will attempt to
> rereserve them). I
> wanted to use the util.Timer class  and util.TimerTask to
> schedule and
> implement this unreservation process.
> </context>
>
> <Questions>
>  Firstly, the Timer class works buy creating a seperate
> thread to run in.
> I have been told (although I don't fully understand why) that it is
> prohibited to create threads in a J2EE container since threads are
> managed by the container and shouldn't be messed with. How
> will using the
> Timer class affect / be affected by this? Is there a better way?
>
> Second, if I create the Timer object in the stateful session bean it
> would mean that for every customer there will be a seperate thread
> running which is obviously not ideal. Ideally, I want to be able to
> create one Timer thread that all the EJB's can share. Is this
> possible,
> any clues on how I might implement such a scenario?
> </Questions>
>
> Any comments / ideas appreciated
> Joel
>
> ==============================================================
> ============To unsubscribe, send email to
> [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help,
> send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to