We don't need locks, we just need ActionInvocation to keep track of the old
ActionContext associated with the thread, and when an action is done being
executed, re-set it. I'll make sure that Actions-within-Actions is supported
properly.

-Pat

----- Original Message -----
From: "Matt Ho" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 21, 2003 7:53 PM
Subject: RE: [OS-webwork] XWork: calling Actions from Actions


> Here's a simple sequence diagram to help illustrate the issue:
>
>         MyAction     AnotherAction
>             |              |
>             |              |
> exectute -->O              |  --- A
>             O              |
>             O-- execute -->O  --- B
>             O              O
>             O              O
>             O<-------------O  --- C
>             O              |
>             O              |  --- D
>             |              |
>             |              |
>
> With the current implementation of ActionContext as a ThreadLocal, if
> you attempt to call an action from within an action, life works well
> until step C.  Because step B sets the ActionContext, when control
> returns to MyAction at point C, the ActionContext is not what you
> expect.
>
> Setting up the ActionContext during the invoke() could work:
>
>
>     private static ThreadLocal lock ;
>
>     static {
>         lock = new ThreadLocal() ;
>         lock.set(new Lock()) ;
>     }
>
>     public static class Lock {
>         private boolean locked = false;
>
>         private boolean acquired() {
>             if( !locked ) {
>                 return true;
>             } else {
>                 return false;
>             }
>         }
>
>         private void release() {
>             locked = false;
>
>         }
>     }
>
>     public void invoke() throws Exception {
>         Lock lock = (Lock)lock.get() ;
>         boolean haveLock = lock.acquire() ;
>
>         if( haveLock ) {
>           // nest storage
>         }
>
>         try {
>            ... execute my action
>         } finally {
>            lock.release() ;
>         }
>     }
>
> --
> Matt Ho
> Principal
> Indigo Egg, Inc.
> http://www.indigoegg.com/
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of
> > Jason Carreira
> > Sent: Friday, February 21, 2003 7:18 PM
> > To: [EMAIL PROTECTED]
> > Subject: RE: [OS-webwork] XWork: calling Actions from Actions
> >
> > So it would nest it during init and unnest at the end of invoke, or
> > when?
> >
> > > -----Original Message-----
> > > From: Patrick Lightbody [mailto:[EMAIL PROTECTED]
> > > Sent: Friday, February 21, 2003 8:05 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [OS-webwork] XWork: calling Actions from Actions
> > >
> > >
> > > Couldn't ActionInvocation just do nested storage of the
> > > ActionContext, just like GenericDispatcher did?
> > >
> > > -Pat
> > >
> > > ----- Original Message -----
> > > From: "Jason Carreira" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Thursday, February 20, 2003 12:20 PM
> > > Subject: RE: [OS-webwork] XWork: calling Actions from Actions
> > >
> > >
> > > > Patrick, this came up while you were gone. Did you have any
> > > thoughts
> > > > on this? In order to be able to do this easily, we'd need
> > > to pull the
> > > > ActionContext initialization out of the ActionInvocation
> > > > initialization, so you can use one ActionContext for multiple
> > > > invocations. Matt didn't like the option where you do:
> > > >
> > > > ActionContext myContext = ActionContext.getContext();
> > > ActionInvocation
> > > > anotherInvocation = new
> > > > ActionInvocation("someNamespace","anotherAction");
> > > > String otherResult = anotherInvocation.invoke();
> > > > ActionContext.setContext(myContext);
> > > >
> > > > Which would be needed to save the current context, then re-set it
> > > > after invoking the other action... This is not really
> > > pretty, but as
> > > > I'm thinking about it, it could be a helper method in
> > > ActionSupport...
> > > >
> > > > Jason
> > > >
> > >
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.net email is sponsored by: SlickEdit Inc. Develop an
> > > edge. The most comprehensive and flexible code editor you can
> > > use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE
> > > 30-Day Trial. www.slickedit.com/sourceforge
> > > _______________________________________________
> > > Opensymphony-webwork mailing list
> > > [EMAIL PROTECTED]
> > > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> > >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
> > The most comprehensive and flexible code editor you can use.
> > Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
> > www.slickedit.com/sourceforge
> > _______________________________________________
> > Opensymphony-webwork mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
> The most comprehensive and flexible code editor you can use.
> Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
> www.slickedit.com/sourceforge
> _______________________________________________
> Opensymphony-webwork mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to