So if I read you correctly, you have a servlet that delivers a web page with
a flash object, and you only want one person to be able to view that web
page at a time?  That seems very counter-productive to me. I know you say
you don't have control over that but I think you should motivate some change
of that system.

I guess there are some cases where you would really only want single user
access. In that case, you could use a flag on the session class itself. You
could mix in a thin class that provides a threading.Semaphore instance as a
class attribute. You can wrap the Semaphore's acquire and release methods or
just reference them directly from the servlet. Each time the servlet
executes, you would attempt to acquire the semaphore. You can use a
non-blocking call to acquire and loop for a certain amount of time before
giving an error message to the users. Otherwise if you do acquire it,
deliver the page as normal.

Now you have the problem of releasing it. You need to know when the user is
"done" with the flash object. If you have no way of guaranteeing that the
user will be done before their session expires, then you have to customize
the session's expiring() method. So you can have your mixin class override
the expiring() method to release the semaphore. But you dont want a session
instance to release the semaphore on expiration unless it was the one that
actually acquired it, so you'll need another flag. But this can just be a
boolean flag on the session instance. The expiring() method checks the flag
and then releases the semaphore if the flag is set. You would set the flag
just after acquiring the class's semaphore and unset the flag just before
releasing the semaphore (assuming it's possible to know when the user is
done with the flash object).

Hope that helps,
Ben

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of jose
Sent: Wednesday, May 28, 2003 9:32 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [Webware-discuss] At a loss please help with Sessions and
Tasks


Exclent point, Here is what I need to do, I have a web application which
allows users to interact with a flash object on a web page.  Now for the
problem the flash object writes an XML file to the server (I didn't make
the flash object so I don't have control of this object), so I need to
make sure that only one person has access to the object at any given
moment.  My first thought was to use sessions, but that won't work
across users, so then I thought of just making a lock file and killing
the lokc file when a session dies. But I am not all that thrilled at
changing the behavior of sessions across the entire website for this one
applicaton.  Any thoughts on maintaining user control?

Jose

-----Original Message-----
From: Ben Parker [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 28, 2003 12:23 AM
To: [EMAIL PROTECTED]
Subject: RE: [Webware-discuss] At a loss please help with Sessions and
Tasks


Jose, can you be a little more specific as to what you need to do when a
session expires? Then maybe I can give you some ideas.

to answer what you've said so far:

Mixing a class into session during the context __init__ will override
the session for the entire appserver. One way to use session classes on
a context-by-context basis is to override the Page.session() method with
something that wraps the session in another class. That won't help with
the expiration issue directly, but you can use that in combination with
a MixIn to achieve what you need.

For example, you can MixIn a class which overrides Session.expiring()
and performs certain logic depending on what type of session object it
is. This type would be determined by an attribute of the MixIn class.
Then in the
Page.session() method, you can set this new type attribute to identify
the Session. When the expiring functions runs, the appropriate logic
will execute.

Really though, what "file housekeeping" do you need to do at expiration
time? The best scenario is to rearchitect your use of session objects to
eliminate the need for such housekeeping.

Ben

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Tuesday, May 27, 2003 8:15 PM
To: [EMAIL PROTECTED]
Subject: [Webware-discuss] At a loss please help with Sessions and Tasks


HI all.

Can someone please tell me how I can access a session variable via a
task? What I need to do is to do some file house keeping once a session
expires. I thought I could do this by using MixIn and simply over riding
the expiring method within a context, but it seems the this over rides
the method for the all contexts (not really what I had in mind). So now
the only thing I can think of is to use Tasks, but I am at a loss as to
how to proceed.  Any and all help would be much appreciated

Thanks

Jose




-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore. Now
part of Progress Software. http://www.objectstore.net/sourceforge
_______________________________________________
Webware-discuss mailing list [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss








-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss





-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to