Impact of having static methods in the helper classes of a Stateless Session Bean
1 posts in topic
Flat View  Flat View

Posted By:   Sathish_Kumar
Posted On:   Friday, October 19, 2001 03:07 PM

I have some helper classes for a stateless Session Bean all of which are utility classes that is they don't have a state of their own. So all the methods are designed as static methods. Will there be any performance degradation when the no of requests increases or when the no of stateless session bean instances increase in proportion to the requests. Also i would like to know the difference between the static method & non-static methods in terms of internal memory allocation (single area where all objects refer this method)

Re: Impact of having static methods in the helper classes of a Stateless Session Bean

Posted By:   Bozidar_Dangubic  
Posted On:   Saturday, October 20, 2001 01:36 PM

no performance degradation will occur with calling static utility classes. however, make sure that those static methods do not operate on the shared data. i.e. if you need those methods to operate on some data, pass that data as parameters to the method. since potentially many EJBs will be invoking this method at the same time, the only way to ensure that data on which it operates is correct is to pass that data to the method. each method invocation contains its own call stack and therefore concurrent calls to static method operate on their own copy of parameters that have been passed in to the method.

in terms of internal memory allocations, it should be obvious that static method is one per class and non-static methods is one per object. therefore, if you have a singleton class, there is the same memory allocation for static and non-static methods. however, if there are multiple objects instantiated for a class, more memory will be allocated for each non-static method of the class. the same applies for static and non-static variables. if a class declares a static char and non-static char, a memory for non-static char will be allocated for each instance of the class and only a single memory allocation will be established for a static char regardless of the number of instances of the class in the VM.
About | Sitemap | Contact