Announcement Announcement Module
Collapse
No announcement yet.
Session-scoped thread? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Session-scoped thread?

    Hi All.
    I have a bean which extends Thread and I want it to have scope = "session" so that I can retrieve it in struts actions via spring dependency injection. I.e.:

    Code:
    public abstract class A extends Thread{
       abstract void init();
       abstract void exec();
       public void run(){
          init();
          exec();
       }
    }
    
    public class B extends A{
       public void init(){
          System.out.println("I'm here!");
       }
       public void exec(){
          //nothing here
       }
    }
    
    public class MyAction extends Action{
       private A a;
       public void setA(A a){
          this.a = a;
       }
       public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception{
          Thread thr = new Thread(a);
          thr.start();
       }
    }
    and I have a spring mapping:
    Code:
    <bean id="b" class="com.my.B" scope="session">
       <aop:scoped-proxy/>
    </bean>
    <bean name="/test" class="com.my.actions.MyAction">
       <property name="a" ref="b"/>
    </bean>
    Why am I not having the text "I'm here!" in log when I access /test.do action?
Working...
X