Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2846

Store Application in InheritableThreadLocal instead of ThreadLocal

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • None
    • 1.4.10
    • wicket
    • None

    Description

      Is there any particular reason why Application class wouldn't be stored in
      InheritableThreadLocal instead of ThreadLocal? The problem is that I need to
      be able to access Application class from a thread created when a button is
      pressed. Using InheritableThreadLocal instead of ThreadLocal would solve
      this problem.

      Use case example:

      public class MyPage extends Page {
      @SpringBean
      private MyService service;
      //perform a polling of long running process triggered by a button click
      onClickButton() {
      new Thread() {
      run()

      { service.executeLongRunningProcess(); }


      }.start();
      }
      }

      The following example won't work well if the Application is not stored in InheritableThreadLocal. The reason why it doesn't work, as I understand that, is because @SpringBean lookup depends on Application instance which is not accessible from within the thread. Having it stored inside of ITL would solve the problem.

      Thanks!
      Alex

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jthomerson Jeremy Thomerson
            alexandru.objelean Alexandru Objelean
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment