struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject RE: cross context notifications
Date Sat, 26 Oct 2002 04:43:50 GMT


On Sat, 26 Oct 2002, Mohan Radhakrishnan wrote:

> Date: Sat, 26 Oct 2002 09:49:13 +0530
> From: Mohan Radhakrishnan <MohanR@hclcomnet.co.in>
> Reply-To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> To: 'Struts Users Mailing List' <struts-user@jakarta.apache.org>
> Subject: RE: cross context notifications
>
> Hi,
>    We could do that if it doesn't affect ongoing sessions. Is it possible
> that one user reloads it while the other is reading the application scope
> variables thorough the tag handlers ? We have several arraylists. Each
> arraylist is read by a <html:options... tag handler. Will it cause something
> like a phantom read ?

It depends on the precise implementation of the Iterator that ends up
getting created, but I would bet that you won't have a problem, if you do
this carefully.  Here's a walkthrough of a typical scenario:

1) User 1 requests a page that includes an <html:options> tag
  based on a ArrayList under servlet context attribute "foo".

2) Inside the implementation of OptionsTag, an Iterator over the
  ArrayList at variable "foo", and starts rendering the options.

3) User 2 requests the administrative function to refresh the list.

4) The Action responding to user 2's request builds a new ArrayList
   in a local variable (not yet added to the servlet context).

5) User 1's tag is still iterating over the old list, with no problems.

6) User 2's request has completed the new ArrayList, and only now
   stores it under the servlet context attribute "foo" key (replacing
   the original list.

7) The Iterator that is being used by User 1 is still operating on the
   old list (so the new changes are not visible on this request), but
   it does NOT see any corrupted data.

As long as the action in step (6) is atomic (in other words, you don't try
to replace the servlet context attribute until your new list has been
completely created), you should never have a problem -- a particular user
request that is running the <html:optoins> tag will see EITHER the old
list OR the new one, but will never see any corrupted combination, or half
completed new list.

> bye,
> Mohan
>

Craig


> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Friday, October 25, 2002 10:12 PM
> To: Struts Users Mailing List
> Subject: Re: cross context notifications
>
>
>
>
> On Fri, 25 Oct 2002, Mohan Radhakrishnan wrote:
>
> > Date: Fri, 25 Oct 2002 15:18:18 +0530
> > From: Mohan Radhakrishnan <MohanR@hclcomnet.co.in>
> > Reply-To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> > To: 'Struts Users Mailing List' <struts-user@jakarta.apache.org>
> > Subject: cross context notifications
> >
> > Hi,
> >     Our problem is one of those classic cases.
> >  We load report parameters into the application scope. These parameters
> > change but not too frequently. We don't want to fetch the parameters with
> > every request because they don't change very frequently.
> >
> >  1. Is there any way to reload data that changes in the database either
> >     a) manually or
> >     b) through the admin application.
> >
> > The admin application and the reporter application are separate contexts.
> >
> > Can there be cross context notifications between applications in tomcat ?
> > Can admin be a sub application of the reporter module ?
> >
>
> Why don't you just add a Struts action to your application that reloads
> its servlet context attributes?  There's no reason to complicate life by
> trying to do cross context things.
>
> > bye,
> > Mohan
> >
>
> Craig
>
>
> --
> To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message