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
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-
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>
Joined: Dec 09, 2000
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
Joined: Dec 02, 2002
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.