aspose file tools*
The moose likes Struts and the fly likes Struts 2 action classes are not singleton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 action classes are not singleton" Watch "Struts 2 action classes are not singleton" New topic
Author

Struts 2 action classes are not singleton

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
Struts 2 action classes are not singleton

1)it will create new instance for each tread(each request eventhough from the same session)
2) It will create a instance for a session, consecutive threads from the session use the same instance
3) Since It create a new instance ,I do not worry about multithreading ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

1)it will create new instance for each tread(each request eventhough from the same session)
2) It will create a instance for a session, consecutive threads from the session use the same instance

Are you asking which one of those Struts 2 does? Every request instantiates a new action.
3) Since It create a new instance ,I do not worry about multithreading ?

In general, that's correct, as long as your actions don't have any un-synchronized static properties.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts 2 action classes are not singleton