pramod talekar wrote:Hello,
I'm working on Struts.
I went through the existing code written by my team and they have written many static methods in the action class.
So is it a right thing to mention such things in the action class apart from 'execute()' method, also the execute method is also containing business logic.
Also, should an action class have only one method i.e. execute ? not even a static block ?
The code is working fine. But is it a right design approach ?
Struts 1 Actions are singletons therefore they must be thread-safe because only one instance of a class handles all the requests for that Action. The singleton strategy restricts to Struts 1 Actions and requires extra care to make the action resources thread safe or synchronized while developing an application.
Struts 2 doesn't have thread-safety issues as Action objects are instantiated for each request. A servlet container generates many throw-away objects per request, and one more object does not impose a performance penalty or impact garbage collection.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton