Announcement Announcement Module
Collapse
No announcement yet.
Ajax service aop scoped proxy and concurrency Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ajax service aop scoped proxy and concurrency

    Hey,

    I'm having a problem with serving Ajax calls in a spring-MVC application.

    Architecture and usecase overview:
    A user navigates to loanGeneralDefinitions.iframe which is referred by the servlet to a LoanController bean (singleton).
    This controller then creates a LoanSession bean (session scope), which is the command, and returns a JstlView.
    The Jsp is then responsible to populate some Divs in the client, through ajax calls (prototype framework) with content according to some indicators in the command.
    For example, if the Loan is a spiezer, then the Div should show the frequency and amount of payments, the start date, the monthly payment sum etc. If it is a different type of loan, then of course different data is presented in the Div. Of course the user can change the selection and the Div is then supposed to be populate with the data according to the user input.

    So the jsp performs an ajax call, and the servlet then refers it to a different controller, called the AjaxLoanController, which is also a singleton. This controller is initialized with a LoanSession through a setter.


    Another thing is that the user can also navigate between different tabs that causes a submit, each responsible for different terms of the loan (e.g. Interest tab, payments tab etc.). Each request is again referred to the LoanController.

    The problem appears when concurrent users edit their loans.
    The first one opens a Loan and then navigates, for example to the payments tab. Suppose it is a spiezer.
    Then, another user opens another loan, and navigates to the payments tab.
    Now the first user decides to change the payment type to a single payment.
    An ajax call is performed, after which the AjaxLoanController is supposed to create and return data for a single payment, on the amount of the principal of the loan. But instead, it returns a single payment on the amount of the principal of the second users loan.

    To clarify the problem, each time a user navigates to a tab (performs submit) the AjaxLoanController uses his LoanSession, and both users will work on this bean with ajax calls until the second users causes a submit, and then the second LoanSession would take over.

    Here is the relevant configuration:


    Code:
    <bean id="baseLoanControllerBeanDef" abstract="true" parent="generalControllerBeanDef">
    		<property name="assetDal" 					ref="assetDal"/>
    		<property name="enumerationsSource" 		ref="enumerationsSource"/>
    		<property name="loanSession"				ref="loanSession" />
    		<property name="loansObjectFactory" 		ref="loansObjectFactory"/>
    		<property name="loanDal" 					ref="loanDal"/>		
    	</bean>
    
    <bean name="/jsp/callLoanAjax.ajax"  class="com.modelity.loans.web.controllers.AjaxLoanController" parent="baseLoanControllerBeanDef"/>
    
    
    <bean id="loanSession" class="com.modelity.loans.beans.LoanSession" scope="session">
    	<property name="sessionStateHolder" ref="sessionStateHolder"/>
    	<property name="loansObjectFactory" ref="loansObjectFactory"/>
    	<property name="userAuthorization" ref="userAuthorization"/>
    	<aop:scoped-proxy/>
    </bean>

    I also tried putting the following in application context, and problem persists:
    Code:
    <aop:aspectj-autoproxy/>

    Thanks!!!
    Lior

  • #2
    correction

    Not only that the <aop:aspectj-autoproxy/> didn't help, it even made it worse.
    After adding it, the normal controller also used a shared LoanSession, and after the second user opens a loan for edit, the first is stuck with it forever (causing submit by switching tabs wouldn't help him).

    Comment


    • #3
      is there anybody out there that can assist?

      Comment

      Working...
      X