Hi Miguel, 

thanks for the tip, is it possible to use this in a struts action which is not 
thread save?

ciao 4 now
Julian 

> -------- Original-Nachricht --------
> Datum: Tue, 30 May 2006 09:28:36 -0300
> Von: Miguel Galves <[EMAIL PROTECTED]>
> An: Struts Users Mailing List <user@struts.apache.org>
> Betreff: Re: Re: Re: How to lock the access of methods within an action?
> &#xA> Julian,
> 
> you can use the lock provided by Java 1.5 API...they are very simple to
> use.
> For istance, I use java.util.concurrent.Semaphore.
> The code above sho how to use it:
> private Semaphore sceneryLock = new Semaphore(1, true);
> 
>   public void removeScenery() throws Exception {
> 
>         try {
>             sceneryLock.acquire();
> 
>             .... do your critical stuff here ...
>         } catch (InterruptedException e) {
> 
>         } finally {
>             sceneryLock.release();
>         }
>     }
> 
> Hope it helps ...
> 
> []s
> 
> Miguel
> 
> On 5/30/06, Julian Tillmann <[EMAIL PROTECTED]> wrote:
> >
> > thx
> >
> > hmm, where can I find it, is it part of Spring?
> >
> > >-------- Original-Nachricht --------
> > >Datum: Tue, 30 May 2006 18:36:06 +0800
> > >Von: Lixin Chu <[EMAIL PROTECTED]>
> > >An: Struts Users Mailing List <user@struts.apache.org>
> > >Betreff: Re: Re: How to lock the access of methods within an action?
> > >&#xA> i think transaction manager will take care of this.
> > >
> > > On 5/30/06, Julian Tillmann <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Thanks a lot for your answer!
> > > >
> > > > My thinking behind is the application level!
> > > >
> > > > I'm not sure but the goal is (my hope..)to solve
> > > >
> > > > this problem using aspect oriented programming or Spring
> > > >
> > > > although I'm not very aware of it.
> > > >
> > > > For example it would be nice to have one central configuration there
> > you
> > > >
> > > > can say:
> > > >
> > > > this method -max-users 1-
> > > >
> > > > rule: throw error ….
> > > >
> > > > Should be done then a second users wants access to the method.
> > > >
> > > > Can you help me?
> > > >
> > > > Thanks a lot!
> > > >
> > > >> >-------- Original-Nachricht --------
> > > > >Datum: Tue, 30 May 2006 10:55:17 +0200
> > > > >Von: The Jasper <[EMAIL PROTECTED]>
> > > > >An: Struts Users Mailing List <user@struts.apache.org>
> > > > >Betreff: Re: How to lock the access of methods within an action?
> > > > >&#xA> Hi,
> > > > >
> > > > > this sounds like a common database problem. You might want to
> > consider
> > > > > some kind of pessimistic locking. Basically you lock the object
> when
> > > > > you start editing and prevent all access to it for the duration of
> > the
> > > > > lock. You could also do an optimistic lock which means that when
> you
> > > > > change an object it will only be committed if the object hasn't
> > > > > changed between the time you got your lock and the time you want
> to
> > > > > commit it. This doens't prevent you from having done unnecessary
> > work
> > > > > however. Most db's support optimistic locking, but not pessimistic
> > > > > locking.
> > > > >
> > > > > If you want to use this at the application level you will have to
> do
> > > > > it yourself. You could put a variable somewhere to track wether an
> > > > > object is being edited and base access restrictions off of that.
> > > > > However you have to be very carefull about making sure you don't
> get
> > > > > any deadlock or race conditions.
> > > > >
> > > > > I suggest you delve into database world and read about how other
> > > > > people have solved this problem.
> > > > >
> > > > > mvg,
> > > > > Jasper
> > > > >
> > > > > On 5/30/06, Julian Tillmann <[EMAIL PROTECTED]> wrote:
> > > > > > Hello everyone,
> > > > > >
> > > > > >>> Within our struts web application in which we have
> edit-actions
> > > > within
> > > > > a user can be busy editing data in the form for several minutes.
> > > > > >
> > > > > > The problem is, if another user is also editing the data at the
> > same
> > > > > time, one of the is eventually going to overwrite the changes of
> the
> > > > other and
> > > > > the other will have worked completely in vain. So my question
> would
> > be
> > > > > whether there's some way to prevent this from happening, some kind
> > of
> > > > "lock
> > > > > down" method for edit-actions? I think this problem is not
> uncommon,
> > > can
> > > > > someone give me a tip?
> > > > > >
> > > > > >>> thanks in advance
> > > > > > Julian
> > > > > >
> > > > > > --
> > > > > >
> > > > > >> Bis zu 70% Ihrer Onlinekosten sparen: GMX SmartSurfer!
> > > > > >       Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer
> > > > > >
> > > > > >>> >
> ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > > >
> > > > >>
> >---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > > --
> > > >
> > > >> Bis zu 70% Ihrer Onlinekosten sparen: GMX SmartSurfer!
> > > >       Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer
> > > >
> > > >>
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >>> --
> >
> >> Bis zu 70% Ihrer Onlinekosten sparen: GMX SmartSurfer!
> >       Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer
> >
> >> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >-- 
> Miguel Galves - Engenheiro de Computação
> Já leu meus blogs hoje?
> Para geeks http://log4dev.blogspot.com
> Pra pessoas normais
> http://miguelgalves.blogspot.com
> 
> "Não sabendo que era impossível, ele foi lá e fez..."

-- 


Bis zu 70% Ihrer Onlinekosten sparen: GMX SmartSurfer!
      Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer
    

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to