aspose file tools*
The moose likes Struts and the fly likes Is this an Overhead with Struts!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Is this an Overhead with Struts!!!" Watch "Is this an Overhead with Struts!!!" New topic
Author

Is this an Overhead with Struts!!!

Rishi Singh
Ranch Hand

Joined: Dec 09, 2000
Posts: 321
Hi Ted,
Having a properties files which keeps a mapping of all the action with the corresponding class and its corresponding method(these methods being static)reading this property files in the init of the controller servlet which uses reflection and invokes the appropriate method of the class is a better way than to create objects of the same.I mean in Struts we deal with Action objects,Action Mapping Objects, ActionForward if the same is taken care by invoking of static methods it works .Now whether object creation at every stage of propagation is an overhead in case of Struts if we can do away without it.
Thanking you
Rishi Singh
SCJP,SCWCD
Doug Wang
Ranch Hand

Joined: Oct 05, 2001
Posts: 445
Hi Rishi,
I am on the same boat with you. Keep my eye open on it.


Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep
Matthew X. Brown
Ranch Hand

Joined: Nov 08, 2000
Posts: 165
With flexibility comes overhead(ie. Jboss).
Matthew X. Brown
Ranch Hand

Joined: Nov 08, 2000
Posts: 165
You know what would be interesting- you could bench mark the two ways of doing it- using a snoop servlet- or a hello world- with a standard servlet vs. a struts implementation. Or you could implement a simple MVC pattern using a standard controller and jsp redirect-
Ted Husted
Author
Ranch Hand

Joined: Dec 02, 2002
Posts: 37
The struts-config file serves the same purpose as the properties file you describe. The elements in the struts-config are used to create "static" Java objects at start-up. The only object that is created again is the ActionForm, which are usually very simple JavaBeans. The design is really as efficient as it gets.
But, hey, do whatever works for you. Struts is an open source framework written by working developers. We aren't trying to sell you anything, we're just sharing what we are using ourselves.
HTH, Ted.
[ December 05, 2002: Message edited by: Ted Husted ]

<a href="http://husted.com/struts/book.html" target="_blank" rel="nofollow">Struts in Action</a>
Rishi Singh
Ranch Hand

Joined: Dec 09, 2000
Posts: 321
Hi All,
Let me put the list of static configuration objects Struts creates .
1)ActionConfig
2)ActionMapping
3)ActionForward
4)ActionForm
Out of these the ActionMapping and ActionConfig are static ones ,ActionForward,ActionForm being created at runtime as per the scope defined in the struts-config.xml.Now i am of the opinion that things can be worked out with invokation of
static methods of the buisnesslogic class(action class) and the mapping can be maintained in a properties files which is loaded in init() of the controller servlet on start-up.
Ted i never wanted to comprehend the Struts Framework, its a proven and trusted framework for large web-applications ,i only wanted to deliberate on the use of object-creation.
Rishi Singh
SCJP,SCWCD
Ted Husted
Author
Ranch Hand

Joined: Dec 02, 2002
Posts: 37
The ActionForwards defined in the struts-config are not recreated at runtime; the same instance is reused. Only the ActionForms are instantiated at runtime. Everything else is only instantiated once.

HTH, Ted.
[ December 06, 2002: Message edited by: Ted Husted ]
 
 
subject: Is this an Overhead with Struts!!!