aspose file tools*
The moose likes Struts and the fly likes Whay action class is not singleton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Whay action class is not singleton" Watch "Whay action class is not singleton" New topic
Author

Whay action class is not singleton

Suvoraj Biswas
Greenhorn

Joined: Apr 02, 2008
Posts: 5
Since we've only one instance of Action class instantiated for any requests, so why struts designers have not made it as a singleton class.


Stuck in the middle of Java/PHP/Ajax/Javascript/Linux development?<br />For free help on any topics and free articles in latest technologies visit: <a href="http://www.techcubetalk.com" target="_blank" rel="nofollow">www.techcubetalk.com</a>
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Originally posted by Suvoraj Biswas:
Since we've only one instance of Action class instantiated for any requests


I'm not sure how Action is implemented or used, but the above is often said about Servlets, and it's not quite true:
the "one instance per servlet" model is a bit of a gloss-over. The truth is that each registered name for a servlet (but not each alias) is associated with one instance of the servlet. The name used to access the servlet determines which instance handles the request. This makes sense because the impression to the client should be that differently named servlets operate independently. The separate instances are also a requirement for servlets that accept initialization parameters

Java Servlet Programming

The Singleton pattern is considered as a Bad Idea by more than a few people.
In the case of Action, it would place an artificial and unnecessary restriction on the implementation of Struts. It's one thing to say there will "probably" be one instance and enforcing it by making Action a singleton.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Whay action class is not singleton