This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is this an Overhead with Struts!!!

 
Rishi Singh
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rishi,
I am on the same boat with you. Keep my eye open on it.
 
Matthew X. Brown
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With flexibility comes overhead(ie. Jboss).
 
Matthew X. Brown
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Rishi Singh
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic