You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Stanton <pa...@mapshed.com.au> on 2012/03/15 05:45:10 UTC
Re: xhr requests and thread safety
In our application, many ajax requests are processed in the same
session, sometimes causing conflicts when they update shared session
information. I found synchronizing the logic within my event handlers to
be useless since many components access shared objects from property
bindings within the tml - outside of the scope of my synchronized block.
In order to combat this globally, I am considering synchronizing all
component event requests on the session:
public static void
contributeAjaxComponentEventRequestHandler(OrderedConfiguration<ComponentEventRequestFilter>
configuration)
{
configuration.addInstance("SessionSynch",
SessionSynchFilter.class);
}
public class SessionSynchFilterimplements ComponentEventRequestFilter
{
@Inject
private HttpServletRequest request;
@Override
public void handle(ComponentEventRequestParameters parameters,
ComponentEventRequestHandler handler) throws IOException
{
synchronized (request.getSession())
{
handler.handle(parameters);
}
}
}
Is this a crazy approach?
Thanks, Paul.
On 30/12/2011 3:43 PM, Josh Canfield wrote:
> unless you're dealing with concurrent requests to objects in a users
> session. When you're dealing with shared resources, protecting them
> from concurrent access is in the developers hands.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org