Announcement Announcement Module
Collapse
No announcement yet.
Annotation based controller and concurrent request (synchronization) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Annotation based controller and concurrent request (synchronization)

    Hi there,

    as I am changing my application from XML to annotation style (component scanning) I need further knowlege about how to get a AT-Controller (thread-) save.

    I've got one controller implementing the AT-Controller annotation. This controller is able to list, create, delete and edit the object. So I added a few methods: list, delete, create(GET), view(GET) and save(POST).

    -create and view must work on the same JSP template, but differ in the formBackingObject they use (create/empty & view/fromDatabase).
    -Update checks for an id and calls a DAO.new or DAO.update method.

    Furthermore I use AT-SessionAttributes to keep the attributes I do not want to pass to the JSP, but are important fields to update (e.g. id).

    so far everything works fine for me, but I cannot distinguish different edit requests.

    <b>Example</b>
    If I call object 3 and object 27 concurrently (tabbed browsing) only 27 is alive in my session and all changes I submit to 3 and 27 go to only 27.

    I think there must be an easy way to synchronize different requests from one user without having this trouble, but I do not know how to configure this.

    I wrote about synchronizeOnSession in HttpSession or stuff like this but do not know how to configure this in an annotation based Spring 2.5 environment with Hibernate 3 ...


    THX! :-)

    PS: Please let me know if you need any code examples...

    PPS: "You are only allowed to post URLs to other sites after you have made 15 posts or more." ... occurs whenever I use annotations (AT) ...

  • #2
    SPR-4818
    3.5.5 Custom scopes
    A Simple Conversation Scope for Spring-based Applications (PDF)

    This is all I found about this.
    Has anyone found a way to accomplish this? either with a custom solution (custom scope?) or with some esoteric spring config, so I can save a little time doing it myself??

    Thanks.
    Last edited by triqui; May 21st, 2010, 03:08 AM.

    Comment


    • #3
      As you may have read from triqui's post, there is no easy way of doing this. Not now and neither in the previous version of MVC.
      I think this will be a feature of the upcoming MVC 3.1, I think I read that somewhere.

      You have to understand that the browser does not make any difference between tabs. Without special markers that you (or the framework) have to create, there is no way to distinguish between requests of different tabs.

      What you can do for now is use the idea behind WebFlow, it supports the same flow definition to run in multiple tabs (each with it's own state). It does this by adding a special marker to every request called "execution", this marker is uniquely generated for each flow start. However you have to be careful to pass this marker (that is a request parameter) to each request. If you manually specify the URL of the submit form and do not include the "execution" marker in your URL or in a hidden field, webflow will no longer work.

      So the solution is to create a unique marker for your "conversation", and send the marker in each request (in every form submit or AJAX request). If you use @SessionAttributes, then you can implement a custom SessionAttributeStore that returns different objects based on that marker.

      Comment

      Working...
      X