Pawan
Pawan

Reputation: 32331

Why there is no Singleton concept for Action class in Struts2?

I was going through differences of Struts1 vs Struts2, and came across this point:

Now my question is: in Struts2, why there are no singleton concept for Action class? As I think because, unnecessarily, there is more Object creation for every request. Please correct me if I am wrong.

Upvotes: 1

Views: 2438

Answers (2)

Shiju
Shiju

Reputation: 1

New instance in the sense, its not creating new object but jvm will create instance of that object hence there is no matter that how many request is comming for a particular object...even if the instance is more, the applcation will not hang...

Upvotes: 0

Dave Newton
Dave Newton

Reputation: 160251

Object creation is ridiculously fast in Java. Programming thread-safe action classes (and servlets, etc.) is irritating and error-prone.

Like with everything, there's a trade-off.

Upvotes: 2

Related Questions